diff options
| author | ruki <[email protected]> | 2019-07-16 17:28:30 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-07-16 17:28:30 +0800 |
| commit | 0724fda9aa61ee9d2b39198559a08cd22064d7a3 (patch) | |
| tree | 1dc6c47bc57d31c41fd11fa9d82ebe166a7cd9c5 /tests | |
| parent | d6be8e7effeca32a035ce89f1d02c28501b6a839 (diff) | |
| parent | 18714381a6257fd93c93344cb559fc409f6b1017 (diff) | |
Merge pull request #486 from OpportunityLiu/dev
Improve dump & fix vsxmake
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/cli/utils/test.lua | 4 | ||||
| -rw-r--r-- | tests/plugins/project/test.lua | 59 | ||||
| -rw-r--r-- | tests/runner.lua | 2 |
3 files changed, 63 insertions, 2 deletions
diff --git a/tests/cli/utils/test.lua b/tests/cli/utils/test.lua index f06a303a9..e54f5d0e6 100644 --- a/tests/cli/utils/test.lua +++ b/tests/cli/utils/test.lua @@ -6,7 +6,7 @@ end function test_help(t) import("core.base.task") - for _, t in ipairs(task.names()) do - os.execv("xmake", {t, "--help"}) + for _, taskname in ipairs(task.names()) do + os.runv("xmake", {taskname, "--help"}) end end diff --git a/tests/plugins/project/test.lua b/tests/plugins/project/test.lua new file mode 100644 index 000000000..c6e1069d9 --- /dev/null +++ b/tests/plugins/project/test.lua @@ -0,0 +1,59 @@ +import("detect.sdks.find_vstudio") +import("core.project.config") +import("core.platform.platform") +import("core.platform.environment") + +function test_vsxmake(t) + + if os.host() ~= "windows" then + return t:skip("wrong host platform") + end + + local projname = "testproj" + + local tempdir = os.tmpfile() + os.mkdir(tempdir) + os.cd(tempdir) + + -- create project + os.runv("xmake", {"create", projname}) + os.cd(projname) + + -- set config + local arch = os.getenv("platform") or "x86" + config.set("arch", arch, {readonly = true, force = true}) + config.check() + platform.load(config.plat()) + local vs = config.get("vs") + environment.enter("toolchains") + + local vstype = "vsxmake" .. vs + -- create sln & vcxproj + os.execv("xmake", {"project", "-k", vstype, "-a", arch}) + os.cd(vstype) + + -- run msbuild + try + { + function () + os.exec("msbuild /P:XmakeDiagnosis=true /P:XmakeVerbose=true") + end, + catch + { + function () + io.write("--- sln file ---\n") + io.cat(projname .. "_" .. vstype .. ".sln") + io.write("--- vcx file ---\n") + io.cat(projname .. "/" .. projname .. ".vcxproj") + io.write("--- filter file ---\n") + io.cat(projname .. "/" .. projname .. ".vcxproj.filters") + raise("msbuild failed") + end + } + } + environment.leave("toolchains") + + -- clean up + os.cd(os.scriptdir()) + os.tryrm(tempdir) +end diff --git a/tests/runner.lua b/tests/runner.lua index 227e66a7f..c99142170 100644 --- a/tests/runner.lua +++ b/tests/runner.lua @@ -44,6 +44,8 @@ function main(script) local result = try { function () + -- set workdir for each test + os.cd(root) return v(context) end, catch |
