From a587a9f7eb10691b7da5fcb45f2741c82618142f Mon Sep 17 00:00:00 2001 From: Andrey Teplyashin Date: Sun, 9 Nov 2014 14:04:05 +0600 Subject: Add colored logs Fix verbose level in global rebar config Replace application:set_env on erlang:put --- inttest/logging/logging_rt.erl | 31 ++++++++++++++++++++------ inttest/t_custom_config/t_custom_config_rt.erl | 5 +++-- inttest/tplugins/tplugins_rt.erl | 2 +- 3 files changed, 28 insertions(+), 10 deletions(-) (limited to 'inttest') diff --git a/inttest/logging/logging_rt.erl b/inttest/logging/logging_rt.erl index d3e1c0f..11cb0cd 100644 --- a/inttest/logging/logging_rt.erl +++ b/inttest/logging/logging_rt.erl @@ -40,23 +40,40 @@ run(_Dir) -> SharedExpected = "==> logging_rt \\(compile\\)", %% provoke ERROR due to an invalid app file retest:log(info, "Check 'compile' failure output~n"), + {ERROR, WARN, INFO, DEBUG} = + case application:get_env(rebar, log_colored) of + {ok, true} -> + { + "\\e\\[1m\\e\\[31mERROR: \\e\\[0m", + "\\e\\[33mWARN: \\e\\[0m", + "\\e\\[32mINFO: \\e\\[0m", + "\\e\\[34mDEBUG: \\e\\[0m" + }; + _ -> + { + "ERROR: ", + "WARN: ", + "INFO: ", + "DEBUG: " + } + end, ok = check_output("./rebar compile -q", should_fail, - [SharedExpected, "ERROR: "], - ["WARN: ", "INFO: ", "DEBUG: "]), + [SharedExpected, ERROR], + [WARN, INFO, DEBUG]), %% fix bad app file ok = file:write_file(?APP_FILE, app(logging, [])), retest:log(info, "Check 'compile' success output~n"), ok = check_output("./rebar compile", should_succeed, [SharedExpected], - ["ERROR: ", "WARN: ", "INFO: ", "DEBUG: "]), + [ERROR, WARN, INFO, DEBUG]), retest:log(info, "Check 'compile -v' success output~n"), ok = check_output("./rebar compile -v", should_succeed, [SharedExpected], - ["ERROR: ", "INFO: ", "DEBUG: "]), + [ERROR, INFO, DEBUG]), retest:log(info, "Check 'compile -vv' success output~n"), ok = check_output("./rebar compile -vv", should_succeed, - [SharedExpected, "DEBUG: "], - ["ERROR: ", "INFO: "]), + [SharedExpected, DEBUG], + [ERROR, INFO]), ok. check_output(Cmd, FailureMode, Expected, Unexpected) -> @@ -73,7 +90,7 @@ check_output(Cmd, FailureMode, Expected, Unexpected) -> end. check_output1(Cmd, Captured, Expected, Unexpected) -> - ReOpts = [{capture, all, list}], + ReOpts = [{capture, all, list}, unicode], ExMatches = lists:zf( fun(Pattern) -> diff --git a/inttest/t_custom_config/t_custom_config_rt.erl b/inttest/t_custom_config/t_custom_config_rt.erl index a6aac9b..a373b32 100644 --- a/inttest/t_custom_config/t_custom_config_rt.erl +++ b/inttest/t_custom_config/t_custom_config_rt.erl @@ -15,13 +15,14 @@ run(Dir) -> retest_log:log(debug, "Running in Dir: ~s~n", [Dir]), Ref = retest:sh("./rebar -C custom.config check-deps -vv", [{async, true}]), + {ok, Captured} = retest:sh_expect(Ref, - "DEBUG: Consult config file .*/custom.config.*", + ".*DEBUG: .*Consult config file .*/custom.config.*", [{capture, all, list}]), {ok, Missing} = retest:sh_expect(Ref, - "DEBUG: Missing deps : \\[\\{dep,bad_name," + ".*DEBUG: .*Missing deps : \\[\\{dep,bad_name," "boo,\"\\.\",undefined,false\\}\\]", [{capture, all, list}]), retest_log:log(debug, "[CAPTURED]: ~s~n", [Captured]), diff --git a/inttest/tplugins/tplugins_rt.erl b/inttest/tplugins/tplugins_rt.erl index 997661b..01d296e 100644 --- a/inttest/tplugins/tplugins_rt.erl +++ b/inttest/tplugins/tplugins_rt.erl @@ -24,7 +24,7 @@ run(_Dir) -> ?assertMatch({ok, _}, retest_sh:run("./rebar fwibble -v", [])), ?assertEqual(false, filelib:is_regular("fwibble.test")), Ref = retest:sh("./rebar -C bad.config -v clean", [{async, true}]), - {ok, _} = retest:sh_expect(Ref, "ERROR: Plugin .*bad_plugin.erl " + {ok, _} = retest:sh_expect(Ref, ".*ERROR: .*Plugin .*bad_plugin.erl " "contains compilation errors:.*", [{newline, any}]), ok. -- cgit v1.2.1