diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2018-04-23 11:06:51 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-05-07 19:27:37 -0300 |
| commit | 6c6b39a41a446b05bb2263e274f916946f0787f4 (patch) | |
| tree | 7d9c6c543dec19bcf41c09e400c97f860c5592c7 | |
| parent | be744c86fe7c38dbe00ea7ac59451dcc3fded4fb (diff) | |
| download | luarocks-6c6b39a41a446b05bb2263e274f916946f0787f4.tar.gz luarocks-6c6b39a41a446b05bb2263e274f916946f0787f4.tar.bz2 luarocks-6c6b39a41a446b05bb2263e274f916946f0787f4.zip | |
Tests: add test for `luarocks test`
| -rw-r--r-- | spec/test_spec.lua | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/test_spec.lua b/spec/test_spec.lua new file mode 100644 index 00000000..1c45bc6e --- /dev/null +++ b/spec/test_spec.lua | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | local test_env = require("spec.util.test_env") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | local run = test_env.run | ||
| 4 | local testing_paths = test_env.testing_paths | ||
| 5 | |||
| 6 | test_env.unload_luarocks() | ||
| 7 | |||
| 8 | local extra_rocks = { | ||
| 9 | "/busted-2.0.rc12-1.rockspec", | ||
| 10 | "/lua_cliargs-3.0-1.src.rock", | ||
| 11 | "/luafilesystem-1.7.0-2.src.rock", | ||
| 12 | "/luasystem-0.2.1-0.src.rock", | ||
| 13 | "/dkjson-2.5-2.src.rock", | ||
| 14 | "/say-1.3-1.rockspec", | ||
| 15 | "/luassert-1.7.9-0.rockspec", | ||
| 16 | "/lua-term-0.7-1.rockspec", | ||
| 17 | "/penlight-1.5.4-1.rockspec", | ||
| 18 | "/mediator_lua-1.1.2-0.rockspec", | ||
| 19 | } | ||
| 20 | |||
| 21 | describe("luarocks test #blackbox #b_test", function() | ||
| 22 | |||
| 23 | before_each(function() | ||
| 24 | test_env.setup_specs(extra_rocks) | ||
| 25 | end) | ||
| 26 | |||
| 27 | it("fails with no flags/arguments", function() | ||
| 28 | finally(function() | ||
| 29 | lfs.chdir(testing_paths.testrun_dir) | ||
| 30 | test_env.remove_dir("empty") | ||
| 31 | end) | ||
| 32 | assert(lfs.mkdir("empty")) | ||
| 33 | assert(lfs.chdir("empty")) | ||
| 34 | assert.is_false(run.luarocks_bool("test")) | ||
| 35 | end) | ||
| 36 | |||
| 37 | describe("busted backend", function() | ||
| 38 | it("with rockspec, installing busted", function() | ||
| 39 | finally(function() | ||
| 40 | -- delete downloaded and unpacked files | ||
| 41 | lfs.chdir(testing_paths.testrun_dir) | ||
| 42 | test_env.remove_dir("luassert-1.7.9-0") | ||
| 43 | os.remove("luassert-1.7.9-0.rockspec") | ||
| 44 | end) | ||
| 45 | |||
| 46 | -- make luassert | ||
| 47 | assert.is_true(run.luarocks_bool("download --rockspec luassert 1.7.9-0")) | ||
| 48 | assert.is_true(run.luarocks_bool("unpack luassert-1.7.9-0.rockspec")) | ||
| 49 | lfs.chdir("luassert-1.7.9-0/luassert-1.7.9/") | ||
| 50 | assert.is_true(run.luarocks_bool("make")) | ||
| 51 | local output = run.luarocks("test --test-type=busted luassert-1.7.9-0.rockspec") | ||
| 52 | -- Assert that busted ran, whether successfully or not | ||
| 53 | assert.match("%d+ success.* / %d+ failure.* / %d+ error.* / %d+ pending", output) | ||
| 54 | end) | ||
| 55 | end) | ||
| 56 | end) | ||
