From 2f3c8648289bb4e22eee5f8ff8d27afca6592fa4 Mon Sep 17 00:00:00 2001 From: roboo Date: Sun, 21 Aug 2016 21:50:38 +0200 Subject: Windows and appveyor support for tests --- spec/config_spec.lua | 70 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 19 deletions(-) (limited to 'spec/config_spec.lua') diff --git a/spec/config_spec.lua b/spec/config_spec.lua index 0dee8620..439d0493 100644 --- a/spec/config_spec.lua +++ b/spec/config_spec.lua @@ -2,6 +2,7 @@ local test_env = require("test/test_environment") local lfs = require("lfs") local run = test_env.run local testing_paths = test_env.testing_paths +local env_variables = test_env.env_variables local site_config test_env.unload_luarocks() @@ -21,12 +22,20 @@ describe("LuaRocks config tests #blackbox #b_config", function() it("LuaRocks config include dir", function() local output = run.luarocks("config --lua-incdir") - assert.are.same(output, site_config.LUA_INCDIR) + if test_env.TEST_TARGET_OS == "windows" then + assert.are.same(output, site_config.LUA_INCDIR:gsub("\\","/")) + else + assert.are.same(output, site_config.LUA_INCDIR) + end end) it("LuaRocks config library dir", function() local output = run.luarocks("config --lua-libdir") - assert.are.same(output, site_config.LUA_LIBDIR) + if test_env.TEST_TARGET_OS == "windows" then + assert.are.same(output, site_config.LUA_LIBDIR:gsub("\\","/")) + else + assert.are.same(output, site_config.LUA_LIBDIR) + end end) it("LuaRocks config lua version", function() @@ -53,38 +62,61 @@ describe("LuaRocks config tests #blackbox #b_config", function() end) describe("LuaRocks config - more complex tests", function() + local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" + local versioned_scname = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua" + local scname = scdir .. "/config.lua" + + local configfile + if test_env.TEST_TARGET_OS == "windows" then + configfile = versioned_scname + else + configfile = scname + end + it("LuaRocks fail system config", function() - os.remove(testing_paths.testing_lrprefix .. "/etc/luarocks/config.lua") - assert.is_false(run.luarocks_bool("config --system-config;")) + os.rename(versioned_scname, versioned_scname .. ".bak") + assert.is_false(run.luarocks_bool("config --system-config")) + os.rename(versioned_scname .. ".bak", versioned_scname) end) it("LuaRocks system config", function() - local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" lfs.mkdir(testing_paths.testing_lrprefix) lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") lfs.mkdir(scdir) - local sysconfig = io.open(scdir .. "/config.lua", "w+") - sysconfig:write(" ") - sysconfig:close() - - local output = run.luarocks("config --system-config;") - assert.are.same(output, scdir .. "/config.lua") - test_env.remove_dir(testing_paths.testing_lrprefix) + if test_env.TEST_TARGET_OS == "windows" then + local output = run.luarocks("config --system-config") + assert.are.same(output, versioned_scname) + else + sysconfig = io.open(scname, "w+") + sysconfig:write(" ") + sysconfig:close() + + local output = run.luarocks("config --system-config") + assert.are.same(output, scname) + os.remove(scname) + end end) it("LuaRocks fail system config invalid", function() - local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" lfs.mkdir(testing_paths.testing_lrprefix) lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") lfs.mkdir(scdir) - local sysconfig = io.open(scdir .. "/config.lua", "w+") - sysconfig:write("if if if") - sysconfig:close() - - assert.is_false(run.luarocks_bool("config --system-config;")) - test_env.remove_dir(testing_paths.testing_lrprefix) + if test_env.TEST_TARGET_OS == "windows" then + test_env.copy(versioned_scname, "versioned_scname_temp") + sysconfig = io.open(versioned_scname, "w+") + sysconfig:write("if if if") + sysconfig:close() + assert.is_false(run.luarocks_bool("config --system-config")) + test_env.copy("versioned_scname_temp", versioned_scname) + else + sysconfig = io.open(scname, "w+") + sysconfig:write("if if if") + sysconfig:close() + assert.is_false(run.luarocks_bool("config --system-config")) + os.remove(scname) + end end) end) end) -- cgit v1.2.3-55-g6feb From f1c9fd4895fe107683488c501bc07d4e22f46a4f Mon Sep 17 00:00:00 2001 From: roboo Date: Mon, 22 Aug 2016 13:40:03 +0200 Subject: Fix of config test --- spec/config_spec.lua | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) (limited to 'spec/config_spec.lua') diff --git a/spec/config_spec.lua b/spec/config_spec.lua index 439d0493..807b077a 100644 --- a/spec/config_spec.lua +++ b/spec/config_spec.lua @@ -61,7 +61,7 @@ describe("LuaRocks config tests #blackbox #b_config", function() end) end) - describe("LuaRocks config - more complex tests", function() + describe("LuaRocks config - more complex tests #special", function() local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" local versioned_scname = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua" local scname = scdir .. "/config.lua" @@ -74,9 +74,9 @@ describe("LuaRocks config tests #blackbox #b_config", function() end it("LuaRocks fail system config", function() - os.rename(versioned_scname, versioned_scname .. ".bak") + os.rename(configfile, configfile .. ".bak") assert.is_false(run.luarocks_bool("config --system-config")) - os.rename(versioned_scname .. ".bak", versioned_scname) + os.rename(configfile .. ".bak", configfile) end) it("LuaRocks system config", function() @@ -84,18 +84,20 @@ describe("LuaRocks config tests #blackbox #b_config", function() lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") lfs.mkdir(scdir) - if test_env.TEST_TARGET_OS == "windows" then - local output = run.luarocks("config --system-config") - assert.are.same(output, versioned_scname) - else - sysconfig = io.open(scname, "w+") + -- if test_env.TEST_TARGET_OS == "windows" then + -- local output = run.luarocks("config --system-config") + -- assert.are.same(output, versioned_scname) + -- else + local sysconfig = io.open(configfile, "w+") + test_env.copy(configfile, "configfile_temp") sysconfig:write(" ") sysconfig:close() local output = run.luarocks("config --system-config") - assert.are.same(output, scname) - os.remove(scname) - end + assert.are.same(output, configfile) + test_env.copy("configfile_temp", configfile) + os.remove("configfile_temp") + -- end end) it("LuaRocks fail system config invalid", function() @@ -103,20 +105,21 @@ describe("LuaRocks config tests #blackbox #b_config", function() lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") lfs.mkdir(scdir) - if test_env.TEST_TARGET_OS == "windows" then - test_env.copy(versioned_scname, "versioned_scname_temp") - sysconfig = io.open(versioned_scname, "w+") + -- if test_env.TEST_TARGET_OS == "windows" then + sysconfig = io.open(configfile, "w+") + test_env.copy(configfile, "configfile_temp") sysconfig:write("if if if") sysconfig:close() assert.is_false(run.luarocks_bool("config --system-config")) - test_env.copy("versioned_scname_temp", versioned_scname) - else - sysconfig = io.open(scname, "w+") - sysconfig:write("if if if") - sysconfig:close() - assert.is_false(run.luarocks_bool("config --system-config")) - os.remove(scname) - end + test_env.copy("configfile_temp", configfile) + os.remove("configfile_temp") + -- else + -- sysconfig = io.open(scname, "w+") + -- sysconfig:write("if if if") + -- sysconfig:close() + -- assert.is_false(run.luarocks_bool("config --system-config")) + -- os.remove(scname) + -- end end) end) end) -- cgit v1.2.3-55-g6feb From 1026d63ba37b8a1074c49797ce737edb5726ed2f Mon Sep 17 00:00:00 2001 From: roboo Date: Mon, 22 Aug 2016 13:50:53 +0200 Subject: Fix of config test --- spec/config_spec.lua | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'spec/config_spec.lua') diff --git a/spec/config_spec.lua b/spec/config_spec.lua index 807b077a..4a7f4aea 100644 --- a/spec/config_spec.lua +++ b/spec/config_spec.lua @@ -61,7 +61,7 @@ describe("LuaRocks config tests #blackbox #b_config", function() end) end) - describe("LuaRocks config - more complex tests #special", function() + describe("LuaRocks config - more complex tests", function() local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" local versioned_scname = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua" local scname = scdir .. "/config.lua" @@ -84,20 +84,18 @@ describe("LuaRocks config tests #blackbox #b_config", function() lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") lfs.mkdir(scdir) - -- if test_env.TEST_TARGET_OS == "windows" then - -- local output = run.luarocks("config --system-config") - -- assert.are.same(output, versioned_scname) - -- else + if test_env.TEST_TARGET_OS == "windows" then + local output = run.luarocks("config --system-config") + assert.are.same(output, configfile) + else local sysconfig = io.open(configfile, "w+") - test_env.copy(configfile, "configfile_temp") sysconfig:write(" ") sysconfig:close() local output = run.luarocks("config --system-config") assert.are.same(output, configfile) - test_env.copy("configfile_temp", configfile) - os.remove("configfile_temp") - -- end + os.remove(configfile) + end end) it("LuaRocks fail system config invalid", function() @@ -105,21 +103,20 @@ describe("LuaRocks config tests #blackbox #b_config", function() lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") lfs.mkdir(scdir) - -- if test_env.TEST_TARGET_OS == "windows" then - sysconfig = io.open(configfile, "w+") + if test_env.TEST_TARGET_OS == "windows" then test_env.copy(configfile, "configfile_temp") + local sysconfig = io.open(configfile, "w+") sysconfig:write("if if if") sysconfig:close() assert.is_false(run.luarocks_bool("config --system-config")) test_env.copy("configfile_temp", configfile) - os.remove("configfile_temp") - -- else - -- sysconfig = io.open(scname, "w+") - -- sysconfig:write("if if if") - -- sysconfig:close() - -- assert.is_false(run.luarocks_bool("config --system-config")) - -- os.remove(scname) - -- end + else + local sysconfig = io.open(configfile, "w+") + sysconfig:write("if if if") + sysconfig:close() + assert.is_false(run.luarocks_bool("config --system-config")) + os.remove(configfile) + end end) end) end) -- cgit v1.2.3-55-g6feb