From 6e7e522ffe3204243306cba8d128a7ec21f591f9 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 4 Jun 2018 17:25:39 -0300 Subject: build: make "builtin" the default build.type --- spec/build_spec.lua | 27 +++++++++++++++++++++++++++ spec/util/test_env.lua | 21 +++++++++++++-------- 2 files changed, 40 insertions(+), 8 deletions(-) (limited to 'spec') 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() end) end) + describe("rockspec format 3.0 #rs3", function() + it("defaults to build.type == 'builtin'", function() + local rockspec = "a_rock-1.0-1.rockspec" + test_env.write_file(rockspec, [[ + rockspec_format = "3.0" + package = "a_rock" + version = "1.0-1" + source = { + url = "file://]] .. testing_paths.fixtures_dir .. [[/a_rock.lua" + } + description = { + summary = "An example rockspec", + } + dependencies = { + "lua >= 5.1" + } + build = { + modules = { + build = "a_rock.lua" + }, + } + ]], finally) + assert.truthy(run.luarocks_bool("build " .. rockspec)) + assert.is.truthy(run.luarocks("show a_rock")) + end) + end) + describe("#mock external dependencies", function() setup(function() 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) end --- Create a file containing a string. --- @param path string: path to file. +-- @param pathname string: path to file. -- @param str string: content of the file. -local function write_file(path, str) - local file = assert(io.open(path, "w")) +function test_env.write_file(pathname, str, finally) + local file = assert(io.open(pathname, "w")) file:write(str) file:close() + if finally then + finally(function() + os.remove(pathname) + end) + end end --- Create md5sum of directory structure recursively, based on filename and size @@ -666,8 +671,8 @@ local function create_configs() testing_cache = test_env.testing_paths.testing_cache }) - write_file(test_env.testing_paths.testrun_dir .. "/testing_config.lua", config_content .. " \nweb_browser = \"true\"") - write_file(test_env.testing_paths.testrun_dir .. "/testing_config_show_downloads.lua", config_content + test_env.write_file(test_env.testing_paths.testrun_dir .. "/testing_config.lua", config_content .. " \nweb_browser = \"true\"") + test_env.write_file(test_env.testing_paths.testrun_dir .. "/testing_config_show_downloads.lua", config_content .. "show_downloads = true \n rocks_servers={\"http://luarocks.org/repositories/rocks\"}") -- testing_config_sftp.lua @@ -691,7 +696,7 @@ local function create_configs() testing_cache = test_env.testing_paths.testing_cache }) - write_file(test_env.testing_paths.testrun_dir .. "/testing_config_sftp.lua", config_content) + test_env.write_file(test_env.testing_paths.testrun_dir .. "/testing_config_sftp.lua", config_content) -- luacov.config config_content = substitute([[ @@ -710,7 +715,7 @@ local function create_configs() testrun_dir = test_env.testing_paths.testrun_dir }) - write_file(test_env.testing_paths.testrun_dir .. "/luacov.config", config_content) + test_env.write_file(test_env.testing_paths.testrun_dir .. "/luacov.config", config_content) config_content = [[ -- Config file of mock LuaRocks.org site for tests @@ -720,7 +725,7 @@ local function create_configs() api_version = "1", } ]] - write_file(test_env.testing_paths.testrun_dir .. "/luarocks_site.lua", config_content) + test_env.write_file(test_env.testing_paths.testrun_dir .. "/luarocks_site.lua", config_content) end --- Remove testing directories. -- cgit v1.2.3-55-g6feb