diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/build_spec.lua | 117 | ||||
-rw-r--r-- | spec/deps_spec.lua | 143 |
2 files changed, 143 insertions, 117 deletions
diff --git a/spec/build_spec.lua b/spec/build_spec.lua index 653f2160..3b33a1aa 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua | |||
@@ -598,123 +598,6 @@ describe("LuaRocks build #unit", function() | |||
598 | end, finally) | 598 | end, finally) |
599 | end) | 599 | end) |
600 | 600 | ||
601 | describe("builtin.autodetect_external_dependencies", function() | ||
602 | it("returns false if the given build table has no external dependencies", function() | ||
603 | local build_table = { | ||
604 | type = "builtin" | ||
605 | } | ||
606 | |||
607 | assert.falsy(build_builtin.autodetect_external_dependencies(build_table)) | ||
608 | end) | ||
609 | |||
610 | it("returns a table of the external dependencies found in the given build table", function() | ||
611 | local build_table = { | ||
612 | type = "builtin", | ||
613 | modules = { | ||
614 | module1 = { | ||
615 | libraries = { "foo1", "foo2" }, | ||
616 | }, | ||
617 | module2 = { | ||
618 | libraries = "foo3" | ||
619 | }, | ||
620 | } | ||
621 | } | ||
622 | |||
623 | local extdeps = build_builtin.autodetect_external_dependencies(build_table) | ||
624 | assert.same(extdeps["FOO1"], { library = "foo1" }) | ||
625 | assert.same(extdeps["FOO2"], { library = "foo2" }) | ||
626 | assert.same(extdeps["FOO3"], { library = "foo3" }) | ||
627 | end) | ||
628 | |||
629 | it("adds proper include and library dirs to the given build table", function() | ||
630 | local build_table | ||
631 | |||
632 | build_table = { | ||
633 | type = "builtin", | ||
634 | modules = { | ||
635 | module1 = { | ||
636 | libraries = "foo" | ||
637 | } | ||
638 | } | ||
639 | } | ||
640 | build_builtin.autodetect_external_dependencies(build_table) | ||
641 | assert.same(build_table, { | ||
642 | type = "builtin", | ||
643 | modules = { | ||
644 | module1 = { | ||
645 | libraries = "foo", | ||
646 | incdirs = { "$(FOO_INCDIR)" }, | ||
647 | libdirs = { "$(FOO_LIBDIR)" } | ||
648 | } | ||
649 | } | ||
650 | }) | ||
651 | |||
652 | build_table = { | ||
653 | type = "builtin", | ||
654 | modules = { | ||
655 | module1 = { | ||
656 | libraries = "foo", | ||
657 | incdirs = { "INCDIRS" } | ||
658 | } | ||
659 | } | ||
660 | } | ||
661 | build_builtin.autodetect_external_dependencies(build_table) | ||
662 | assert.same(build_table, { | ||
663 | type = "builtin", | ||
664 | modules = { | ||
665 | module1 = { | ||
666 | libraries = "foo", | ||
667 | incdirs = { "INCDIRS" }, | ||
668 | libdirs = { "$(FOO_LIBDIR)" } | ||
669 | } | ||
670 | } | ||
671 | }) | ||
672 | |||
673 | build_table = { | ||
674 | type = "builtin", | ||
675 | modules = { | ||
676 | module1 = { | ||
677 | libraries = "foo", | ||
678 | libdirs = { "LIBDIRS" } | ||
679 | } | ||
680 | } | ||
681 | } | ||
682 | build_builtin.autodetect_external_dependencies(build_table) | ||
683 | assert.same(build_table, { | ||
684 | type = "builtin", | ||
685 | modules = { | ||
686 | module1 = { | ||
687 | libraries = "foo", | ||
688 | incdirs = { "$(FOO_INCDIR)" }, | ||
689 | libdirs = { "LIBDIRS" } | ||
690 | } | ||
691 | } | ||
692 | }) | ||
693 | |||
694 | build_table = { | ||
695 | type = "builtin", | ||
696 | modules = { | ||
697 | module1 = { | ||
698 | libraries = "foo", | ||
699 | incdirs = { "INCDIRS" }, | ||
700 | libdirs = { "LIBDIRS" } | ||
701 | } | ||
702 | } | ||
703 | } | ||
704 | build_builtin.autodetect_external_dependencies(build_table) | ||
705 | assert.same(build_table, { | ||
706 | type = "builtin", | ||
707 | modules = { | ||
708 | module1 = { | ||
709 | libraries = "foo", | ||
710 | incdirs = { "INCDIRS" }, | ||
711 | libdirs = { "LIBDIRS" } | ||
712 | } | ||
713 | } | ||
714 | }) | ||
715 | end) | ||
716 | end) | ||
717 | |||
718 | describe("builtin.autodetect_modules", function() | 601 | describe("builtin.autodetect_modules", function() |
719 | local tmpdir | 602 | local tmpdir |
720 | local olddir | 603 | local olddir |
diff --git a/spec/deps_spec.lua b/spec/deps_spec.lua index b0064298..32f68f51 100644 --- a/spec/deps_spec.lua +++ b/spec/deps_spec.lua | |||
@@ -116,3 +116,146 @@ describe("LuaRocks deps-mode #integration", function() | |||
116 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec")) | 116 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lxsh/${LXSH}/lxsh-${LXSH}.rockspec")) |
117 | end) | 117 | end) |
118 | end) | 118 | end) |
119 | |||
120 | test_env.unload_luarocks() | ||
121 | test_env.setup_specs() | ||
122 | local cfg = require("luarocks.core.cfg") | ||
123 | local deps = require("luarocks.deps") | ||
124 | local fs = require("luarocks.fs") | ||
125 | |||
126 | describe("LuaRocks deps #unit", function() | ||
127 | local runner | ||
128 | |||
129 | lazy_setup(function() | ||
130 | runner = require("luacov.runner") | ||
131 | runner.init(testing_paths.testrun_dir .. "/luacov.config") | ||
132 | runner.tick = true | ||
133 | cfg.init() | ||
134 | fs.init() | ||
135 | deps.check_lua_incdir(cfg.variables) | ||
136 | deps.check_lua_libdir(cfg.variables) | ||
137 | end) | ||
138 | |||
139 | lazy_teardown(function() | ||
140 | runner.shutdown() | ||
141 | end) | ||
142 | |||
143 | describe("deps", function() | ||
144 | describe("deps.autodetect_external_dependencies", function() | ||
145 | it("returns false if the given build table has no external dependencies", function() | ||
146 | local build_table = { | ||
147 | type = "builtin" | ||
148 | } | ||
149 | |||
150 | assert.falsy(deps.autodetect_external_dependencies(build_table)) | ||
151 | end) | ||
152 | |||
153 | it("returns a table of the external dependencies found in the given build table", function() | ||
154 | local build_table = { | ||
155 | type = "builtin", | ||
156 | modules = { | ||
157 | module1 = { | ||
158 | libraries = { "foo1", "foo2" }, | ||
159 | }, | ||
160 | module2 = { | ||
161 | libraries = "foo3" | ||
162 | }, | ||
163 | } | ||
164 | } | ||
165 | |||
166 | local extdeps = deps.autodetect_external_dependencies(build_table) | ||
167 | assert.same(extdeps["FOO1"], { library = "foo1" }) | ||
168 | assert.same(extdeps["FOO2"], { library = "foo2" }) | ||
169 | assert.same(extdeps["FOO3"], { library = "foo3" }) | ||
170 | end) | ||
171 | |||
172 | it("adds proper include and library dirs to the given build table", function() | ||
173 | local build_table | ||
174 | |||
175 | build_table = { | ||
176 | type = "builtin", | ||
177 | modules = { | ||
178 | module1 = { | ||
179 | libraries = "foo" | ||
180 | } | ||
181 | } | ||
182 | } | ||
183 | deps.autodetect_external_dependencies(build_table) | ||
184 | assert.same(build_table, { | ||
185 | type = "builtin", | ||
186 | modules = { | ||
187 | module1 = { | ||
188 | libraries = "foo", | ||
189 | incdirs = { "$(FOO_INCDIR)" }, | ||
190 | libdirs = { "$(FOO_LIBDIR)" } | ||
191 | } | ||
192 | } | ||
193 | }) | ||
194 | |||
195 | build_table = { | ||
196 | type = "builtin", | ||
197 | modules = { | ||
198 | module1 = { | ||
199 | libraries = "foo", | ||
200 | incdirs = { "INCDIRS" } | ||
201 | } | ||
202 | } | ||
203 | } | ||
204 | deps.autodetect_external_dependencies(build_table) | ||
205 | assert.same(build_table, { | ||
206 | type = "builtin", | ||
207 | modules = { | ||
208 | module1 = { | ||
209 | libraries = "foo", | ||
210 | incdirs = { "INCDIRS" }, | ||
211 | libdirs = { "$(FOO_LIBDIR)" } | ||
212 | } | ||
213 | } | ||
214 | }) | ||
215 | |||
216 | build_table = { | ||
217 | type = "builtin", | ||
218 | modules = { | ||
219 | module1 = { | ||
220 | libraries = "foo", | ||
221 | libdirs = { "LIBDIRS" } | ||
222 | } | ||
223 | } | ||
224 | } | ||
225 | deps.autodetect_external_dependencies(build_table) | ||
226 | assert.same(build_table, { | ||
227 | type = "builtin", | ||
228 | modules = { | ||
229 | module1 = { | ||
230 | libraries = "foo", | ||
231 | incdirs = { "$(FOO_INCDIR)" }, | ||
232 | libdirs = { "LIBDIRS" } | ||
233 | } | ||
234 | } | ||
235 | }) | ||
236 | |||
237 | build_table = { | ||
238 | type = "builtin", | ||
239 | modules = { | ||
240 | module1 = { | ||
241 | libraries = "foo", | ||
242 | incdirs = { "INCDIRS" }, | ||
243 | libdirs = { "LIBDIRS" } | ||
244 | } | ||
245 | } | ||
246 | } | ||
247 | deps.autodetect_external_dependencies(build_table) | ||
248 | assert.same(build_table, { | ||
249 | type = "builtin", | ||
250 | modules = { | ||
251 | module1 = { | ||
252 | libraries = "foo", | ||
253 | incdirs = { "INCDIRS" }, | ||
254 | libdirs = { "LIBDIRS" } | ||
255 | } | ||
256 | } | ||
257 | }) | ||
258 | end) | ||
259 | end) | ||
260 | end) | ||
261 | end) | ||