aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2015-03-09 14:35:14 -0300
committerHisham Muhammad <hisham@gobolinux.org>2015-03-09 14:35:14 -0300
commit0f9d259ab3a59ae0f3ab3a2992dd371a368da5aa (patch)
treea251978814d083d3ef55ede0787020c3735ce042
parent9a9caf8fd6edfb82284b7ec6edb2f460400b614c (diff)
downloadluarocks-0f9d259ab3a59ae0f3ab3a2992dd371a368da5aa.tar.gz
luarocks-0f9d259ab3a59ae0f3ab3a2992dd371a368da5aa.tar.bz2
luarocks-0f9d259ab3a59ae0f3ab3a2992dd371a368da5aa.zip
Test success of patching in `unpack`. Closes #316.
Includes test cases for the test suite! Yay!
-rw-r--r--src/luarocks/unpack.lua6
-rw-r--r--test/testfiles/invalid_patch-0.1-1.rockspec29
-rwxr-xr-xtest/testing.sh3
3 files changed, 36 insertions, 2 deletions
diff --git a/src/luarocks/unpack.lua b/src/luarocks/unpack.lua
index 9204e265..a889bac5 100644
--- a/src/luarocks/unpack.lua
+++ b/src/luarocks/unpack.lua
@@ -43,9 +43,10 @@ local function unpack_rockspec(rockspec_file, dir_name)
43 end 43 end
44 ok, err = fs.change_dir(sources_dir) 44 ok, err = fs.change_dir(sources_dir)
45 if not ok then return nil, err end 45 if not ok then return nil, err end
46 build.apply_patches(rockspec) 46 ok, err = build.apply_patches(rockspec)
47 fs.pop_dir() 47 fs.pop_dir()
48 fs.pop_dir() 48 fs.pop_dir()
49 if not ok then return nil, err end
49 return rockspec 50 return rockspec
50end 51end
51 52
@@ -79,8 +80,9 @@ local function unpack_rock(rock_file, dir_name, kind)
79 end 80 end
80 ok, err = fs.change_dir(rockspec.source.dir) 81 ok, err = fs.change_dir(rockspec.source.dir)
81 if not ok then return nil, err end 82 if not ok then return nil, err end
82 build.apply_patches(rockspec) 83 ok, err = build.apply_patches(rockspec)
83 fs.pop_dir() 84 fs.pop_dir()
85 if not ok then return nil, err end
84 end 86 end
85 end 87 end
86 return rockspec 88 return rockspec
diff --git a/test/testfiles/invalid_patch-0.1-1.rockspec b/test/testfiles/invalid_patch-0.1-1.rockspec
new file mode 100644
index 00000000..c2ecd160
--- /dev/null
+++ b/test/testfiles/invalid_patch-0.1-1.rockspec
@@ -0,0 +1,29 @@
1package = "invalid_patch"
2version = "0.1-1"
3source = {
4 -- any valid URL
5 url = "https://raw.github.com/keplerproject/luarocks/master/src/luarocks/build.lua"
6}
7description = {
8 summary = "A rockspec with an invalid patch",
9}
10dependencies = {
11 "lua >= 5.1"
12}
13build = {
14 type = "builtin",
15 modules = {
16 build = "build.lua"
17 },
18 patches = {
19 ["I_am_an_invalid_patch.patch"] =
20[[
21diff -Naur luadoc-3.0.1/src/luadoc/doclet/html.lua luadoc-3.0.1-new/src/luadoc/doclet/html.lua
22--- luadoc-3.0.1/src/luadoc/doclet/html.lua2007-12-21 15:50:48.000000000 -0200
23+++ luadoc-3.0.1-new/src/luadoc/doclet/html.lua2008-02-28 01:59:53.000000000 -0300
24@@ -18,6 +18,7 @@
25- gabba gabba gabba
26+ gobo gobo gobo
27]]
28 }
29}
diff --git a/test/testing.sh b/test/testing.sh
index 5018abe0..b3c85191 100755
--- a/test/testing.sh
+++ b/test/testing.sh
@@ -357,6 +357,7 @@ test_build_nohttps() { need_luasocket; $luarocks download --rockspec validate-ar
357test_build_https() { need_luasocket; $luarocks download --rockspec validate-args ${verrev_validate_args} && $luarocks install $luasec && $luarocks build ./validate-args-${verrev_validate_args}.rockspec && rm ./validate-args-${verrev_validate_args}.rockspec; } 357test_build_https() { need_luasocket; $luarocks download --rockspec validate-args ${verrev_validate_args} && $luarocks install $luasec && $luarocks build ./validate-args-${verrev_validate_args}.rockspec && rm ./validate-args-${verrev_validate_args}.rockspec; }
358test_build_supported_platforms() { $luarocks build lpty; } 358test_build_supported_platforms() { $luarocks build lpty; }
359fail_build_missing_external() { $luarocks build "$testing_dir/testfiles/missing_external-0.1-1.rockspec" INEXISTENT_INCDIR="/invalid/dir"; } 359fail_build_missing_external() { $luarocks build "$testing_dir/testfiles/missing_external-0.1-1.rockspec" INEXISTENT_INCDIR="/invalid/dir"; }
360fail_build_invalidpatch() { need_luasocket; $luarocks build "$testing_dir/testfiles/invalid_patch-0.1-1.rockspec"; }
360 361
361test_build_deps_partial_match() { $luarocks build lmathx; } 362test_build_deps_partial_match() { $luarocks build lmathx; }
362test_build_show_downloads() { export LUAROCKS_CONFIG="$testing_dir/testing_config_show_downloads.lua" && $luarocks build alien; export LUAROCKS_CONFIG="$testing_dir/testing_config.lua"; } 363test_build_show_downloads() { export LUAROCKS_CONFIG="$testing_dir/testing_config_show_downloads.lua" && $luarocks build alien; export LUAROCKS_CONFIG="$testing_dir/testing_config.lua"; }
@@ -370,6 +371,7 @@ fail_help_invalid() { $luarocks help invalid; }
370test_install_binaryrock() { $luarocks build --pack-binary-rock cprint && $luarocks install ./cprint-${verrev_cprint}.${platform}.rock && rm ./cprint-${verrev_cprint}.${platform}.rock; } 371test_install_binaryrock() { $luarocks build --pack-binary-rock cprint && $luarocks install ./cprint-${verrev_cprint}.${platform}.rock && rm ./cprint-${verrev_cprint}.${platform}.rock; }
371test_install_with_bin() { $luarocks install wsapi; } 372test_install_with_bin() { $luarocks install wsapi; }
372fail_install_notazipfile() { $luarocks install "$testing_dir/testfiles/not_a_zipfile-1.0-1.src.rock"; } 373fail_install_notazipfile() { $luarocks install "$testing_dir/testfiles/not_a_zipfile-1.0-1.src.rock"; }
374fail_install_invalidpatch() { need_luasocket; $luarocks install "$testing_dir/testfiles/invalid_patch-0.1-1.rockspec"; }
373 375
374test_lint_ok() { $luarocks download --rockspec validate-args ${verrev_validate_args} && $luarocks lint ./validate-args-${verrev_validate_args}.rockspec && rm ./validate-args-${verrev_validate_args}.rockspec; } 376test_lint_ok() { $luarocks download --rockspec validate-args ${verrev_validate_args} && $luarocks lint ./validate-args-${verrev_validate_args}.rockspec && rm ./validate-args-${verrev_validate_args}.rockspec; }
375fail_lint_type_mismatch_string() { $luarocks lint "$testing_dir/testfiles/type_mismatch_string-1.0-1.rockspec"; } 377fail_lint_type_mismatch_string() { $luarocks lint "$testing_dir/testfiles/type_mismatch_string-1.0-1.rockspec"; }
@@ -416,6 +418,7 @@ test_unpack_download() { rm -rf ./cprint-${verrev_cprint} && $luarocks unpack cp
416test_unpack_src() { rm -rf ./cprint-${verrev_cprint} && $luarocks download --src cprint && $luarocks unpack ./cprint-${verrev_cprint}.src.rock && rm -rf ./cprint-${verrev_cprint}; } 418test_unpack_src() { rm -rf ./cprint-${verrev_cprint} && $luarocks download --src cprint && $luarocks unpack ./cprint-${verrev_cprint}.src.rock && rm -rf ./cprint-${verrev_cprint}; }
417test_unpack_rockspec() { rm -rf ./cprint-${verrev_cprint} && $luarocks download --rockspec cprint && $luarocks unpack ./cprint-${verrev_cprint}.rockspec && rm -rf ./cprint-${verrev_cprint}; } 419test_unpack_rockspec() { rm -rf ./cprint-${verrev_cprint} && $luarocks download --rockspec cprint && $luarocks unpack ./cprint-${verrev_cprint}.rockspec && rm -rf ./cprint-${verrev_cprint}; }
418test_unpack_binary() { rm -rf ./cprint-${verrev_cprint} && $luarocks build cprint && $luarocks pack cprint && $luarocks unpack ./cprint-${verrev_cprint}.${platform}.rock && rm -rf ./cprint-${verrev_cprint}; } 420test_unpack_binary() { rm -rf ./cprint-${verrev_cprint} && $luarocks build cprint && $luarocks pack cprint && $luarocks unpack ./cprint-${verrev_cprint}.${platform}.rock && rm -rf ./cprint-${verrev_cprint}; }
421fail_unpack_invalidpatch() { need_luasocket; $luarocks unpack "$testing_dir/testfiles/invalid_patch-0.1-1.rockspec"; }
419 422
420test_admin_help() { $luarocks_admin help; } 423test_admin_help() { $luarocks_admin help; }
421 424