diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2016-01-20 09:40:07 -0800 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2016-01-20 09:40:07 -0800 |
commit | c83bacb98b0b0fafb5c57fb9cf45301b74b84cd6 (patch) | |
tree | 7599794d12a6c7c8953fe2671131f6a057f3ab3b | |
parent | c534f8a903c10bf330c0b819fd75e1495a7e1d39 (diff) | |
parent | 0bf08e4e34469144ae6f3297aae4a38b3bb2bd3c (diff) | |
download | rebar-c83bacb98b0b0fafb5c57fb9cf45301b74b84cd6.tar.gz |
Merge pull request #562 from lrascao/fix/windows_retests
Add support for Windows integration testing
39 files changed, 385 insertions, 166 deletions
diff --git a/appveyor.yml b/appveyor.yml index a13f3d6..59b9570 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,13 +1,24 @@ version: 2.6.1.{build} -branches: - only: - - master +clone_depth: 1 build_script: -- cmd: bootstrap.bat +- cmd: >- + bootstrap.bat + + set REBAR_EXTRA_DEPS=1 + + .\rebar get-deps + + copy rebar deps\retest + + copy rebar.cmd deps\retest + + cd deps\retest & .\rebar compile escriptize test_script: - cmd: >- rebar eunit - deps/retest/retest -l debug inttest + "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 + + cd deps\retest & retest -l debug -t 120000 ..\..\inttest artifacts: - path: rebar diff --git a/inttest/app_src/app_src_rt.erl b/inttest/app_src/app_src_rt.erl index d71f03e..2b5a87e 100644 --- a/inttest/app_src/app_src_rt.erl +++ b/inttest/app_src/app_src_rt.erl @@ -30,9 +30,14 @@ -include_lib("eunit/include/eunit.hrl"). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> - [{copy, "../../rebar", "rebar"}, - {create, "src/app_src.app.src", app(app_src)}]. + [ + {create, "src/app_src.app.src", app(app_src)} + ] ++ inttest_utils:rebar_setup(). run(Dir) -> retest_log:log(debug, "Running in Dir: ~s~n", [Dir]), diff --git a/inttest/app_src_script/app_src_script_rt.erl b/inttest/app_src_script/app_src_script_rt.erl index 4c00ec8..c0de128 100644 --- a/inttest/app_src_script/app_src_script_rt.erl +++ b/inttest/app_src_script/app_src_script_rt.erl @@ -30,9 +30,14 @@ -include_lib("eunit/include/eunit.hrl"). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> - [{copy, "../../rebar", "rebar"}, - {create, "src/app_src_script.app.src.script", app_script(app_src_script)}]. + [ + {create, "src/app_src_script.app.src.script", app_script(app_src_script)} + ] ++ inttest_utils:rebar_setup(). run(Dir) -> retest_log:log(debug, "Running in Dir: ~s~n", [Dir]), diff --git a/inttest/app_src_script_2/app_src_script_2_rt.erl b/inttest/app_src_script_2/app_src_script_2_rt.erl index 1bf59d1..613e3f9 100644 --- a/inttest/app_src_script_2/app_src_script_2_rt.erl +++ b/inttest/app_src_script_2/app_src_script_2_rt.erl @@ -30,10 +30,15 @@ -include_lib("eunit/include/eunit.hrl"). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> - [{copy, "../../rebar", "rebar"}, + [ {create, "src/app_src_script_2.app.src.script", app_script(app_src_script_2)}, - {create, "src/app_src_script_2.app.src", app(app_src_script_2)}]. + {create, "src/app_src_script_2.app.src", app(app_src_script_2)} + ] ++ inttest_utils:rebar_setup(). run(Dir) -> retest_log:log(debug, "Running in Dir: ~s~n", [Dir]), diff --git a/inttest/appup_src/appup_src_rt.erl b/inttest/appup_src/appup_src_rt.erl index 2ca6788..7530aa4 100644 --- a/inttest/appup_src/appup_src_rt.erl +++ b/inttest/appup_src/appup_src_rt.erl @@ -30,9 +30,14 @@ -include_lib("eunit/include/eunit.hrl"). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> - [{copy, "../../rebar", "rebar"}, - {copy, "src", "src"}]. + [ + {copy, "src", "src"} + ] ++ inttest_utils:rebar_setup(). run(Dir) -> retest_log:log(debug, "Running in Dir: ~s~n", [Dir]), diff --git a/inttest/appup_src_2/appup_src_2_rt.erl b/inttest/appup_src_2/appup_src_2_rt.erl index 09d2503..99e6248 100644 --- a/inttest/appup_src_2/appup_src_2_rt.erl +++ b/inttest/appup_src_2/appup_src_2_rt.erl @@ -30,9 +30,14 @@ -include_lib("eunit/include/eunit.hrl"). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> - [{copy, "../../rebar", "rebar"}, - {copy, "src", "src"}]. + [ + {copy, "src", "src"} + ] ++ inttest_utils:rebar_setup(). run(Dir) -> retest_log:log(debug, "Running in Dir: ~s~n", [Dir]), diff --git a/inttest/appup_src_2/appup_src_rt_2.erl b/inttest/appup_src_2/appup_src_rt_2.erl index d662183..fff6f62 100644 --- a/inttest/appup_src_2/appup_src_rt_2.erl +++ b/inttest/appup_src_2/appup_src_rt_2.erl @@ -30,9 +30,13 @@ -include_lib("eunit/include/eunit.hrl"). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> - [{copy, "../../rebar", "rebar"}, - {copy, "src", "src"}]. + [{copy, "src", "src"} + ] ++ inttest_utils:rebar_setup(). run(Dir) -> retest_log:log(debug, "Running in Dir: ~s~n", [Dir]), diff --git a/inttest/appup_src_script/appup_src_script_rt.erl b/inttest/appup_src_script/appup_src_script_rt.erl index c98e54e..1aeb680 100644 --- a/inttest/appup_src_script/appup_src_script_rt.erl +++ b/inttest/appup_src_script/appup_src_script_rt.erl @@ -30,9 +30,14 @@ -include_lib("eunit/include/eunit.hrl"). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> - [{copy, "../../rebar", "rebar"}, - {copy, "src", "src"}]. + [ + {copy, "src", "src"} + ] ++ inttest_utils:rebar_setup(). run(Dir) -> retest_log:log(debug, "Running in Dir: ~s~n", [Dir]), diff --git a/inttest/bug_5_rt.erl b/inttest/bug_5_rt.erl index 8894cb5..f198d40 100644 --- a/inttest/bug_5_rt.erl +++ b/inttest/bug_5_rt.erl @@ -4,20 +4,21 @@ -compile(export_all). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. files() -> [{create, "ebin/a1.app", app(a1)}, {create, "deps/d1/src/d1.app.src", app(d1)}, {create, "rebar.config", - <<"{deps, [{d1, \"1\", {hg, \"http://example.com\", \"tip\"}}]}.\n">>}, - {copy, "../rebar", "rebar"}]. + <<"{deps, [{d1, \"1\", {hg, \"http://example.com\", \"tip\"}}]}.\n">>} + ] ++ inttest_utils:rebar_setup(".."). run(_Dir) -> {ok, _} = retest:sh("./rebar compile"), ok. - - %% %% Generate the contents of a simple .app file %% diff --git a/inttest/code_path_no_recurse/code_path_no_recurse_rt.erl b/inttest/code_path_no_recurse/code_path_no_recurse_rt.erl index 74d035e..a2ca980 100644 --- a/inttest/code_path_no_recurse/code_path_no_recurse_rt.erl +++ b/inttest/code_path_no_recurse/code_path_no_recurse_rt.erl @@ -28,14 +28,17 @@ -export([files/0, run/1]). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> [ - {copy, "../../rebar", "rebar"}, {copy, "rebar.config", "rebar.config"}, {copy, "src", "src"}, {copy, "test", "test"}, {copy, "deps", "deps"} - ]. + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> retest:log(info, "Compile project~n"), diff --git a/inttest/cover/cover_rt.erl b/inttest/cover/cover_rt.erl index a9f3f08..3f5e485 100644 --- a/inttest/cover/cover_rt.erl +++ b/inttest/cover/cover_rt.erl @@ -30,13 +30,18 @@ -include_lib("eunit/include/eunit.hrl"). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> - [{create, "ebin/foo.app", app(foo)}, - {copy, "../../rebar","rebar"}, + [ + {create, "ebin/foo.app", app(foo)}, {copy, "src", "src"}, {copy, "rebar-cover_export_json.config", - "rebar-cover_export_json.config"}]. + "rebar-cover_export_json.config"} + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> ifdef_test(), diff --git a/inttest/ct1/ct1_rt.erl b/inttest/ct1/ct1_rt.erl index dc83095..03b4ed8 100644 --- a/inttest/ct1/ct1_rt.erl +++ b/inttest/ct1/ct1_rt.erl @@ -4,21 +4,23 @@ -compile(export_all). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. files() -> - [{create, "ebin/a1.app", app(a1)}, - {copy, "../../rebar", "rebar"}, + [ + {create, "ebin/a1.app", app(a1)}, {copy, "rebar.config", "rebar.config"}, {copy, "app.config", "app.config"}, - {copy, "test_SUITE.erl", "itest/test_SUITE.erl"}]. + {copy, "test_SUITE.erl", "itest/test_SUITE.erl"} + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> {ok, _} = retest:sh("./rebar compile ct"), {ok, _} = retest:sh("./rebar compile ct -v"), ok. - - %% %% Generate the contents of a simple .app file %% diff --git a/inttest/ct2/ct2_rt.erl b/inttest/ct2/ct2_rt.erl index f9d2b19..b3138d4 100644 --- a/inttest/ct2/ct2_rt.erl +++ b/inttest/ct2/ct2_rt.erl @@ -4,13 +4,17 @@ -compile(export_all). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. files() -> - [{create, "ebin/foo.app", app(foo)}, - {copy, "../../rebar", "rebar"}, + [ + {create, "ebin/foo.app", app(foo)}, {copy, "foo.test.spec", "foo.test.spec"}, {copy, "deps/bar.test.spec", "deps/bar.test.spec"}, - {copy, "foo_SUITE.erl", "test/foo_SUITE.erl"}]. + {copy, "foo_SUITE.erl", "test/foo_SUITE.erl"} + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> Ref = retest:sh("./rebar compile ct -vvv", [async]), diff --git a/inttest/ct3/ct3_rt.erl b/inttest/ct3/ct3_rt.erl index a87cf21..b5739db 100644 --- a/inttest/ct3/ct3_rt.erl +++ b/inttest/ct3/ct3_rt.erl @@ -28,19 +28,23 @@ -compile(export_all). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. files() -> - [{create, "ebin/a1.app", app(a1)}, - {copy, "../../rebar", "rebar"}, + [ + {create, "ebin/a1.app", app(a1)}, {copy, "rebar.config", "rebar.config"}, {copy, "app.config", "itest/app.config"}, {copy, "test_SUITE.erl", "itest/test_SUITE.erl"}, {copy, "converted"}, - {copy, "unconverted"}]. + {copy, "unconverted"} + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> {ok, _} = retest:sh("./rebar compile ct -v", - [{env, [{"ERL_FLAGS", "-name ct_rt3"}]}]), + [{env, [{"ERL_FLAGS", "-name ct_rt3@localhost"}]}]), ok. %% diff --git a/inttest/ct_cover/ct_cover_rt.erl b/inttest/ct_cover/ct_cover_rt.erl index c7f8776..361d85b 100644 --- a/inttest/ct_cover/ct_cover_rt.erl +++ b/inttest/ct_cover/ct_cover_rt.erl @@ -4,14 +4,19 @@ -compile(export_all). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> - [{create, "ebin/a1.app", app(a1)}, - {copy, "../../rebar", "rebar"}, + [ + {create, "ebin/a1.app", app(a1)}, {copy, "rebar.config", "rebar.config"}, {copy, "app.config", "app.config"}, {copy, "cover.spec", "cover.spec"}, {copy, "test_SUITE.erl", "itest/test_SUITE.erl"}, - {copy, "mock", "deps"}]. + {copy, "mock", "deps"} + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> {ok, _} = retest:sh("./rebar compile ct"), diff --git a/inttest/depplugins/depplugins_rt.erl b/inttest/depplugins/depplugins_rt.erl index 7bcfe86..fc72dec 100644 --- a/inttest/depplugins/depplugins_rt.erl +++ b/inttest/depplugins/depplugins_rt.erl @@ -21,9 +21,12 @@ -include_lib("eunit/include/eunit.hrl"). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> [ - {copy, "../../rebar", "rebar"}, {copy, "rebar.config", "rebar.config"}, {copy, "base_dir_cwd_plugin.erl", "base_dir_cwd_plugin.erl"}, {create, "ebin/fish.app", app(fish, [])}, @@ -38,7 +41,7 @@ files() -> "deps/testplugin/plugins/testplugin_mod.erl"}, {copy, "dep_cwd_plugin.erl", "deps/testplugin/dep_cwd_plugin.erl"}, {create, "deps/testplugin/ebin/testplugin.app", app(testplugin, [])} - ]. + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> ?assertMatch({ok, _}, retest_sh:run("./rebar compile", [])), diff --git a/inttest/erlc/erlc_rt.erl b/inttest/erlc/erlc_rt.erl index 0c1f25d..3ac5956 100644 --- a/inttest/erlc/erlc_rt.erl +++ b/inttest/erlc/erlc_rt.erl @@ -54,9 +54,12 @@ "foo_worker.beam", "SIMPLE-ASN.beam"]). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> [ - {copy, "../../rebar", "rebar"}, {copy, "rebar.config", "rebar.config"}, {copy, "rebar-no_debug_info.config", "rebar-no_debug_info.config"}, {copy, "include", "include"}, @@ -73,7 +76,7 @@ files() -> %% deps {create, "deps/foobar/ebin/foobar.app", app(foobar, [foobar])}, {copy, "foobar.erl", "deps/foobar/src/foobar.erl"} - ]. + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> ?assertMatch({ok, _}, retest_sh:run("./rebar compile", [])), diff --git a/inttest/erlc_dep_graph/erlc_dep_graph_rt.erl b/inttest/erlc_dep_graph/erlc_dep_graph_rt.erl index 384ce87..72c6928 100644 --- a/inttest/erlc_dep_graph/erlc_dep_graph_rt.erl +++ b/inttest/erlc_dep_graph/erlc_dep_graph_rt.erl @@ -30,39 +30,57 @@ -include_lib("eunit/include/eunit.hrl"). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> - [{copy, "../../rebar", "rebar"}, + [ {copy, "rebar.config", "rebar.config"}, {copy, "src", "src"}, {copy, "include", "include"}, - {copy, "extra_include", "extra_include"}]. + {copy, "extra_include", "extra_include"} + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> + retest_log:log(debug, "compiling all...\n\n", []), compile_all(ok, ""), + retest_log:log(debug, "checking beams integrity...\n\n", []), check_beams_ok(), check_beams_untouched(filelib:wildcard("ebin/*.beam")), + retest_log:log(debug, "modifying lisp.erl and recompiling...\n\n", []), modify_and_recompile_ok("src/lisp.erl", "ebin/lisp.beam"), + retest_log:log(debug, "cleaning all...\n\n", []), clean_all_ok(), + retest_log:log(debug, "compiling all (expect fail)...\n\n", []), compile_all(error, "-C rebar.config.non-existing"), + retest_log:log(debug, "compiling all...\n\n", []), compile_all(ok, ""), + retest_log:log(debug, "modifying extra_include/extra.hrl and recompiling...\n\n", []), modify_and_recompile_ok("extra_include/extra.hrl", "ebin/java.beam"), + retest_log:log(debug, "rewriting src/java.erl...\n\n", []), Java = "src/java.erl", {ok, OrigContent} = file:read_file(Java), %% Remove header file inclusion {ok, _} = file:copy("src/java.erl.no_extra", Java), %% Ensure recompilation touch([Java]), + retest_log:log(debug, "compiling all...\n\n", []), compile_all(ok, ""), %% Modify that header file + retest_log:log(debug, "again modifying extra_include/extra.hrl and recompiling...\n\n", []), touch(["extra_include/extra.hrl"]), %% Ensure we don't have to recompile anything + retest_log:log(debug, "ensure ebin/java.beam was untouched...\n\n", []), check_beams_untouched(["ebin/java.beam"]), %% Clean up + retest_log:log(debug, "modifying src/java.erl...\n\n", []), ok = file:write_file(Java, OrigContent), %% Check that changes propagate deeply through the dependency tree + retest_log:log(debug, "modifying include/lambda.hrl...\n\n", []), modify_and_recompile_ok("include/lambda.hrl", "ebin/perl.beam"), ok. @@ -82,7 +100,9 @@ compile_all_and_assert_mtimes(Beams, Cmp) -> BeamsModifiedBefore = mtime_ns(Beams), compile_all(ok, ""), BeamsModifiedAfter = mtime_ns(Beams), - lists:zipwith(fun(Before, After) -> ?assert(Cmp(Before, After)) end, + lists:zipwith(fun(Before, After) -> + ?assert(Cmp(Before, After)) + end, BeamsModifiedBefore, BeamsModifiedAfter). with_erl_beams(F) -> @@ -95,13 +115,13 @@ with_erl_beams(F) -> filelib:wildcard("src/*.erl")). mtime_ns(Files) -> - [os:cmd("stat -c%y " ++ File) || File <- Files]. + [calendar:datetime_to_gregorian_seconds(filelib:last_modified(File)) || File <- Files]. touch(Files) -> %% Sleep one second so that filelib:last_modified/1 is guaranteed to notice %% that files have changed. ok = timer:sleep(1000), - [os:cmd("touch " ++ File) || File <- Files]. + [file:change_time(File, calendar:local_time()) || File <- Files]. compile_all(Result, Opts) -> ?assertMatch({Result, _}, diff --git a/inttest/eunit/eunit_rt.erl b/inttest/eunit/eunit_rt.erl index 1d71404..bc24b26 100644 --- a/inttest/eunit/eunit_rt.erl +++ b/inttest/eunit/eunit_rt.erl @@ -5,14 +5,19 @@ -include_lib("eunit/include/eunit.hrl"). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> - [{create, "ebin/foo.app", app(foo)}, - {copy, "../../rebar", "rebar"}, + [ + {create, "ebin/foo.app", app(foo)}, {copy, "src", "src"}, {copy, "eunit_src", "eunit_src"}, {copy, "rebar-eunit_compile_opts.config", - "rebar-eunit_compile_opts.config"}]. + "rebar-eunit_compile_opts.config"} + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> ifdef_test(), diff --git a/inttest/inttest_utils.erl b/inttest/inttest_utils.erl new file mode 100644 index 0000000..d896f4d --- /dev/null +++ b/inttest/inttest_utils.erl @@ -0,0 +1,16 @@ +%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*- +%% ex: ts=4 sw=4 et +-module(inttest_utils). + +-compile(export_all). + +rebar_setup({win32, nt}, Dir) -> + [{copy, filename:join(Dir, "rebar.cmd"), "rebar.cmd"}]; +rebar_setup({_, _}, _) -> []. + +rebar_setup(Dir) -> + [{copy, + filename:join(Dir, "rebar"), "rebar"}] ++ rebar_setup(os:type(), Dir). + +rebar_setup() -> + rebar_setup("../.."). diff --git a/inttest/logging/logging_rt.erl b/inttest/logging/logging_rt.erl index 2709a84..f774376 100644 --- a/inttest/logging/logging_rt.erl +++ b/inttest/logging/logging_rt.erl @@ -30,11 +30,14 @@ -define(APP_FILE, "ebin/logging.app"). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> [ - {copy, "../../rebar", "rebar"}, {create, ?APP_FILE, app(invalid_name, [])} - ]. + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> SharedExpected = "==> logging_rt \\(compile\\)", diff --git a/inttest/port/port_rt.erl b/inttest/port/port_rt.erl index 90ecbdc..c910e0e 100644 --- a/inttest/port/port_rt.erl +++ b/inttest/port/port_rt.erl @@ -31,13 +31,16 @@ -include_lib("eunit/include/eunit.hrl"). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> [ - {copy, "../../rebar", "rebar"}, {copy, "rebar.config", "rebar.config"}, {copy, "c_src", "c_src"}, {create, "ebin/foo.app", app(foo, [])} - ]. + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> %% wait a bit for new files to have different timestamps @@ -45,48 +48,76 @@ run(_Dir) -> %% test.so is created during first compile ?assertEqual(0, filelib:last_modified("priv/test.so")), ?assertMatch({ok, _}, retest_sh:run("./rebar compile", [])), - TestSo1 = filelib:last_modified("priv/test.so"), + TestSo1 = filelib:last_modified("priv/test" ++ + shared_library_file_extension(os:type())), ?assert(TestSo1 > 0), wait(), %% nothing happens during second compile ?assertMatch({ok, _}, retest_sh:run("./rebar compile", [])), - TestSo2 = filelib:last_modified("priv/test.so"), - Test1o2 = filelib:last_modified("c_src/test1.o"), - Test2o2 = filelib:last_modified("c_src/test2.o"), + TestSo2 = filelib:last_modified("priv/test" ++ + shared_library_file_extension(os:type())), + Test1o2 = filelib:last_modified("c_src/test1" ++ + object_file_extension(os:type())), + Test2o2 = filelib:last_modified("c_src/test2" ++ + object_file_extension(os:type())), ?assertEqual(TestSo1, TestSo2), ?assert(TestSo1 >= Test1o2), ?assert(TestSo1 >= Test2o2), wait(), %% when test2.c changes, at least test2.o and test.so are rebuilt - ?assertMatch({ok, _}, retest_sh:run("touch c_src/test2.c", [])), + ?assertMatch({ok, _}, retest:run({touch, "c_src/test2.c"}, [{dir, "."}])), ?assertMatch({ok, _}, retest_sh:run("./rebar compile", [])), - TestSo3 = filelib:last_modified("priv/test.so"), - Test2o3 = filelib:last_modified("c_src/test2.o"), + TestSo3 = filelib:last_modified("priv/test" ++ + shared_library_file_extension(os:type())), + Test2o3 = filelib:last_modified("c_src/test2" ++ + object_file_extension(os:type())), ?assert(TestSo3 > TestSo2), ?assert(Test2o3 > TestSo2), - wait(), - %% when test2.h changes, at least test2.o and test.so are rebuilt - ?assertMatch({ok, _}, retest_sh:run("touch c_src/test2.h", [])), - ?assertMatch({ok, _}, retest_sh:run("./rebar compile", [])), - TestSo4 = filelib:last_modified("priv/test.so"), - Test2o4 = filelib:last_modified("c_src/test2.o"), - ?assert(TestSo4 > TestSo3), - ?assert(Test2o4 > TestSo3), - wait(), - %% when test1.h changes, everything is rebuilt - ?assertMatch({ok, _}, retest_sh:run("touch c_src/test1.h", [])), - ?assertMatch({ok, _}, retest_sh:run("./rebar compile", [])), - TestSo5 = filelib:last_modified("priv/test.so"), - Test1o5 = filelib:last_modified("c_src/test1.o"), - Test2o5 = filelib:last_modified("c_src/test2.o"), - ?assert(TestSo5 > TestSo4), - ?assert(Test1o5 > TestSo4), - ?assert(Test2o5 > TestSo4), - ok. + %% detecting the a full recompile is needed when changing a .h file is a feature attained + %% by using the -MMD gcc flag which sadly is not available in Windows, so this part of the + %% test is only executed in Unix + case os:type() of + {win32, _} -> ok; + _ -> + wait(), + %% when test2.h changes, at least test2.o and test.so are rebuilt + ?assertMatch({ok, _}, + retest:run({touch, "c_src/test2.h"}, [{dir, "."}])), + ?assertMatch({ok, _}, + retest_sh:run("./rebar compile", [])), + TestSo4 = filelib:last_modified("priv/test" ++ + shared_library_file_extension(os:type())), + Test2o4 = filelib:last_modified("c_src/test2" ++ + object_file_extension(os:type())), + ?assert(TestSo4 > TestSo3), + ?assert(Test2o4 > TestSo3), + wait(), + %% when test1.h changes, everything is rebuilt + ?assertMatch({ok, _}, + retest:run({touch, "c_src/test1.h"}, [{dir, "."}])), + ?assertMatch({ok, _}, + retest_sh:run("./rebar compile", [])), + TestSo5 = filelib:last_modified("priv/test" ++ + shared_library_file_extension(os:type())), + Test1o5 = filelib:last_modified("c_src/test1" ++ + object_file_extension(os:type())), + Test2o5 = filelib:last_modified("c_src/test2" ++ + object_file_extension(os:type())), + ?assert(TestSo5 > TestSo4), + ?assert(Test1o5 > TestSo4), + ?assert(Test2o5 > TestSo4), + ok + end. wait() -> timer:sleep(1000). +object_file_extension({win32, nt}) -> ".o"; +object_file_extension(_) -> ".o". + +shared_library_file_extension({win32, nt}) -> ".dll"; +shared_library_file_extension(_) -> ".so". + %% %% Generate the contents of a simple .app file %% diff --git a/inttest/port/rebar.config b/inttest/port/rebar.config index a941218..efab1af 100644 --- a/inttest/port/rebar.config +++ b/inttest/port/rebar.config @@ -1 +1,2 @@ -{port_specs, [{"priv/test.so", ["c_src/*.c"]}]}. +{port_specs, [{"win32", "priv/test.dll", ["c_src/*.c"]}, + {"priv/test.so", ["c_src/*.c"]}]}. diff --git a/inttest/profile/profile_rt.erl b/inttest/profile/profile_rt.erl index b128517..b8a9e09 100644 --- a/inttest/profile/profile_rt.erl +++ b/inttest/profile/profile_rt.erl @@ -30,10 +30,12 @@ -include_lib("eunit/include/eunit.hrl"). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> - [ - {copy, "../../rebar", "rebar"} - ]. + inttest_utils:rebar_setup(). run(_Dir) -> Cmd = "./rebar list-deps", diff --git a/inttest/proto_gpb/proto_gpb_rt.erl b/inttest/proto_gpb/proto_gpb_rt.erl index 8a7cacf..307aca0 100644 --- a/inttest/proto_gpb/proto_gpb_rt.erl +++ b/inttest/proto_gpb/proto_gpb_rt.erl @@ -30,7 +30,6 @@ -include_lib("eunit/include/eunit.hrl"). -include_lib("kernel/include/file.hrl"). --include_lib("deps/retest/include/retest.hrl"). -define(MODULES, [foo, @@ -51,9 +50,12 @@ "c/test4.proto", "c/d/test5.proto"]). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> [ - {copy, "../../rebar", "rebar"}, {copy, "rebar.config", "rebar.config"}, {copy, "rebar2.config", "rebar2.config"}, {copy, "rebar.bad.config", "rebar.bad.config"}, @@ -63,7 +65,7 @@ files() -> {copy, "proto.bad", "proto.bad"}, {copy, "mock", "deps"}, {create, "ebin/foo.app", app(foo, ?MODULES ++ ?GENERATED_MODULES)} - ]. + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> % perform test obtaining the .proto files from src dir @@ -99,7 +101,7 @@ run_from_dir(success_expected, ProtoDir, ConfigFile) -> %% the .hrl file was generated before foo was compiled. ok = check_beams_generated(), - ?DEBUG("Verifying recompilation~n", []), + retest_log:log(debug, "Verifying recompilation~n", []), TestErl = hd(generated_erl_files()), TestProto = hd(source_proto_files(ProtoDir)), make_proto_newer_than_erl(TestProto, TestErl), @@ -111,7 +113,7 @@ run_from_dir(success_expected, ProtoDir, ConfigFile) -> TestMTime2 = read_mtime(TestErl), ?assert(TestMTime2 > TestMTime1), - ?DEBUG("Verifying recompilation with no changes~n", []), + retest_log:log(debug, "Verifying recompilation with no changes~n", []), TestMTime3 = read_mtime(TestErl), ?assertMatch({ok, _}, retest_sh:run("./rebar --config " ++ ConfigFile @@ -120,7 +122,7 @@ run_from_dir(success_expected, ProtoDir, ConfigFile) -> TestMTime4 = read_mtime(TestErl), ?assert(TestMTime3 =:= TestMTime4), - ?DEBUG("Verify cleanup~n", []), + retest_log:log(debug, "Verify cleanup~n", []), ?assertMatch({ok, _}, retest_sh:run("./rebar --config " ++ ConfigFile ++ " clean", diff --git a/inttest/proto_protobuffs/proto_protobuffs_rt.erl b/inttest/proto_protobuffs/proto_protobuffs_rt.erl index 1bb7b5e..ee4c294 100644 --- a/inttest/proto_protobuffs/proto_protobuffs_rt.erl +++ b/inttest/proto_protobuffs/proto_protobuffs_rt.erl @@ -42,15 +42,18 @@ "foo_sup.beam", "test_pb.beam"]). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> [ - {copy, "../../rebar", "rebar"}, {copy, "rebar.config", "rebar.config"}, {copy, "include", "include"}, {copy, "src", "src"}, {copy, "mock", "deps"}, {create, "ebin/foo.app", app(foo, ?MODULES)} - ]. + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> ?assertMatch({ok, _}, retest_sh:run("./rebar clean", [])), diff --git a/inttest/require_vsn/require_vsn_rt.erl b/inttest/require_vsn/require_vsn_rt.erl index 0b947c5..8ff87f7 100644 --- a/inttest/require_vsn/require_vsn_rt.erl +++ b/inttest/require_vsn/require_vsn_rt.erl @@ -28,12 +28,15 @@ -export([files/0, run/1]). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> [ - {copy, "../../rebar", "rebar"}, {copy, "rebar.config", "rebar.config"}, {create, "ebin/require_vsn.app", app(require_vsn, [])} - ]. + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> SharedExpected = "==> require_vsn_rt \\(compile\\)", diff --git a/inttest/rgen1/retest.config b/inttest/rgen1/retest.config index b569f14..244096d 100644 --- a/inttest/rgen1/retest.config +++ b/inttest/rgen1/retest.config @@ -1 +1 @@ -{timeout, 120000}. +{timeout, 240000}. diff --git a/inttest/rgen1/rgen1_rt.erl b/inttest/rgen1/rgen1_rt.erl index 1bf36c2..5847f4a 100644 --- a/inttest/rgen1/rgen1_rt.erl +++ b/inttest/rgen1/rgen1_rt.erl @@ -6,13 +6,16 @@ %% Exercise release generation w/ templating +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> [ {copy, "reltool.config"}, {copy, "test.config"}, - {copy, "vars.config"}, - {copy, "../../rebar"} - ]. + {copy, "vars.config"} + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> {ok, _} = retest_sh:run("./rebar -v generate", []), diff --git a/inttest/t_custom_config/t_custom_config_rt.erl b/inttest/t_custom_config/t_custom_config_rt.erl index a373b32..1f21927 100644 --- a/inttest/t_custom_config/t_custom_config_rt.erl +++ b/inttest/t_custom_config/t_custom_config_rt.erl @@ -6,10 +6,15 @@ -include_lib("eunit/include/eunit.hrl"). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> - [{copy, "../../rebar", "rebar"}, + [ {copy, "custom.config", "custom.config"}, - {create, "ebin/custom_config.app", app(custom_config, [custom_config])}]. + {create, "ebin/custom_config.app", app(custom_config, [custom_config])} + ] ++ inttest_utils:rebar_setup(). run(Dir) -> retest_log:log(debug, "Running in Dir: ~s~n", [Dir]), diff --git a/inttest/tdeps1/tdeps1_rt.erl b/inttest/tdeps1/tdeps1_rt.erl index 3591ec0..849403b 100644 --- a/inttest/tdeps1/tdeps1_rt.erl +++ b/inttest/tdeps1/tdeps1_rt.erl @@ -4,16 +4,18 @@ -compile(export_all). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + %% Exercise transitive dependencies %% A -> B -> C, where A includes a .hrl from B which includes .hrl from C - files() -> [ %% A application {create, "ebin/a.app", app(a, [a])}, {copy, "a.rebar.config", "rebar.config"}, {copy, "a.erl", "src/a.erl"}, - {copy, "../../rebar", "rebar"}, %% B application {create, "repo/b/ebin/b.app", app(b, [])}, @@ -23,7 +25,7 @@ files() -> %% C application {create, "repo/c/ebin/c.app", app(c, [])}, {copy, "c.hrl", "repo/c/include/c.hrl"} - ]. + ] ++ inttest_utils:rebar_setup(). apply_cmds([], _Params) -> ok; @@ -39,7 +41,7 @@ run(_Dir) -> "git add -A", "git config user.email 'tdeps@example.com'", "git config user.name 'tdeps'", - "git commit -a -m 'Initial Commit'"], + "git commit -a -m \"Initial Commit\""], apply_cmds(GitCmds, [{dir, "repo/b"}]), apply_cmds(GitCmds, [{dir, "repo/c"}]), diff --git a/inttest/tdeps2/tdeps2_rt.erl b/inttest/tdeps2/tdeps2_rt.erl index 97a24ce..a5665ad 100644 --- a/inttest/tdeps2/tdeps2_rt.erl +++ b/inttest/tdeps2/tdeps2_rt.erl @@ -4,10 +4,13 @@ -compile(export_all). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + %% Exercise transitive dependencies where there are multiple files %% depending on the same set of deps %% [A1, A2] -> B -> C ; A1 and A2 includes B.hrl which includes C.hrl - files() -> [ %% A1 application @@ -21,7 +24,6 @@ files() -> {template, "a.erl", "apps/a2/src/a2.erl", dict:from_list([{module, a2}])}, {copy, "root.rebar.config", "rebar.config"}, - {copy, "../../rebar", "rebar"}, %% B application {create, "repo/b/ebin/b.app", app(b, [])}, @@ -31,7 +33,7 @@ files() -> %% C application {create, "repo/c/ebin/c.app", app(c, [])}, {copy, "c.hrl", "repo/c/include/c.hrl"} - ]. + ] ++ inttest_utils:rebar_setup(). apply_cmds([], _Params) -> ok; @@ -47,7 +49,7 @@ run(_Dir) -> "git add -A", "git config user.email 'tdeps@example.com'", "git config user.name 'tdeps'", - "git commit -a -m 'Initial Commit'"], + "git commit -a -m \"Initial Commit\""], ok = apply_cmds(GitCmds, [{dir, "repo/b"}]), ok = apply_cmds(GitCmds, [{dir, "repo/c"}]), diff --git a/inttest/tdeps3/tdeps3_rt.erl b/inttest/tdeps3/tdeps3_rt.erl index f56b3ca..bc47772 100644 --- a/inttest/tdeps3/tdeps3_rt.erl +++ b/inttest/tdeps3/tdeps3_rt.erl @@ -4,12 +4,15 @@ -compile(export_all). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + %% Exercise transitive dependencies where there are multiple files %% depending on the same set of deps as well as lib_dir directives %% A -> B -> C -> D -> E %% |--> G(via lib_dir) %% |--> F -> D -> E - files() -> [ %% A1 application @@ -17,7 +20,6 @@ files() -> {template, "a.erl", "src/a.erl", dict:from_list([{module, a}, {dep, b}])}, {copy, "a.rebar.config", "rebar.config"}, - {copy, "../../rebar", "rebar"}, %% B application {create, "repo/b/ebin/b.app", app(b, [b])}, @@ -52,7 +54,7 @@ files() -> {create, "repo/b/apps/g/ebin/g.app", app(g, [])}, {copy, "e.hrl", "repo/b/apps/g/include/g.hrl"} - ]. + ] ++ inttest_utils:rebar_setup(). apply_cmds([], _Params) -> ok; @@ -68,7 +70,7 @@ run(_Dir) -> "git add -A", "git config user.email 'tdeps@example.com'", "git config user.name 'tdeps'", - "git commit -a -m 'Initial Commit'"], + "git commit -a -m \"Initial Commit\""], ok = apply_cmds(GitCmds, [{dir, "repo/b"}]), ok = apply_cmds(GitCmds, [{dir, "repo/c"}]), ok = apply_cmds(GitCmds, [{dir, "repo/d"}]), diff --git a/inttest/tdeps_update/tdeps_update_rt.erl b/inttest/tdeps_update/tdeps_update_rt.erl index c53e253..b4919c5 100644 --- a/inttest/tdeps_update/tdeps_update_rt.erl +++ b/inttest/tdeps_update/tdeps_update_rt.erl @@ -4,6 +4,10 @@ -compile(export_all). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + %% Exercises update deps, with recursive dependency updates. %% Initially: %% A(v0.5) -> B(v0.2.3) -> C(v1.0) @@ -25,7 +29,6 @@ files() -> {template, "a.erl", "apps/a1/src/a1.erl", dict:from_list([{module, a1}])}, {copy, "root.rebar.config", "rebar.config"}, - {copy, "../../rebar", "rebar"}, %% B application {create, "repo/b/ebin/b.app", app(b, [], "0.2.3")}, @@ -64,57 +67,62 @@ files() -> {copy, "c.rebar.config", "c.rebar.config"}, {copy, "c2.rebar.config", "c2.rebar.config"}, {copy, "c3.rebar.config", "c3.rebar.config"} - ]. + ] ++ inttest_utils:rebar_setup(). apply_cmds([], _Params) -> ok; apply_cmds([Cmd | Rest], Params) -> - io:format("Running: ~s (~p)\n", [Cmd, Params]), - {ok, _} = retest_sh:run(Cmd, Params), + io:format("Running: ~p (~p)\n", [Cmd, Params]), + {ok, _} = retest:run(Cmd, Params), apply_cmds(Rest, Params). -run(_Dir) -> +run(Dir) -> %% Initialize the b/c/d apps as git repos so that dependencies pull %% properly GitCmds = ["git init", "git add -A", - "git config user.email 'tdeps@example.com'", - "git config user.name 'tdeps'", - "git commit -a -m 'Initial Commit'"], + "git config user.email \"tdeps@example.com\"", + "git config user.name \"tdeps\"", + "git commit -a -m \"Initial Commit\""], BCmds = ["git tag 0.2.3", - "cp ../../b2.rebar.config rebar.config", - "cp ../../b2.app ebin/b.app", - "git commit -a -m 'update to 0.2.4'", + {copy, "../../b2.rebar.config", "rebar.config"}, + {copy, "../../b2.app", "ebin/b.app"}, + {touch, "ebin/b.app"}, + "git commit -a -m \"update to 0.2.4\"", "git tag 0.2.4", - "cp ../../b3.rebar.config rebar.config", - "cp ../../b3.app ebin/b.app", - "git commit -a -m 'update to 0.2.5'", + {copy, "../../b3.rebar.config", "rebar.config"}, + {copy, "../../b3.app", "ebin/b.app"}, + {touch, "ebin/b.app"}, + "git commit -a -m \"update to 0.2.5\"", "git tag 0.2.5", - "cp ../../b4.rebar.config rebar.config", - "cp ../../b4.app ebin/b.app", - "git commit -a -m 'update to 0.2.6'", + {copy, "../../b4.rebar.config", "rebar.config"}, + {copy, "../../b4.app", "ebin/b.app"}, + {touch, "ebin/b.app"}, + "git commit -a -m \"update to 0.2.6\"", "git tag 0.2.6"], %"git checkout 0.2.3"], CCmds = ["git tag 1.0", - "cp ../../c2.hrl include/c.hrl", - "cp ../../c2.app ebin/c.app", - "cp ../../c.rebar.config rebar.config", + {copy, "../../c2.hrl", "include/c.hrl"}, + {copy, "../../c2.app", "ebin/c.app"}, + {copy, "../../c.rebar.config", "rebar.config"}, "git add rebar.config", - "git commit -a -m 'update to 1.1'", + "git commit -a -m \"update to 1.1\"", "git tag 1.1", - "cp ../../c3.app ebin/c.app", - "cp ../../c2.rebar.config rebar.config", - "git commit -a -m 'update to 1.2'", + {copy, "../../c3.app", "ebin/c.app"}, + {copy, "../../c2.rebar.config", "rebar.config"}, + "git commit -a -m \"update to 1.2\"", "git tag 1.2", - "cp ../../c4.app ebin/c.app", - "cp ../../c3.rebar.config rebar.config", - "git commit -a -m 'update to 1.3'", + {copy, "../../c4.app", "ebin/c.app"}, + {copy, "../../c3.rebar.config", "rebar.config"}, + {touch, "rebar.config"}, + "git commit -a -m \"update to 1.3\"", "git tag 1.3"], %"git checkout 1.0"], DCmds = ["git tag 0.7"], ECmds = ["git tag 2.0", - "cp ../../e2.app ebin/e.app", - "git commit -a -m 'update to 2.1'", + {copy, "../../e2.app", "ebin/e.app"}, + {touch, "ebin/e.app"}, + "git commit -a -m \"update to 2.1\"", "git tag 2.1"], FCmds = ["git tag 0.1"], @@ -126,13 +134,16 @@ run(_Dir) -> {ok, _} = retest_sh:run("./rebar -v get-deps", []), {ok, _} = retest_sh:run("./rebar -v compile", []), - os:cmd("cp a2.rebar.config apps/a1/rebar.config"), + retest:run({copy, "a2.rebar.config", "apps/a1/rebar.config"}, + [{dir, Dir}]), {ok, _} = retest_sh:run("./rebar -v update-deps", []), {ok, _} = retest_sh:run("./rebar -v compile", []), - os:cmd("cp a3.rebar.config apps/a1/rebar.config"), + retest:run({copy, "a3.rebar.config", "apps/a1/rebar.config"}, + [{dir, Dir}]), {ok, _} = retest_sh:run("./rebar -v update-deps", []), {ok, _} = retest_sh:run("./rebar -v compile", []), - os:cmd("cp a4.rebar.config apps/a1/rebar.config"), + retest:run({copy, "a4.rebar.config", "apps/a1/rebar.config"}, + [{dir, Dir}]), {ok, _} = retest_sh:run("./rebar -v update-deps", []), {ok, _} = retest_sh:run("./rebar -v compile", []), ok. diff --git a/inttest/thooks/thooks_rt.erl b/inttest/thooks/thooks_rt.erl index 3cca6bb..f1e7fa4 100644 --- a/inttest/thooks/thooks_rt.erl +++ b/inttest/thooks/thooks_rt.erl @@ -5,14 +5,17 @@ -include_lib("eunit/include/eunit.hrl"). -compile(export_all). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> [ %% dummy lfe files - {copy, "../../rebar", "rebar"}, {copy, "rebar.config", "rebar.config"}, {copy, "fish.erl", "src/fish.erl"}, {create, "ebin/fish.app", app(fish, [fish])} - ]. + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> ?assertMatch({ok, _}, retest_sh:run("./rebar -v clean compile", [])), @@ -27,7 +30,13 @@ ensure_command_ran_only_once(Command) -> ?assert(filelib:is_regular(File)), %% ensure that this command only ran once (not for each module) {ok, Content} = file:read_file(File), - ?assertEqual(Command ++ "\n", binary_to_list(Content)). + %% echo behaves differently in windows and unix + case os:type() of + {win32, nt} -> + ?assertEqual(Command ++ " \r\n", binary_to_list(Content)); + _ -> + ?assertEqual(Command ++ "\n", binary_to_list(Content)) + end. %% %% Generate the contents of a simple .app file diff --git a/inttest/tplugins/tplugins_rt.erl b/inttest/tplugins/tplugins_rt.erl index 01d296e..d36afdd 100644 --- a/inttest/tplugins/tplugins_rt.erl +++ b/inttest/tplugins/tplugins_rt.erl @@ -8,9 +8,12 @@ -define(COMPILE_ERROR, "ERROR: Plugin bad_plugin contains compilation errors:"). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> [ - {copy, "../../rebar", "rebar"}, {copy, "rebar.config", "rebar.config"}, {copy, "bad.config", "bad.config"}, {copy, "fish.erl", "src/fish.erl"}, @@ -18,7 +21,7 @@ files() -> {copy, "bad_plugin.erl", "bad_plugins/bad_plugin.erl"}, {create, "fwibble.test", <<"fwibble">>}, {create, "ebin/fish.app", app(fish, [fish])} - ]. + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> ?assertMatch({ok, _}, retest_sh:run("./rebar fwibble -v", [])), diff --git a/inttest/xref_behavior/xref_behavior_rt.erl b/inttest/xref_behavior/xref_behavior_rt.erl index 8536710..f6d5ff8 100644 --- a/inttest/xref_behavior/xref_behavior_rt.erl +++ b/inttest/xref_behavior/xref_behavior_rt.erl @@ -2,16 +2,19 @@ -export([files/0, run/1]). +setup([Target]) -> + retest_utils:load_module(filename:join(Target, "inttest_utils.erl")), + ok. + files() -> [ - {copy, "../../rebar", "rebar"}, {copy, "rebar.config", "rebar.config"}, {copy, "xref_behavior.erl", "src/xref_behavior.erl"}, {copy, "gen_xref_behavior.erl", "src/gen_xref_behavior.erl"}, {create, "ebin/xref_behavior.app", app(xref_behavior, [xref_behavior, gen_xref_behavior])} - ]. + ] ++ inttest_utils:rebar_setup(). run(_Dir) -> {ok, _} = retest_sh:run("./rebar compile", []), diff --git a/rebar.config.script b/rebar.config.script index 25e3f80..78ba967 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -1,7 +1,8 @@ %% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*- %% ex: ts=4 sw=4 ft=erlang et -ExtraDeps = [{retest, ".*", {git, "git://github.com/dizzyd/retest.git", {tag, "4590941a"}}}], +ExtraDeps = [{retest, ".*", {git, "git://github.com/dizzyd/retest.git", + {tag, "1.1.0"}}}], case os:getenv("REBAR_EXTRA_DEPS") of false -> diff --git a/src/rebar_ct.erl b/src/rebar_ct.erl index 022dfc4..cf2059e 100644 --- a/src/rebar_ct.erl +++ b/src/rebar_ct.erl @@ -113,7 +113,12 @@ run_test(TestDir, LogDir, Config, _File) -> false -> " >> " ++ RawLog ++ " 2>&1"; true -> + case os:type() of + {win32, nt} -> + " >> " ++ RawLog ++ " 2>&1"; + _ -> " 2>&1 | tee -a " ++ RawLog + end end, ShOpts = [{env,[{"TESTDIR", TestDir}]}, return_on_error], @@ -155,14 +160,27 @@ failure_logger(Command, {Rc, Output}) -> check_fail_log(Config, RawLog, Command, Result) -> check_log(Config, RawLog, failure_logger(Command, Result)). -check_log(Config,RawLog,Fun) -> - {ok, Msg} = - rebar_utils:sh("grep -e \"TEST COMPLETE\" -e \"{error,make_failed}\" " - ++ RawLog, [{use_stdout, false}]), - MakeFailed = string:str(Msg, "{error,make_failed}") =/= 0, - RunFailed = string:str(Msg, ", 0 failed") =:= 0, +check_log(Config,RawLogFilename,Fun) -> + %% read the file and split into a list separated by newlines + {ok, RawLog} = file:read_file(RawLogFilename), + Msg = string:tokens(binary_to_list(RawLog), "\n"), + %% now filter out all the list entries that do not have test + %% completion strings + CompleteRuns = lists:filter(fun(M) -> + string:str(M, "TEST COMPLETE") =/= 0 + end, Msg), + MakeFailed = lists:filter(fun(M) -> + string:str(M, "{error,make_failed}") =/= 0 + end, Msg), + %% the run has failed if at least one of the tests failed + RunFailed = lists:foldl(fun(M, Acc) -> + %% the "0 failed" string must be present for + %% the test to be considered successful + TestFailed = string:str(M, "0 failed") =:= 0, + TestFailed orelse Acc + end, false, CompleteRuns), if - MakeFailed -> + MakeFailed =/= [] -> show_log(Config, RawLog), ?ERROR("Building tests failed\n",[]), ?FAIL; @@ -182,8 +200,7 @@ show_log(Config, RawLog) -> ?CONSOLE("Showing log\n", []), case rebar_log:is_verbose(Config) of false -> - {ok, Contents} = file:read_file(RawLog), - ?CONSOLE("~s", [Contents]); + ?CONSOLE("~s", [RawLog]); true -> ok end. |