diff options
| author | Peter Melnichenko <mpeterval@gmail.com> | 2016-07-08 14:30:00 +0300 |
|---|---|---|
| committer | Peter Melnichenko <mpeterval@gmail.com> | 2016-07-08 14:43:19 +0300 |
| commit | 8867f3324d97584ed24f3a1082144e9b1375d663 (patch) | |
| tree | 6d2ac6859128b94e02c7e9fb247cc505ab62d6c4 | |
| parent | 20a1baba59e7555b3140e0c2226948447fe8e62a (diff) | |
| download | luarocks-8867f3324d97584ed24f3a1082144e9b1375d663.tar.gz luarocks-8867f3324d97584ed24f3a1082144e9b1375d663.tar.bz2 luarocks-8867f3324d97584ed24f3a1082144e9b1375d663.zip | |
Make env vars, paths and run commands available on test env load
| -rw-r--r-- | spec/add_spec.lua | 4 | ||||
| -rw-r--r-- | spec/build_spec.lua | 4 | ||||
| -rw-r--r-- | spec/config_spec.lua | 4 | ||||
| -rw-r--r-- | spec/deps_spec.lua | 2 | ||||
| -rw-r--r-- | spec/doc_spec.lua | 3 | ||||
| -rw-r--r-- | spec/download_spec.lua | 2 | ||||
| -rw-r--r-- | spec/help_spec.lua | 2 | ||||
| -rw-r--r-- | spec/install_spec.lua | 6 | ||||
| -rw-r--r-- | spec/lint_spec.lua | 4 | ||||
| -rw-r--r-- | spec/list_spec.lua | 4 | ||||
| -rw-r--r-- | spec/make_manifest_spec.lua | 2 | ||||
| -rw-r--r-- | spec/make_spec.lua | 4 | ||||
| -rw-r--r-- | spec/new_version_spec.lua | 4 | ||||
| -rw-r--r-- | spec/pack_spec.lua | 3 | ||||
| -rw-r--r-- | spec/path_spec.lua | 2 | ||||
| -rw-r--r-- | spec/purge_spec.lua | 4 | ||||
| -rw-r--r-- | spec/refresh_cache_spec.lua | 2 | ||||
| -rw-r--r-- | spec/remove_spec.lua | 4 | ||||
| -rw-r--r-- | spec/search_spec.lua | 2 | ||||
| -rw-r--r-- | spec/show_spec.lua | 2 | ||||
| -rw-r--r-- | spec/unpack_spec.lua | 4 | ||||
| -rw-r--r-- | spec/upload_spec.lua | 2 | ||||
| -rw-r--r-- | spec/util_spec.lua | 6 | ||||
| -rw-r--r-- | spec/write_rockspec_spec.lua | 4 | ||||
| -rw-r--r-- | test/test_environment.lua | 94 |
25 files changed, 82 insertions, 92 deletions
diff --git a/spec/add_spec.lua b/spec/add_spec.lua index 930c221d..dca6f850 100644 --- a/spec/add_spec.lua +++ b/spec/add_spec.lua | |||
| @@ -1,4 +1,6 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local run = test_env.run | ||
| 3 | local testing_paths = test_env.testing_paths | ||
| 2 | 4 | ||
| 3 | test_env.unload_luarocks() | 5 | test_env.unload_luarocks() |
| 4 | 6 | ||
| @@ -11,8 +13,6 @@ describe("LuaRocks add tests #blackbox #b_add", function() | |||
| 11 | 13 | ||
| 12 | before_each(function() | 14 | before_each(function() |
| 13 | test_env.setup_specs(extra_rocks) | 15 | test_env.setup_specs(extra_rocks) |
| 14 | testing_paths = test_env.testing_paths | ||
| 15 | run = test_env.run | ||
| 16 | end) | 16 | end) |
| 17 | 17 | ||
| 18 | describe("LuaRocks-admin add tests", function() | 18 | describe("LuaRocks-admin add tests", function() |
diff --git a/spec/build_spec.lua b/spec/build_spec.lua index 7248e8f0..1ce99089 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local lfs = require("lfs") | 2 | local lfs = require("lfs") |
| 3 | local run = test_env.run | ||
| 4 | local testing_paths = test_env.testing_paths | ||
| 3 | 5 | ||
| 4 | test_env.unload_luarocks() | 6 | test_env.unload_luarocks() |
| 5 | 7 | ||
| @@ -29,8 +31,6 @@ describe("LuaRocks build tests #blackbox #b_build", function() | |||
| 29 | 31 | ||
| 30 | before_each(function() | 32 | before_each(function() |
| 31 | test_env.setup_specs(extra_rocks) | 33 | test_env.setup_specs(extra_rocks) |
| 32 | testing_paths = test_env.testing_paths | ||
| 33 | run = test_env.run | ||
| 34 | end) | 34 | end) |
| 35 | 35 | ||
| 36 | describe("LuaRocks build - basic testing set", function() | 36 | describe("LuaRocks build - basic testing set", function() |
diff --git a/spec/config_spec.lua b/spec/config_spec.lua index df2480ac..4a09fdcf 100644 --- a/spec/config_spec.lua +++ b/spec/config_spec.lua | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local lfs = require("lfs") | 2 | local lfs = require("lfs") |
| 3 | local run = test_env.run | ||
| 4 | local testing_paths = test_env.testing_paths | ||
| 3 | 5 | ||
| 4 | test_env.unload_luarocks() | 6 | test_env.unload_luarocks() |
| 5 | 7 | ||
| @@ -9,8 +11,6 @@ describe("LuaRocks config tests #blackbox #b_config", function() | |||
| 9 | test_env.setup_specs(extra_rocks) | 11 | test_env.setup_specs(extra_rocks) |
| 10 | test_env.unload_luarocks() -- need to be required here, because site_config is created after first loading of specs | 12 | test_env.unload_luarocks() -- need to be required here, because site_config is created after first loading of specs |
| 11 | site_config = require("luarocks.site_config") | 13 | site_config = require("luarocks.site_config") |
| 12 | testing_paths = test_env.testing_paths | ||
| 13 | run = test_env.run | ||
| 14 | end) | 14 | end) |
| 15 | 15 | ||
| 16 | describe("LuaRocks config - basic tests", function() | 16 | describe("LuaRocks config - basic tests", function() |
diff --git a/spec/deps_spec.lua b/spec/deps_spec.lua index 9bb4709d..5df96452 100644 --- a/spec/deps_spec.lua +++ b/spec/deps_spec.lua | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local lfs = require("lfs") | 2 | local lfs = require("lfs") |
| 3 | local run = test_env.run | ||
| 4 | local testing_paths = test_env.testing_paths | ||
| 3 | 5 | ||
| 4 | test_env.unload_luarocks() | 6 | test_env.unload_luarocks() |
| 5 | 7 | ||
diff --git a/spec/doc_spec.lua b/spec/doc_spec.lua index e4e7f5f2..9dbeaab8 100644 --- a/spec/doc_spec.lua +++ b/spec/doc_spec.lua | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local run = test_env.run | ||
| 2 | 3 | ||
| 3 | test_env.unload_luarocks() | 4 | test_env.unload_luarocks() |
| 4 | 5 | ||
| @@ -10,8 +11,6 @@ describe("LuaRocks doc tests #blackbox #b_doc", function() | |||
| 10 | 11 | ||
| 11 | before_each(function() | 12 | before_each(function() |
| 12 | test_env.setup_specs(extra_rocks) | 13 | test_env.setup_specs(extra_rocks) |
| 13 | testing_paths = test_env.testing_paths | ||
| 14 | run = test_env.run | ||
| 15 | end) | 14 | end) |
| 16 | 15 | ||
| 17 | describe("LuaRocks doc basic tests", function() | 16 | describe("LuaRocks doc basic tests", function() |
diff --git a/spec/download_spec.lua b/spec/download_spec.lua index 2485960d..320d9304 100644 --- a/spec/download_spec.lua +++ b/spec/download_spec.lua | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local lfs = require("lfs") | 2 | local lfs = require("lfs") |
| 3 | local run = test_env.run | ||
| 3 | 4 | ||
| 4 | test_env.unload_luarocks() | 5 | test_env.unload_luarocks() |
| 5 | 6 | ||
| @@ -11,7 +12,6 @@ describe("LuaRocks download tests #blackbox #b_download", function() | |||
| 11 | 12 | ||
| 12 | before_each(function() | 13 | before_each(function() |
| 13 | test_env.setup_specs(extra_rocks) | 14 | test_env.setup_specs(extra_rocks) |
| 14 | run = test_env.run | ||
| 15 | end) | 15 | end) |
| 16 | 16 | ||
| 17 | it("LuaRocks download with no flags/arguments", function() | 17 | it("LuaRocks download with no flags/arguments", function() |
diff --git a/spec/help_spec.lua b/spec/help_spec.lua index 376b6ceb..35bb6817 100644 --- a/spec/help_spec.lua +++ b/spec/help_spec.lua | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local run = test_env.run | ||
| 2 | 3 | ||
| 3 | test_env.unload_luarocks() | 4 | test_env.unload_luarocks() |
| 4 | 5 | ||
| @@ -6,7 +7,6 @@ describe("LuaRocks help tests #blackbox #b_help", function() | |||
| 6 | 7 | ||
| 7 | before_each(function() | 8 | before_each(function() |
| 8 | test_env.setup_specs(extra_rocks) | 9 | test_env.setup_specs(extra_rocks) |
| 9 | run = test_env.run | ||
| 10 | end) | 10 | end) |
| 11 | 11 | ||
| 12 | it("LuaRocks help with no flags/arguments", function() | 12 | it("LuaRocks help with no flags/arguments", function() |
diff --git a/spec/install_spec.lua b/spec/install_spec.lua index f8869791..876e25fc 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua | |||
| @@ -1,5 +1,8 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local lfs = require("lfs") | 2 | local lfs = require("lfs") |
| 3 | local run = test_env.run | ||
| 4 | local testing_paths = test_env.testing_paths | ||
| 5 | local env_variables = test_env.env_variables | ||
| 3 | 6 | ||
| 4 | test_env.unload_luarocks() | 7 | test_env.unload_luarocks() |
| 5 | 8 | ||
| @@ -22,9 +25,6 @@ describe("LuaRocks install tests #blackbox #b_install", function() | |||
| 22 | 25 | ||
| 23 | before_each(function() | 26 | before_each(function() |
| 24 | test_env.setup_specs(extra_rocks) | 27 | test_env.setup_specs(extra_rocks) |
| 25 | testing_paths = test_env.testing_paths | ||
| 26 | env_variables = test_env.env_variables | ||
| 27 | run = test_env.run | ||
| 28 | platform = test_env.platform | 28 | platform = test_env.platform |
| 29 | end) | 29 | end) |
| 30 | 30 | ||
diff --git a/spec/lint_spec.lua b/spec/lint_spec.lua index ce753618..f7496037 100644 --- a/spec/lint_spec.lua +++ b/spec/lint_spec.lua | |||
| @@ -1,4 +1,6 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local run = test_env.run | ||
| 3 | local testing_paths = test_env.testing_paths | ||
| 2 | 4 | ||
| 3 | test_env.unload_luarocks() | 5 | test_env.unload_luarocks() |
| 4 | 6 | ||
| @@ -10,8 +12,6 @@ describe("LuaRocks lint tests #blackbox #b_lint", function() | |||
| 10 | 12 | ||
| 11 | before_each(function() | 13 | before_each(function() |
| 12 | test_env.setup_specs(extra_rocks) | 14 | test_env.setup_specs(extra_rocks) |
| 13 | testing_paths = test_env.testing_paths | ||
| 14 | run = test_env.run | ||
| 15 | end) | 15 | end) |
| 16 | 16 | ||
| 17 | it("LuaRocks lint with no flags/arguments", function() | 17 | it("LuaRocks lint with no flags/arguments", function() |
diff --git a/spec/list_spec.lua b/spec/list_spec.lua index 344607e3..1b082ab6 100644 --- a/spec/list_spec.lua +++ b/spec/list_spec.lua | |||
| @@ -1,4 +1,6 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local run = test_env.run | ||
| 3 | local testing_paths = test_env.testing_paths | ||
| 2 | 4 | ||
| 3 | test_env.unload_luarocks() | 5 | test_env.unload_luarocks() |
| 4 | 6 | ||
| @@ -11,8 +13,6 @@ describe("LuaRocks list tests #blackbox #b_list", function() | |||
| 11 | 13 | ||
| 12 | before_each(function() | 14 | before_each(function() |
| 13 | test_env.setup_specs(extra_rocks) | 15 | test_env.setup_specs(extra_rocks) |
| 14 | run = test_env.run | ||
| 15 | testing_paths = test_env.testing_paths | ||
| 16 | end) | 16 | end) |
| 17 | 17 | ||
| 18 | it("LuaRocks list with no flags/arguments", function() | 18 | it("LuaRocks list with no flags/arguments", function() |
diff --git a/spec/make_manifest_spec.lua b/spec/make_manifest_spec.lua index c6b0753c..5bd9e2f3 100644 --- a/spec/make_manifest_spec.lua +++ b/spec/make_manifest_spec.lua | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local run = test_env.run | ||
| 2 | 3 | ||
| 3 | test_env.unload_luarocks() | 4 | test_env.unload_luarocks() |
| 4 | 5 | ||
| @@ -6,7 +7,6 @@ describe("LuaRocks make_manifest tests #blackbox #b_make_manifest", function() | |||
| 6 | 7 | ||
| 7 | before_each(function() | 8 | before_each(function() |
| 8 | test_env.setup_specs(extra_rocks) | 9 | test_env.setup_specs(extra_rocks) |
| 9 | run = test_env.run | ||
| 10 | end) | 10 | end) |
| 11 | 11 | ||
| 12 | describe("LuaRocks-admin make manifest tests", function() | 12 | describe("LuaRocks-admin make manifest tests", function() |
diff --git a/spec/make_spec.lua b/spec/make_spec.lua index 5ae23fd5..2821c143 100644 --- a/spec/make_spec.lua +++ b/spec/make_spec.lua | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local lfs = require("lfs") | 2 | local lfs = require("lfs") |
| 3 | local run = test_env.run | ||
| 4 | local testing_paths = test_env.testing_paths | ||
| 3 | 5 | ||
| 4 | test_env.unload_luarocks() | 6 | test_env.unload_luarocks() |
| 5 | 7 | ||
| @@ -15,8 +17,6 @@ describe("LuaRocks make tests #blackbox #b_make", function() | |||
| 15 | 17 | ||
| 16 | before_each(function() | 18 | before_each(function() |
| 17 | test_env.setup_specs(extra_rocks) | 19 | test_env.setup_specs(extra_rocks) |
| 18 | run = test_env.run | ||
| 19 | testing_paths = test_env.testing_paths | ||
| 20 | end) | 20 | end) |
| 21 | 21 | ||
| 22 | it("LuaRocks make with no flags/arguments", function() | 22 | it("LuaRocks make with no flags/arguments", function() |
diff --git a/spec/new_version_spec.lua b/spec/new_version_spec.lua index 140c9906..2274bce3 100644 --- a/spec/new_version_spec.lua +++ b/spec/new_version_spec.lua | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local lfs = require("lfs") | 2 | local lfs = require("lfs") |
| 3 | local run = test_env.run | ||
| 4 | local testing_paths = test_env.testing_paths | ||
| 3 | 5 | ||
| 4 | test_env.unload_luarocks() | 6 | test_env.unload_luarocks() |
| 5 | 7 | ||
| @@ -11,8 +13,6 @@ describe("LuaRocks new_version tests #blackbox #b_new_version", function() | |||
| 11 | 13 | ||
| 12 | before_each(function() | 14 | before_each(function() |
| 13 | test_env.setup_specs(extra_rocks) | 15 | test_env.setup_specs(extra_rocks) |
| 14 | testing_paths = test_env.testing_paths | ||
| 15 | run = test_env.run | ||
| 16 | end) | 16 | end) |
| 17 | 17 | ||
| 18 | describe("LuaRocks new_version basic tests", function() | 18 | describe("LuaRocks new_version basic tests", function() |
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua index 1671152c..416184a8 100644 --- a/spec/pack_spec.lua +++ b/spec/pack_spec.lua | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local lfs = require("lfs") | 2 | local lfs = require("lfs") |
| 3 | local run = test_env.run | ||
| 3 | 4 | ||
| 4 | test_env.unload_luarocks() | 5 | test_env.unload_luarocks() |
| 5 | 6 | ||
| @@ -13,8 +14,6 @@ describe("LuaRocks pack tests #blackbox #b_pack", function() | |||
| 13 | 14 | ||
| 14 | before_each(function() | 15 | before_each(function() |
| 15 | test_env.setup_specs(extra_rocks) | 16 | test_env.setup_specs(extra_rocks) |
| 16 | testing_paths = test_env.testing_paths | ||
| 17 | run = test_env.run | ||
| 18 | end) | 17 | end) |
| 19 | 18 | ||
| 20 | it("LuaRocks pack basic", function() | 19 | it("LuaRocks pack basic", function() |
diff --git a/spec/path_spec.lua b/spec/path_spec.lua index d201f337..fcdb36cf 100644 --- a/spec/path_spec.lua +++ b/spec/path_spec.lua | |||
| @@ -1,11 +1,11 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local run = test_env.run | ||
| 2 | 3 | ||
| 3 | test_env.unload_luarocks() | 4 | test_env.unload_luarocks() |
| 4 | 5 | ||
| 5 | describe("LuaRocks path tests #blackbox #b_path", function() | 6 | describe("LuaRocks path tests #blackbox #b_path", function() |
| 6 | before_each(function() | 7 | before_each(function() |
| 7 | test_env.setup_specs(extra_rocks) | 8 | test_env.setup_specs(extra_rocks) |
| 8 | run = test_env.run | ||
| 9 | end) | 9 | end) |
| 10 | 10 | ||
| 11 | it("LuaRocks path bin", function() | 11 | it("LuaRocks path bin", function() |
diff --git a/spec/purge_spec.lua b/spec/purge_spec.lua index 30ce15e2..e6f12ddb 100644 --- a/spec/purge_spec.lua +++ b/spec/purge_spec.lua | |||
| @@ -1,12 +1,12 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local run = test_env.run | ||
| 3 | local testing_paths = test_env.testing_paths | ||
| 2 | 4 | ||
| 3 | test_env.unload_luarocks() | 5 | test_env.unload_luarocks() |
| 4 | 6 | ||
| 5 | describe("LuaRocks purge tests #blackbox #b_purge", function() | 7 | describe("LuaRocks purge tests #blackbox #b_purge", function() |
| 6 | before_each(function() | 8 | before_each(function() |
| 7 | test_env.setup_specs(extra_rocks) | 9 | test_env.setup_specs(extra_rocks) |
| 8 | testing_paths = test_env.testing_paths | ||
| 9 | run = test_env.run | ||
| 10 | end) | 10 | end) |
| 11 | 11 | ||
| 12 | describe("LuaRocks purge basic tests", function() | 12 | describe("LuaRocks purge basic tests", function() |
diff --git a/spec/refresh_cache_spec.lua b/spec/refresh_cache_spec.lua index 764cbcb5..34d211ab 100644 --- a/spec/refresh_cache_spec.lua +++ b/spec/refresh_cache_spec.lua | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local run = test_env.run | ||
| 2 | 3 | ||
| 3 | test_env.unload_luarocks() | 4 | test_env.unload_luarocks() |
| 4 | 5 | ||
| @@ -6,7 +7,6 @@ describe("LuaRocks refresh_cache tests #blackbox #b_refresh_cache", function() | |||
| 6 | 7 | ||
| 7 | before_each(function() | 8 | before_each(function() |
| 8 | test_env.setup_specs(extra_rocks) | 9 | test_env.setup_specs(extra_rocks) |
| 9 | run = test_env.run | ||
| 10 | end) | 10 | end) |
| 11 | 11 | ||
| 12 | describe("LuaRocks-admin refresh cache tests #ssh", function() | 12 | describe("LuaRocks-admin refresh cache tests #ssh", function() |
diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua index 4129e755..41c6348a 100644 --- a/spec/remove_spec.lua +++ b/spec/remove_spec.lua | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local lfs = require("lfs") | 2 | local lfs = require("lfs") |
| 3 | local run = test_env.run | ||
| 4 | local testing_paths = test_env.testing_paths | ||
| 3 | 5 | ||
| 4 | test_env.unload_luarocks() | 6 | test_env.unload_luarocks() |
| 5 | 7 | ||
| @@ -14,8 +16,6 @@ describe("LuaRocks remove tests #blackbox #b_remove", function() | |||
| 14 | 16 | ||
| 15 | before_each(function() | 17 | before_each(function() |
| 16 | test_env.setup_specs(extra_rocks) | 18 | test_env.setup_specs(extra_rocks) |
| 17 | testing_paths = test_env.testing_paths | ||
| 18 | run = test_env.run | ||
| 19 | end) | 19 | end) |
| 20 | 20 | ||
| 21 | describe("LuaRocks remove basic tests", function() | 21 | describe("LuaRocks remove basic tests", function() |
diff --git a/spec/search_spec.lua b/spec/search_spec.lua index 93e85928..33c49856 100644 --- a/spec/search_spec.lua +++ b/spec/search_spec.lua | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local run = test_env.run | ||
| 2 | 3 | ||
| 3 | test_env.unload_luarocks() | 4 | test_env.unload_luarocks() |
| 4 | 5 | ||
| @@ -10,7 +11,6 @@ describe("LuaRocks search tests #blackbox #b_search", function() | |||
| 10 | 11 | ||
| 11 | before_each(function() | 12 | before_each(function() |
| 12 | test_env.setup_specs(extra_rocks) | 13 | test_env.setup_specs(extra_rocks) |
| 13 | run = test_env.run | ||
| 14 | end) | 14 | end) |
| 15 | 15 | ||
| 16 | it("LuaRocks search with no flags/arguments", function() | 16 | it("LuaRocks search with no flags/arguments", function() |
diff --git a/spec/show_spec.lua b/spec/show_spec.lua index a58eea52..6f055612 100644 --- a/spec/show_spec.lua +++ b/spec/show_spec.lua | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local run = test_env.run | ||
| 2 | 3 | ||
| 3 | test_env.unload_luarocks() | 4 | test_env.unload_luarocks() |
| 4 | 5 | ||
| @@ -6,7 +7,6 @@ describe("LuaRocks show tests #blackbox #b_show", function() | |||
| 6 | 7 | ||
| 7 | before_each(function() | 8 | before_each(function() |
| 8 | test_env.setup_specs(extra_rocks) | 9 | test_env.setup_specs(extra_rocks) |
| 9 | run = test_env.run | ||
| 10 | end) | 10 | end) |
| 11 | 11 | ||
| 12 | it("LuaRocks show with no flags/arguments", function() | 12 | it("LuaRocks show with no flags/arguments", function() |
diff --git a/spec/unpack_spec.lua b/spec/unpack_spec.lua index 1e9df811..db71aa06 100644 --- a/spec/unpack_spec.lua +++ b/spec/unpack_spec.lua | |||
| @@ -1,4 +1,6 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local run = test_env.run | ||
| 3 | local testing_paths = test_env.testing_paths | ||
| 2 | 4 | ||
| 3 | test_env.unload_luarocks() | 5 | test_env.unload_luarocks() |
| 4 | 6 | ||
| @@ -11,8 +13,6 @@ describe("LuaRocks unpack tests #blackbox #b_unpack", function() | |||
| 11 | 13 | ||
| 12 | before_each(function() | 14 | before_each(function() |
| 13 | test_env.setup_specs(extra_rocks) | 15 | test_env.setup_specs(extra_rocks) |
| 14 | testing_paths = test_env.testing_paths | ||
| 15 | run = test_env.run | ||
| 16 | platform = test_env.platform | 16 | platform = test_env.platform |
| 17 | end) | 17 | end) |
| 18 | 18 | ||
diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua index ce998987..c10ef0e9 100644 --- a/spec/upload_spec.lua +++ b/spec/upload_spec.lua | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local run = test_env.run | ||
| 2 | 3 | ||
| 3 | test_env.unload_luarocks() | 4 | test_env.unload_luarocks() |
| 4 | 5 | ||
| @@ -10,7 +11,6 @@ describe("LuaRocks upload tests #blackbox #b_upload", function() | |||
| 10 | 11 | ||
| 11 | before_each(function() | 12 | before_each(function() |
| 12 | test_env.setup_specs(extra_rocks) | 13 | test_env.setup_specs(extra_rocks) |
| 13 | run = test_env.run | ||
| 14 | end) | 14 | end) |
| 15 | 15 | ||
| 16 | it("LuaRocks upload with no flags/arguments", function() | 16 | it("LuaRocks upload with no flags/arguments", function() |
diff --git a/spec/util_spec.lua b/spec/util_spec.lua index 7e0289d6..39ce3c83 100644 --- a/spec/util_spec.lua +++ b/spec/util_spec.lua | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local lfs = require("lfs") | 2 | local lfs = require("lfs") |
| 3 | local run = test_env.run | ||
| 4 | local testing_paths = test_env.testing_paths | ||
| 5 | local env_variables = test_env.env_variables | ||
| 3 | 6 | ||
| 4 | describe("Basic tests #blackbox #b_util", function() | 7 | describe("Basic tests #blackbox #b_util", function() |
| 5 | 8 | ||
| 6 | before_each(function() | 9 | before_each(function() |
| 7 | test_env.setup_specs(extra_rocks) | 10 | test_env.setup_specs(extra_rocks) |
| 8 | testing_paths = test_env.testing_paths | ||
| 9 | env_variables = test_env.env_variables | ||
| 10 | run = test_env.run | ||
| 11 | end) | 11 | end) |
| 12 | 12 | ||
| 13 | it("LuaRocks version", function() | 13 | it("LuaRocks version", function() |
diff --git a/spec/write_rockspec_spec.lua b/spec/write_rockspec_spec.lua index 4c29f204..cf0a642e 100644 --- a/spec/write_rockspec_spec.lua +++ b/spec/write_rockspec_spec.lua | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | local test_env = require("test/test_environment") | 1 | local test_env = require("test/test_environment") |
| 2 | local lfs = require("lfs") | 2 | local lfs = require("lfs") |
| 3 | local run = test_env.run | ||
| 3 | 4 | ||
| 4 | test_env.unload_luarocks() | 5 | test_env.unload_luarocks() |
| 5 | local write_rockspec = require("luarocks.write_rockspec") | 6 | local write_rockspec = require("luarocks.write_rockspec") |
| @@ -8,7 +9,6 @@ describe("LuaRocks write_rockspec tests #blackbox #b_write_rockspec", function() | |||
| 8 | 9 | ||
| 9 | before_each(function() | 10 | before_each(function() |
| 10 | test_env.setup_specs(extra_rocks) | 11 | test_env.setup_specs(extra_rocks) |
| 11 | run = test_env.run | ||
| 12 | end) | 12 | end) |
| 13 | 13 | ||
| 14 | describe("LuaRocks write_rockspec basic tests", function() | 14 | describe("LuaRocks write_rockspec basic tests", function() |
| @@ -71,4 +71,4 @@ describe("LuaRocks write_rockspec tests #blackbox #b_write_rockspec", function() | |||
| 71 | assert.is_true(os.remove("luafcgi-scm-1.rockspec")) | 71 | assert.is_true(os.remove("luafcgi-scm-1.rockspec")) |
| 72 | end) | 72 | end) |
| 73 | end) | 73 | end) |
| 74 | end) \ No newline at end of file | 74 | end) |
diff --git a/test/test_environment.lua b/test/test_environment.lua index bde43163..b3ac3b18 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua | |||
| @@ -254,44 +254,40 @@ local function create_md5sums(testing_paths) | |||
| 254 | return md5sums | 254 | return md5sums |
| 255 | end | 255 | end |
| 256 | 256 | ||
| 257 | local function run_luarocks(testing_paths, env_variables) | 257 | local function make_run_function(cmd_name, exec_function, with_coverage, do_print) |
| 258 | 258 | local cmd_prefix = test_env.testing_paths.lua .. " " | |
| 259 | local function make_command_function(exec_function, lua_cmd, do_print) | 259 | |
| 260 | return function(cmd, new_vars) | 260 | if with_coverage then |
| 261 | local temp_vars = {} | 261 | cmd_prefix = cmd_prefix .. "-e \"require('luacov.runner')('" .. test_env.testing_paths.testing_dir .. "/luacov.config')\" " |
| 262 | for k, v in pairs(env_variables) do | 262 | end |
| 263 | |||
| 264 | cmd_prefix = cmd_prefix .. test_env.testing_paths.src_dir .. "/bin/" .. cmd_name .. " " | ||
| 265 | |||
| 266 | return function(cmd, new_vars) | ||
| 267 | local temp_vars = {} | ||
| 268 | for k, v in pairs(test_env.env_variables) do | ||
| 269 | temp_vars[k] = v | ||
| 270 | end | ||
| 271 | if new_vars then | ||
| 272 | for k, v in pairs(new_vars) do | ||
| 263 | temp_vars[k] = v | 273 | temp_vars[k] = v |
| 264 | end | 274 | end |
| 265 | if new_vars then | ||
| 266 | for k, v in pairs(new_vars) do | ||
| 267 | temp_vars[k] = v | ||
| 268 | end | ||
| 269 | end | ||
| 270 | return exec_function(lua_cmd .. cmd, do_print, temp_vars) | ||
| 271 | end | 275 | end |
| 276 | return exec_function(cmd_prefix .. cmd, do_print, temp_vars) | ||
| 272 | end | 277 | end |
| 278 | end | ||
| 273 | 279 | ||
| 274 | local run = {} | 280 | local function make_run_functions() |
| 275 | 281 | return { | |
| 276 | local cov_str = testing_paths.lua .. " -e\"require('luacov.runner')('" .. testing_paths.testing_dir .. "/luacov.config')\" " | 282 | luarocks = make_run_function("luarocks", execute_output, true, true), |
| 277 | 283 | luarocks_bool = make_run_function("luarocks", execute_bool, true, true), | |
| 278 | local luarocks_cmd = cov_str .. testing_paths.src_dir .. "/bin/luarocks " | 284 | luarocks_noprint = make_run_function("luarocks", execute_bool, true, false), |
| 279 | run.luarocks = make_command_function(execute_output, luarocks_cmd, true) | 285 | luarocks_nocov = make_run_function("luarocks", execute_bool, false, true), |
| 280 | run.luarocks_bool = make_command_function(execute_bool, luarocks_cmd, true) | 286 | luarocks_noprint_nocov = make_run_function("luarocks", execute_bool, false, false), |
| 281 | run.luarocks_noprint = make_command_function(execute_bool, luarocks_cmd, false) | 287 | luarocks_admin = make_run_function("luarocks-admin", execute_output, true, true), |
| 282 | 288 | luarocks_admin_bool = make_run_function("luarocks-admin", execute_bool, true, true), | |
| 283 | local luarocks_nocov_cmd = testing_paths.lua .. " " .. testing_paths.src_dir .. "/bin/luarocks " | 289 | luarocks_admin_nocov = make_run_function("luarocks-admin", execute_bool, false, false) |
| 284 | run.luarocks_nocov = make_command_function(execute_bool, luarocks_nocov_cmd, true) | 290 | } |
| 285 | run.luarocks_noprint_nocov = make_command_function(execute_bool, luarocks_nocov_cmd, false) | ||
| 286 | |||
| 287 | local luarocks_admin_cmd = cov_str .. testing_paths.src_dir .. "/bin/luarocks-admin " | ||
| 288 | run.luarocks_admin = make_command_function(execute_output, luarocks_admin_cmd, true) | ||
| 289 | run.luarocks_admin_bool = make_command_function(execute_bool, luarocks_admin_cmd, true) | ||
| 290 | |||
| 291 | local luarocks_admin_nocov_cmd = testing_paths.lua .. " " .. testing_paths.src_dir .. "/bin/luarocks-admin " | ||
| 292 | run.luarocks_admin_nocov = make_command_function(execute_bool, luarocks_admin_nocov_cmd, false) | ||
| 293 | |||
| 294 | return run | ||
| 295 | end | 291 | end |
| 296 | 292 | ||
| 297 | --- Build environment for testing | 293 | --- Build environment for testing |
| @@ -307,14 +303,13 @@ local function build_environment(env_rocks, testing_paths, env_variables) | |||
| 307 | lfs.mkdir(testing_paths.testing_tree) | 303 | lfs.mkdir(testing_paths.testing_tree) |
| 308 | lfs.mkdir(testing_paths.testing_sys_tree) | 304 | lfs.mkdir(testing_paths.testing_sys_tree) |
| 309 | 305 | ||
| 310 | local run = run_luarocks(testing_paths, env_variables) | 306 | test_env.run.luarocks_admin_nocov("make_manifest " .. testing_paths.testing_server) |
| 311 | run.luarocks_admin_nocov("make_manifest " .. testing_paths.testing_server) | 307 | test_env.run.luarocks_admin_nocov("make_manifest " .. testing_paths.testing_cache) |
| 312 | run.luarocks_admin_nocov("make_manifest " .. testing_paths.testing_cache) | ||
| 313 | 308 | ||
| 314 | for _,package in ipairs(env_rocks) do | 309 | for _,package in ipairs(env_rocks) do |
| 315 | if not run.luarocks_nocov("install --only-server=" .. testing_paths.testing_cache .. " --tree=" .. testing_paths.testing_sys_tree .. " " .. package, env_variables) then | 310 | if not test_env.run.luarocks_nocov("install --only-server=" .. testing_paths.testing_cache .. " --tree=" .. testing_paths.testing_sys_tree .. " " .. package, env_variables) then |
| 316 | run.luarocks_nocov("build --tree=" .. testing_paths.testing_sys_tree .. " " .. package, env_variables) | 311 | test_env.run.luarocks_nocov("build --tree=" .. testing_paths.testing_sys_tree .. " " .. package, env_variables) |
| 317 | run.luarocks_nocov("pack --tree=" .. testing_paths.testing_sys_tree .. " " .. package .. "; mv " .. package .. "-*.rock " .. testing_paths.testing_cache, env_variables) | 312 | test_env.run.luarocks_nocov("pack --tree=" .. testing_paths.testing_sys_tree .. " " .. package .. "; mv " .. package .. "-*.rock " .. testing_paths.testing_cache, env_variables) |
| 318 | end | 313 | end |
| 319 | end | 314 | end |
| 320 | 315 | ||
| @@ -394,12 +389,9 @@ function test_env.unload_luarocks() | |||
| 394 | end | 389 | end |
| 395 | 390 | ||
| 396 | --- Function for initially setup of environment, variables, md5sums for spec files | 391 | --- Function for initially setup of environment, variables, md5sums for spec files |
| 397 | function test_env.setup_specs(extra_rocks, luaversion_full) | 392 | function test_env.setup_specs(extra_rocks) |
| 398 | -- if global variable about successful creation of testing environment doesn't exists, build environment | 393 | -- if global variable about successful creation of testing environment doesn't exists, build environment |
| 399 | if not test_env.setup_done then | 394 | if not test_env.setup_done then |
| 400 | test_env.set_lua_version() | ||
| 401 | test_env.set_args() | ||
| 402 | |||
| 403 | if test_env.TRAVIS then | 395 | if test_env.TRAVIS then |
| 404 | if not os.rename(os.getenv("HOME") .. "/.ssh/id_rsa.pub", os.getenv("HOME") .. "/.ssh/id_rsa.pub") then | 396 | if not os.rename(os.getenv("HOME") .. "/.ssh/id_rsa.pub", os.getenv("HOME") .. "/.ssh/id_rsa.pub") then |
| 405 | execute_bool("ssh-keygen -t rsa -P \"\" -f ~/.ssh/id_rsa") | 397 | execute_bool("ssh-keygen -t rsa -P \"\" -f ~/.ssh/id_rsa") |
| @@ -409,16 +401,9 @@ function test_env.setup_specs(extra_rocks, luaversion_full) | |||
| 409 | end | 401 | end |
| 410 | end | 402 | end |
| 411 | 403 | ||
| 412 | luaversion_full = luaversion_full or test_env.LUA_V or test_env.LUAJIT_V | ||
| 413 | |||
| 414 | test_env.main() | 404 | test_env.main() |
| 415 | |||
| 416 | -- Set paths, env_vars and functions for specs | ||
| 417 | test_env.testing_paths = create_paths(luaversion_full) | ||
| 418 | test_env.env_variables = create_env(test_env.testing_paths) | ||
| 419 | package.path = test_env.env_variables.LUA_PATH | 405 | package.path = test_env.env_variables.LUA_PATH |
| 420 | 406 | ||
| 421 | test_env.run = run_luarocks(test_env.testing_paths, test_env.env_variables) | ||
| 422 | test_env.platform = execute_output(test_env.testing_paths.lua .. " -e 'print(require(\"luarocks.cfg\").arch)'", false, test_env.env_variables) | 407 | test_env.platform = execute_output(test_env.testing_paths.lua .. " -e 'print(require(\"luarocks.cfg\").arch)'", false, test_env.env_variables) |
| 423 | test_env.md5sums = create_md5sums(test_env.testing_paths) | 408 | test_env.md5sums = create_md5sums(test_env.testing_paths) |
| 424 | test_env.setup_done = true | 409 | test_env.setup_done = true |
| @@ -427,8 +412,7 @@ function test_env.setup_specs(extra_rocks, luaversion_full) | |||
| 427 | if extra_rocks then | 412 | if extra_rocks then |
| 428 | local make_manifest = download_rocks(extra_rocks, test_env.testing_paths.testing_server) | 413 | local make_manifest = download_rocks(extra_rocks, test_env.testing_paths.testing_server) |
| 429 | if make_manifest then | 414 | if make_manifest then |
| 430 | local run = run_luarocks(test_env.testing_paths, test_env.env_variables) | 415 | test_env.run.luarocks_admin_nocov("make_manifest " .. test_env.testing_paths.testing_server) |
| 431 | run.luarocks_admin_nocov("make_manifest " .. test_env.testing_paths.testing_server) | ||
| 432 | end | 416 | end |
| 433 | end | 417 | end |
| 434 | 418 | ||
| @@ -602,4 +586,10 @@ upload_servers = { | |||
| 602 | print("----------------") | 586 | print("----------------") |
| 603 | end | 587 | end |
| 604 | 588 | ||
| 589 | test_env.set_lua_version() | ||
| 590 | test_env.set_args() | ||
| 591 | test_env.testing_paths = create_paths(test_env.LUA_V or test_env.LUAJIT_V) | ||
| 592 | test_env.env_variables = create_env(test_env.testing_paths) | ||
| 593 | test_env.run = make_run_functions() | ||
| 594 | |||
| 605 | return test_env | 595 | return test_env |
