diff options
author | George Roman <30772943+georgeroman@users.noreply.github.com> | 2018-06-05 17:10:02 +0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-06-05 11:10:02 -0300 |
commit | db066d68e0355b98106a6e1f5f2573047363f851 (patch) | |
tree | f6c1f80e5ab291bc8baf2ddf11ff0d57474bfbf4 /spec/init_spec.lua | |
parent | 5b2540eb0d759d538c1d3fcd802b7d6961b337a9 (diff) | |
download | luarocks-db066d68e0355b98106a6e1f5f2573047363f851.tar.gz luarocks-db066d68e0355b98106a6e1f5f2573047363f851.tar.bz2 luarocks-db066d68e0355b98106a6e1f5f2573047363f851.zip |
Tests: luarocks init (#811)
Diffstat (limited to 'spec/init_spec.lua')
-rw-r--r-- | spec/init_spec.lua | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/spec/init_spec.lua b/spec/init_spec.lua new file mode 100644 index 00000000..2d28bfe7 --- /dev/null +++ b/spec/init_spec.lua | |||
@@ -0,0 +1,83 @@ | |||
1 | local test_env = require("spec.util.test_env") | ||
2 | local run = test_env.run | ||
3 | local testing_paths = test_env.testing_paths | ||
4 | local get_tmp_path = test_env.get_tmp_path | ||
5 | local copy_dir = test_env.copy_dir | ||
6 | local is_win = test_env.TEST_TARGET_OS == "windows" | ||
7 | |||
8 | test_env.unload_luarocks() | ||
9 | |||
10 | describe("Luarocks init test #integration", function() | ||
11 | local tmpdir | ||
12 | |||
13 | after_each(function() | ||
14 | if tmpdir then | ||
15 | lfs.rmdir(tmpdir) | ||
16 | tmpdir = nil | ||
17 | end | ||
18 | end) | ||
19 | |||
20 | it("LuaRocks init with no arguments", function() | ||
21 | tmpdir = get_tmp_path() | ||
22 | lfs.mkdir(tmpdir) | ||
23 | local myproject = tmpdir .. "/myproject" | ||
24 | lfs.mkdir(myproject) | ||
25 | local olddir = lfs.currentdir() | ||
26 | lfs.chdir(myproject) | ||
27 | |||
28 | assert(run.luarocks("init")) | ||
29 | if is_win then | ||
30 | assert.truthy(lfs.attributes(myproject .. "/lua.bat")) | ||
31 | assert.truthy(lfs.attributes(myproject .. "/luarocks.bat")) | ||
32 | else | ||
33 | assert.truthy(lfs.attributes(myproject .. "/lua")) | ||
34 | assert.truthy(lfs.attributes(myproject .. "/luarocks")) | ||
35 | end | ||
36 | assert.truthy(lfs.attributes(myproject .. "/lua_modules")) | ||
37 | assert.truthy(lfs.attributes(myproject .. "/.luarocks")) | ||
38 | assert.truthy(lfs.attributes(myproject .. "/.luarocks/config-" .. test_env.lua_version .. ".lua")) | ||
39 | assert.truthy(lfs.attributes(myproject .. "/.gitignore")) | ||
40 | assert.truthy(lfs.attributes(myproject .. "/myproject-dev-1.rockspec")) | ||
41 | |||
42 | lfs.chdir(olddir) | ||
43 | end) | ||
44 | |||
45 | it("LuaRocks init with given arguments", function() | ||
46 | tmpdir = get_tmp_path() | ||
47 | lfs.mkdir(tmpdir) | ||
48 | local myproject = tmpdir .. "/myproject" | ||
49 | lfs.mkdir(myproject) | ||
50 | local olddir = lfs.currentdir() | ||
51 | lfs.chdir(myproject) | ||
52 | |||
53 | assert(run.luarocks("init customname 1.0")) | ||
54 | assert.truthy(lfs.attributes(myproject .. "/customname-1.0-1.rockspec")) | ||
55 | |||
56 | lfs.chdir(olddir) | ||
57 | end) | ||
58 | |||
59 | it("LuaRocks init in a git repo", function() | ||
60 | tmpdir = get_tmp_path() | ||
61 | lfs.mkdir(tmpdir) | ||
62 | local olddir = lfs.currentdir() | ||
63 | lfs.chdir(tmpdir) | ||
64 | local myproject = tmpdir .. "/myproject" | ||
65 | copy_dir(testing_paths.fixtures_dir .. "/git_repo", myproject) | ||
66 | lfs.chdir(myproject) | ||
67 | |||
68 | assert(run.luarocks("init")) | ||
69 | local fd = assert(io.open(myproject .. "/myproject-dev-1.rockspec", "r")) | ||
70 | local content = assert(fd:read("*a")) | ||
71 | assert.truthy(content:find("summary = \"Test repo\"")) | ||
72 | assert.truthy(content:find("detailed = .+Test repo.+")) | ||
73 | assert.truthy(content:find("license = \"MIT\"")) | ||
74 | |||
75 | fd = assert(io.open(myproject .. "/.gitignore", "r")) | ||
76 | content = assert(fd:read("*a")) | ||
77 | assert.truthy(content:find("/foo")) | ||
78 | assert.truthy(content:find("/lua")) | ||
79 | assert.truthy(content:find("/lua_modules")) | ||
80 | |||
81 | lfs.chdir(olddir) | ||
82 | end) | ||
83 | end) | ||