diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | spec/build_spec.lua | 27 | ||||
-rw-r--r-- | spec/util/test_env.lua | 21 | ||||
-rw-r--r-- | src/luarocks/build.lua | 10 |
4 files changed, 49 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cbf3d35..798f3c5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md | |||
@@ -48,6 +48,7 @@ Rockspec 3.0 | |||
48 | 48 | ||
49 | These features are only enabled if `rockspec_format = "3.0"` is set in the rockspec: | 49 | These features are only enabled if `rockspec_format = "3.0"` is set in the rockspec: |
50 | 50 | ||
51 | * Build type `builtin` is the default if `build.type` is not specified. | ||
51 | * New table `build_dependencies`: dependencies used only for running `luarocks build` | 52 | * New table `build_dependencies`: dependencies used only for running `luarocks build` |
52 | but not when installing binary rocks. | 53 | but not when installing binary rocks. |
53 | * New table `test_dependencies`: dependencies used only for running `luarocks test` | 54 | * New table `test_dependencies`: dependencies used only for running `luarocks test` |
diff --git a/spec/build_spec.lua b/spec/build_spec.lua index f042cbb9..b703478e 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua | |||
@@ -244,6 +244,33 @@ describe("LuaRocks build tests #integration", function() | |||
244 | end) | 244 | end) |
245 | end) | 245 | end) |
246 | 246 | ||
247 | describe("rockspec format 3.0 #rs3", function() | ||
248 | it("defaults to build.type == 'builtin'", function() | ||
249 | local rockspec = "a_rock-1.0-1.rockspec" | ||
250 | test_env.write_file(rockspec, [[ | ||
251 | rockspec_format = "3.0" | ||
252 | package = "a_rock" | ||
253 | version = "1.0-1" | ||
254 | source = { | ||
255 | url = "file://]] .. testing_paths.fixtures_dir .. [[/a_rock.lua" | ||
256 | } | ||
257 | description = { | ||
258 | summary = "An example rockspec", | ||
259 | } | ||
260 | dependencies = { | ||
261 | "lua >= 5.1" | ||
262 | } | ||
263 | build = { | ||
264 | modules = { | ||
265 | build = "a_rock.lua" | ||
266 | }, | ||
267 | } | ||
268 | ]], finally) | ||
269 | assert.truthy(run.luarocks_bool("build " .. rockspec)) | ||
270 | assert.is.truthy(run.luarocks("show a_rock")) | ||
271 | end) | ||
272 | end) | ||
273 | |||
247 | describe("#mock external dependencies", function() | 274 | describe("#mock external dependencies", function() |
248 | setup(function() | 275 | setup(function() |
249 | test_env.mock_server_init() | 276 | test_env.mock_server_init() |
diff --git a/spec/util/test_env.lua b/spec/util/test_env.lua index 08d5c850..0c140be7 100644 --- a/spec/util/test_env.lua +++ b/spec/util/test_env.lua | |||
@@ -344,12 +344,17 @@ local function download_rocks(urls, save_path) | |||
344 | end | 344 | end |
345 | 345 | ||
346 | --- Create a file containing a string. | 346 | --- Create a file containing a string. |
347 | -- @param path string: path to file. | 347 | -- @param pathname string: path to file. |
348 | -- @param str string: content of the file. | 348 | -- @param str string: content of the file. |
349 | local function write_file(path, str) | 349 | function test_env.write_file(pathname, str, finally) |
350 | local file = assert(io.open(path, "w")) | 350 | local file = assert(io.open(pathname, "w")) |
351 | file:write(str) | 351 | file:write(str) |
352 | file:close() | 352 | file:close() |
353 | if finally then | ||
354 | finally(function() | ||
355 | os.remove(pathname) | ||
356 | end) | ||
357 | end | ||
353 | end | 358 | end |
354 | 359 | ||
355 | --- Create md5sum of directory structure recursively, based on filename and size | 360 | --- Create md5sum of directory structure recursively, based on filename and size |
@@ -666,8 +671,8 @@ local function create_configs() | |||
666 | testing_cache = test_env.testing_paths.testing_cache | 671 | testing_cache = test_env.testing_paths.testing_cache |
667 | }) | 672 | }) |
668 | 673 | ||
669 | write_file(test_env.testing_paths.testrun_dir .. "/testing_config.lua", config_content .. " \nweb_browser = \"true\"") | 674 | test_env.write_file(test_env.testing_paths.testrun_dir .. "/testing_config.lua", config_content .. " \nweb_browser = \"true\"") |
670 | write_file(test_env.testing_paths.testrun_dir .. "/testing_config_show_downloads.lua", config_content | 675 | test_env.write_file(test_env.testing_paths.testrun_dir .. "/testing_config_show_downloads.lua", config_content |
671 | .. "show_downloads = true \n rocks_servers={\"http://luarocks.org/repositories/rocks\"}") | 676 | .. "show_downloads = true \n rocks_servers={\"http://luarocks.org/repositories/rocks\"}") |
672 | 677 | ||
673 | -- testing_config_sftp.lua | 678 | -- testing_config_sftp.lua |
@@ -691,7 +696,7 @@ local function create_configs() | |||
691 | testing_cache = test_env.testing_paths.testing_cache | 696 | testing_cache = test_env.testing_paths.testing_cache |
692 | }) | 697 | }) |
693 | 698 | ||
694 | write_file(test_env.testing_paths.testrun_dir .. "/testing_config_sftp.lua", config_content) | 699 | test_env.write_file(test_env.testing_paths.testrun_dir .. "/testing_config_sftp.lua", config_content) |
695 | 700 | ||
696 | -- luacov.config | 701 | -- luacov.config |
697 | config_content = substitute([[ | 702 | config_content = substitute([[ |
@@ -710,7 +715,7 @@ local function create_configs() | |||
710 | testrun_dir = test_env.testing_paths.testrun_dir | 715 | testrun_dir = test_env.testing_paths.testrun_dir |
711 | }) | 716 | }) |
712 | 717 | ||
713 | write_file(test_env.testing_paths.testrun_dir .. "/luacov.config", config_content) | 718 | test_env.write_file(test_env.testing_paths.testrun_dir .. "/luacov.config", config_content) |
714 | 719 | ||
715 | config_content = [[ | 720 | config_content = [[ |
716 | -- Config file of mock LuaRocks.org site for tests | 721 | -- Config file of mock LuaRocks.org site for tests |
@@ -720,7 +725,7 @@ local function create_configs() | |||
720 | api_version = "1", | 725 | api_version = "1", |
721 | } | 726 | } |
722 | ]] | 727 | ]] |
723 | write_file(test_env.testing_paths.testrun_dir .. "/luarocks_site.lua", config_content) | 728 | test_env.write_file(test_env.testing_paths.testrun_dir .. "/luarocks_site.lua", config_content) |
724 | end | 729 | end |
725 | 730 | ||
726 | --- Remove testing directories. | 731 | --- Remove testing directories. |
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index fe004fb5..25e73b0d 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
@@ -170,8 +170,14 @@ function build.build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_m | |||
170 | return nil, err, errcode | 170 | return nil, err, errcode |
171 | elseif not rockspec.build then | 171 | elseif not rockspec.build then |
172 | return nil, "Rockspec error: build table not specified" | 172 | return nil, "Rockspec error: build table not specified" |
173 | elseif not rockspec.build.type then | 173 | end |
174 | return nil, "Rockspec error: build type not specified" | 174 | |
175 | if not rockspec.build.type then | ||
176 | if rockspec:format_is_at_least("3.0") then | ||
177 | rockspec.build.type = "builtin" | ||
178 | else | ||
179 | return nil, "Rockspec error: build type not specified" | ||
180 | end | ||
175 | end | 181 | end |
176 | 182 | ||
177 | if not build_only_deps then | 183 | if not build_only_deps then |