diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/rebar_eunit_tests.erl | 33 | ||||
-rw-r--r-- | test/rebar_file_utils_tests.erl | 3 | ||||
-rw-r--r-- | test/upgrade_project/rel/files/app.config | 3 | ||||
-rwxr-xr-x | test/upgrade_project/rel/files/dummy | 34 | ||||
-rwxr-xr-x | test/upgrade_project/rel/files/erl | 2 | ||||
-rw-r--r-- | test/upgrade_project/rel/files/vm.args | 1 |
6 files changed, 48 insertions, 28 deletions
diff --git a/test/rebar_eunit_tests.erl b/test/rebar_eunit_tests.erl index 57a337a..9af1e58 100644 --- a/test/rebar_eunit_tests.erl +++ b/test/rebar_eunit_tests.erl @@ -51,13 +51,13 @@ eunit_test_() -> fun(RebarOut) -> [{"Tests in 'test' directory are found and run", ?_assert(string:str(RebarOut, "myapp_mymod_tests:") =/= 0)}, - + {"Tests in 'src' directory are found and run", ?_assert(string:str(RebarOut, "myapp_mymod:") =/= 0)}, - + {"Tests are only run once", ?_assert(string:str(RebarOut, "All 2 tests passed") =/= 0)}] - end}. + end}. cover_test_() -> {"Ensure Cover runs with tests in a test dir and no defined suite", @@ -67,7 +67,7 @@ cover_test_() -> [{"All cover reports are generated", assert_files_in("the temporary eunit directory", expected_cover_generated_files())}, - + {"Only production modules get coverage reports", assert_files_not_in("the temporary eunit directory", [".eunit/myapp_mymod_tests.COVER.html"])}]}. @@ -115,7 +115,7 @@ environment_test_() -> {"Sanity check the testing environment", setup, fun make_tmp_dir/0, fun remove_tmp_dir/1, - [{"Ensure a test project can be created", + [{"Ensure a test project can be created", ?_assert(filelib:is_dir(?TMP_DIR))}, {"Ensure the rebar script can be found, copied, and run", @@ -134,21 +134,22 @@ basic_setup_test_() -> %% Test the setup function assert_dirs_in("Basic Project", ["src", "ebin", "test"]) ++ - assert_files_in("Basic Project", - ["test/myapp_mymod_tests.erl", "src/myapp_mymod.erl"])}. + assert_files_in("Basic Project", + ["test/myapp_mymod_tests.erl", + "src/myapp_mymod.erl"])}. %% ==================================================================== %% Setup and Teardown %% ==================================================================== --define(myapp_mymod, +-define(myapp_mymod, ["-module(myapp_mymod).\n", "-export([myfunc/0]).\n", "-include_lib(\"eunit/include/eunit.hrl\").\n", "myfunc() -> ok.\n", "myprivate_test() -> ?assert(true).\n"]). --define(myapp_mymod_tests, +-define(myapp_mymod_tests, ["-module(myapp_mymod_tests).\n", "-compile([export_all]).\n", "-include_lib(\"eunit/include/eunit.hrl\").\n", @@ -160,7 +161,7 @@ basic_setup_test_() -> "-include_lib(\"eunit/include/eunit.hrl\").\n", "all_test_() -> [myapp_mymod_defined_in_mysuite_tests].\n"]). --define(myapp_mymod_defined_in_mysuite_tests, +-define(myapp_mymod_defined_in_mysuite_tests, ["-module(myapp_mymod_defined_in_mysuite_tests).\n", "-compile([export_all]).\n", "-include_lib(\"eunit/include/eunit.hrl\").\n", @@ -200,7 +201,7 @@ teardown(_) -> remove_tmp_dir() -> remove_tmp_dir(arg_for_eunit). -remove_tmp_dir(_) -> +remove_tmp_dir(_) -> case os:type() of {unix, _} -> os:cmd("rm -rf " ++ ?TMP_DIR ++ " 2>/dev/null"); @@ -227,22 +228,22 @@ rebar() -> rebar(Args) when is_list(Args) -> Out = os:cmd(filename:nativename("./rebar") ++ " " ++ Args), - %?debugMsg("**** Begin"), ?debugMsg(Out), ?debugMsg("**** End"), + %% ?debugMsg("**** Begin"), ?debugMsg(Out), ?debugMsg("**** End"), Out. assert_dirs_in(Name, [Dir|T]) -> [{Name ++ " has directory: " ++ Dir, ?_assert(filelib:is_dir(Dir))} | - assert_dirs_in(Name, T)]; + assert_dirs_in(Name, T)]; assert_dirs_in(_, []) -> []. assert_files_in(Name, [File|T]) -> [{Name ++ " has file: " ++ File, ?_assert(filelib:is_regular(File))} | - assert_files_in(Name, T)]; + assert_files_in(Name, T)]; assert_files_in(_, []) -> []. assert_files_not_in(Name, [File|T]) -> - [{Name ++ " does not have file: " ++ File, ?_assertNot(filelib:is_regular(File))} | - assert_files_not_in(Name, T)]; + [{Name ++ " does not have file: " ++ File, + ?_assertNot(filelib:is_regular(File))} | assert_files_not_in(Name, T)]; assert_files_not_in(_, []) -> []. assert_full_coverage(Mod) -> diff --git a/test/rebar_file_utils_tests.erl b/test/rebar_file_utils_tests.erl index ea8ccf9..26a6f9f 100644 --- a/test/rebar_file_utils_tests.erl +++ b/test/rebar_file_utils_tests.erl @@ -225,7 +225,8 @@ mv_file_test_() -> end, fun teardown/1, [?_assert(filelib:is_regular(filename:join([?TMP_DIR,"dest","file1"]))), - ?_assertNot(filelib:is_regular(filename:join([?TMP_DIR,"source","file1"])))]}. + ?_assertNot(filelib:is_regular( + filename:join([?TMP_DIR,"source","file1"])))]}. %% ==================================================================== %% Utilities diff --git a/test/upgrade_project/rel/files/app.config b/test/upgrade_project/rel/files/app.config index 25a3bb3..3b7f6bd 100644 --- a/test/upgrade_project/rel/files/app.config +++ b/test/upgrade_project/rel/files/app.config @@ -6,5 +6,6 @@ {error_logger_mf_dir, "log/sasl"}, % Log directory {error_logger_mf_maxbytes, 10485760}, % 10 MB max file size {error_logger_mf_maxfiles, 5} % 5 files max - ]} + ]} ]. + diff --git a/test/upgrade_project/rel/files/dummy b/test/upgrade_project/rel/files/dummy index 43dce0f..bacce8d 100755 --- a/test/upgrade_project/rel/files/dummy +++ b/test/upgrade_project/rel/files/dummy @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # -*- tab-width:4;indent-tabs-mode:nil -*- # ex: ts=4 sw=4 et @@ -23,14 +23,14 @@ cd $RUNNER_BASE_DIR mkdir -p $RUNNER_LOG_DIR # Extract the target node name from node.args -NAME_ARG=`grep -e '-[s]*name' $RUNNER_ETC_DIR/vm.args` +NAME_ARG=`egrep '^-s?name' $RUNNER_ETC_DIR/vm.args` if [ -z "$NAME_ARG" ]; then echo "vm.args needs to have either -name or -sname parameter." exit 1 fi # Extract the target cookie -COOKIE_ARG=`grep -e '-setcookie' $RUNNER_ETC_DIR/vm.args` +COOKIE_ARG=`grep '^-setcookie' $RUNNER_ETC_DIR/vm.args` if [ -z "$COOKIE_ARG" ]; then echo "vm.args needs to have a -setcookie parameter." exit 1 @@ -62,7 +62,8 @@ case "$1" in HEART_COMMAND="$RUNNER_BASE_DIR/bin/$SCRIPT start" export HEART_COMMAND mkdir -p $PIPE_DIR - $ERTS_PATH/run_erl -daemon $PIPE_DIR $RUNNER_LOG_DIR "exec $RUNNER_BASE_DIR/bin/$SCRIPT console" 2>&1 + shift # remove $1 + $ERTS_PATH/run_erl -daemon $PIPE_DIR $RUNNER_LOG_DIR "exec $RUNNER_BASE_DIR/bin/$SCRIPT console $@" 2>&1 ;; stop) @@ -84,6 +85,10 @@ case "$1" in ;; esac $NODETOOL stop + ES=$? + if [ "$ES" -ne 0 ]; then + exit $ES + fi while `kill -0 $PID 2>/dev/null`; do sleep 1 @@ -93,28 +98,41 @@ case "$1" in restart) ## Restart the VM without exiting the process $NODETOOL restart + ES=$? + if [ "$ES" -ne 0 ]; then + exit $ES + fi ;; reboot) ## Restart the VM completely (uses heart to restart it) $NODETOOL reboot + ES=$? + if [ "$ES" -ne 0 ]; then + exit $ES + fi ;; ping) ## See if the VM is alive $NODETOOL ping + ES=$? + if [ "$ES" -ne 0 ]; then + exit $ES + fi ;; attach) # Make sure a node IS running RES=`$NODETOOL ping` - if [ "$RES" != "pong" ]; then + ES=$? + if [ "$ES" -ne 0 ]; then echo "Node is not running!" - exit 1 + exit $ES fi shift - $ERTS_PATH/to_erl $PIPE_DIR + exec $ERTS_PATH/to_erl $PIPE_DIR ;; console|console_clean) @@ -129,7 +147,7 @@ case "$1" in BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin EMU=beam PROGNAME=`echo $0 | sed 's/.*\\///'` - CMD="$BINDIR/erlexec -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$BOOTFILE -embedded -config $RUNNER_ETC_DIR/app.config -args_file $RUNNER_ETC_DIR/vm.args -- ${1+"$@"}" + CMD="$BINDIR/erlexec -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$BOOTFILE -mode embedded -config $RUNNER_ETC_DIR/app.config -args_file $RUNNER_ETC_DIR/vm.args -- ${1+"$@"}" export EMU export ROOTDIR export BINDIR diff --git a/test/upgrade_project/rel/files/erl b/test/upgrade_project/rel/files/erl index b985f23..6f65e3f 100755 --- a/test/upgrade_project/rel/files/erl +++ b/test/upgrade_project/rel/files/erl @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh ## This script replaces the default "erl" in erts-VSN/bin. This is necessary ## as escript depends on erl and in turn, erl depends on having access to a diff --git a/test/upgrade_project/rel/files/vm.args b/test/upgrade_project/rel/files/vm.args index 7448fb1..2d64e25 100644 --- a/test/upgrade_project/rel/files/vm.args +++ b/test/upgrade_project/rel/files/vm.args @@ -1,4 +1,3 @@ - ## Name of the node -name dummy@127.0.0.1 |