0
我在工作场所刚刚'继承'了一个OTP项目,并且遇到以下问题: 一组测试包括调用使用os的函数: cmd,这似乎是测试失败的原因,这是我在失败和成功测试之间唯一的区别。我正在Mac OS X 10.6.8和Erlang 14A上运行测试。在Mac OSX中包含调用os:cmd失败的eurls 10.6
这些失败的功能:
execute_shell_command(Config, Event, Params, output) ->
execute_with_output(Config, Event, Params);
execute_shell_command(Config, Event, Params, status) ->
execute_with_status(Config, Event, Params).
execute_with_output(Config, Event, Params) ->
Command = executable(Config, Event),
String = string:join([Command|Params], " "),
error_logger:info_msg("Command to be invoked:~n~p", [String]),
os:cmd(String).
及以下的测试失败:
execute_with_output_test() ->
Config = [{click, [{log_path, "fixtures"}, {executable, "echo"}]},
{processing_stat_path, "fixtures"}],
?assertMatch("OK", execute_with_output(Config, click, ["-n", "OK"])).
execute_with_output_success_test() ->
Config = [{click, [{log_path, "fixtures"}, {executable, "true"}]},
{processing_stat_path, "fixtures"}],
?assertMatch("success", execute_with_output(Config, click,
[status_as_output_suffix()])).
execute_with_output_failure_test() ->
Config = [{click, [{log_path, "fixtures"}, {executable, "false"}]},
{processing_stat_path, "fixtures"}],
?assertMatch("error", execute_with_output(Config, click,
[status_as_output_suffix()])).
execute_with_status_success_test() ->
Config = [{click, [{log_path, "fixtures"}, {executable, "true"}]},
{processing_stat_path, "fixtures"}],
?assertMatch(ok, execute_with_status(Config, click, [])).
execute_with_status_failure_test() ->
Config = [{click, [{log_path, "fixtures"}, {executable, "false"}]},
{processing_stat_path, "fixtures"}],
?assertMatch(error, execute_with_status(Config, click, [])).
hdfs_put_command_parameters_echoed_test() ->
Config = [{click, [{log_path, "fixtures"},
{executable, "echo -n"},
{delete_after_copy, false},
{hdfs_url, "hdfs://localhost/unprocessed/clicks"}]},
{processing_stat_path, "fixtures"}],
{ok, Hostname} = inet:gethostname(),
Expected = "fs -put test_file hdfs://localhost/unprocessed/clicks/" ++ Hostname ++ "-test_file",
?assertMatch(Expected, hdfs_put_command(Config, click, "test_file", output)).
click_upload_success_test() ->
Config = [{click, [{log_path, "fixtures"},
{executable, "fixtures/hadoop_mock_success"},
{delete_after_copy, false},
{hdfs_url, "hdfs://testhost"}]},
{processing_state_path, "fixtures"}],
unconsult(configuration_file(test), Config),
Callback = click_upload(test),
?assertMatch([ok, ok], Callback(click, test_message)),
write_last_processed(Config, click, "click-2009-04-10-17-00").
测试套件的输出
erl -noshell -setcookie colonel_hathi -sname test_units_talkative_client -eval 'error_logger:tty(false).' -pa ./ebin -eval 'case lists:member({test,0}, hdfs_loader:module_info(exports)) of true -> hdfs_loader:test(); false -> io:format(" [No test in ~p]~n", [hdfs_loader]) end' -eval 'case lists:member({test,0}, talkative_client_app:module_info(exports)) of true -> talkative_client_app:test(); false -> io:format(" [No test in ~p]~n", [talkative_client_app]) end' -eval 'case lists:member({test,0}, talkative_client_connection:module_info(exports)) of true -> talkative_client_connection:test(); false -> io:format(" [No test in ~p]~n", [talkative_client_connection]) end' -eval 'case lists:member({test,0}, talkative_client_control:module_info(exports)) of true -> talkative_client_control:test(); false -> io:format(" [No test in ~p]~n", [talkative_client_control]) end' -eval 'case lists:member({test,0}, talkative_client_sup:module_info(exports)) of true -> talkative_client_sup:test(); false -> io:format(" [No test in ~p]~n", [talkative_client_sup]) end' -s init stop
hdfs_loader: execute_with_output_test...*failed*
::error:{assertMatch_failed,
[{module,hdfs_loader},
{line,310},
{expression,
"execute_with_output (Config , click , [ \"-n\" , \"OK\" ])"},
{expected,"\"OK\""},
{value,"-n OK\n"}]}
in function hdfs_loader:'-execute_with_output_test/0-fun-0-'/0
hdfs_loader: execute_with_output_success_test...*failed*
::error:{assertMatch_failed,
[{module,hdfs_loader},
{line,315},
{expression,
"execute_with_output (Config , click , [ status_as_output_suffix () ])"},
{expected,"\"success\""},
{value,"-n success\n"}]}
in function hdfs_loader:'-execute_with_output_success_test/0-fun-0-'/0
hdfs_loader: execute_with_output_failure_test...*failed*
::error:{assertMatch_failed,
[{module,hdfs_loader},
{line,321},
{expression,
"execute_with_output (Config , click , [ status_as_output_suffix () ])"},
{expected,"\"error\""},
{value,"-n error\n"}]}
in function hdfs_loader:'-execute_with_output_failure_test/0-fun-0-'/0
hdfs_loader: execute_with_status_success_test...*failed*
::error:{assertMatch_failed,
[{module,hdfs_loader},
{line,327},
{expression,"execute_with_status (Config , click , [ ])"},
{expected,"ok"},
{value,"-n success\n"}]}
in function hdfs_loader:'-execute_with_status_success_test/0-fun-0-'/0
hdfs_loader: execute_with_status_failure_test...*failed*
::error:{assertMatch_failed,
[{module,hdfs_loader},
{line,332},
{expression,"execute_with_status (Config , click , [ ])"},
{expected,"error"},
{value,"-n error\n"}]}
in function hdfs_loader:'-execute_with_status_failure_test/0-fun-0-'/0
hdfs_loader: hdfs_put_command_parameters_echoed_test...*failed*
::error:{assertMatch_failed,
[{module,hdfs_loader},
{line,342},
{expression,
"hdfs_put_command (Config , click , \"test_file\" , output)"},
{expected,"Expected"},
{value,
"-n fs -put test_file hdfs://localhost/unprocessed/clicks/ws-dhcp_3_156-test_file\n"}]}
in function hdfs_loader:'-hdfs_put_command_parameters_echoed_test/0-fun-0-'/1
hdfs_loader: click_upload_success_test...*failed*
::error:{assertMatch_failed,[{module,hdfs_loader},
{line,352},
{expression,"Callback (click , test_message)"},
{expected,"[ ok , ok ]"},
{value,[error,error]}]}
in function hdfs_loader:'-click_upload_success_test/0-fun-0-'/1
in call from hdfs_loader:click_upload_success_test/0
=======================================================
Failed: 7. Skipped: 0. Passed: 17.
All 5 tests passed.
All 46 tests passed.
[No test in talkative_client_control]
rake aborted!
Tests failed
任何帮助表示赞赏!
运行测试的实际输出将会很有帮助。 – 2012-02-22 10:06:58
只需将其添加到原始帖子中即可。谢谢 – 2012-02-22 14:27:07