summaryrefslogtreecommitdiff
path: root/tests/plugins/project/test.lua
diff options
context:
space:
mode:
authorOpportunityLiu <[email protected]>2019-07-16 16:49:39 +0800
committerOpportunityLiu <[email protected]>2019-07-16 16:49:39 +0800
commita0192acccc14a218b79d73ed6013f5862abefd4f (patch)
tree4e0f85a5e34f1f1be56128d68f37d871ffff02c6 /tests/plugins/project/test.lua
parentbfeab8e24d26c92b8f52cf5aba431920e3bc6f11 (diff)
use tempdir for test
Diffstat (limited to 'tests/plugins/project/test.lua')
-rw-r--r--tests/plugins/project/test.lua80
1 files changed, 37 insertions, 43 deletions
diff --git a/tests/plugins/project/test.lua b/tests/plugins/project/test.lua
index 4f6ec3cc7..649a2e944 100644
--- a/tests/plugins/project/test.lua
+++ b/tests/plugins/project/test.lua
@@ -11,55 +11,49 @@ function test_vsxmake(t)
local projname = "testproj"
+ local tempdir = os.tmpdir()
+ os.mkdir(tempdir)
+ os.cd(tempdir)
+
-- create project
os.runv("xmake", {"create", projname})
+ os.cd(projname)
- -- build project
- local vs = find_vstudio()
+ -- 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")
- os.cd(projname)
+ local vstype = "vsxmake" .. vs
+ -- create sln & vcxproj
+ os.execv("xmake", {"project", "-k", vstype, "-a", arch})
+ os.cd(vstype)
- for name, _ in pairs(vs) do
- if tonumber(name) > 2010 then
- -- set config
- config.set("arch", arch, {readonly = true, force = true})
- config.set("vs", name, {readonly = true, force = true})
- config.check()
- platform.load(config.plat())
- environment.enter("toolchains")
-
- local vstype = "vsxmake" .. name
- -- 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.tryrm(vstype)
- end
- end
+ -- 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.tryrm(projname)
+ os.cd(os.scriptdir())
+ os.tryrm(tempdir)
end