From 6304c19180ec2e0c1f00145e86719e228195823a Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Mon, 13 Dec 2010 13:07:33 +0100 Subject: Revert to using awk instead of cut --- priv/templates/simplenode.runner | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'priv') diff --git a/priv/templates/simplenode.runner b/priv/templates/simplenode.runner index cfde552..262cc1e 100755 --- a/priv/templates/simplenode.runner +++ b/priv/templates/simplenode.runner @@ -70,16 +70,16 @@ case "$1" in Linux|Darwin|FreeBSD|DragonFly|NetBSD|OpenBSD) # PID COMMAND PID=`ps ax -o pid= -o command=|\ - grep "$RUNNER_BASE_DIR/.*/[b]eam"|cut -d' ' -f1` + grep "$RUNNER_BASE_DIR/.*/[b]eam"|awk '{print $1}'` ;; SunOS) # PID COMMAND PID=`ps -ef -o pid= -o args=|\ - grep "$RUNNER_BASE_DIR/.*/[b]eam"|cut -d' ' -f1` + grep "$RUNNER_BASE_DIR/.*/[b]eam"|awk '{print $1}'` ;; CYGWIN*) # UID PID PPID TTY STIME COMMAND - PID=`ps -efW|grep "$RUNNER_BASE_DIR/.*/[b]eam"|cut -d' ' -f2` + PID=`ps -efW|grep "$RUNNER_BASE_DIR/.*/[b]eam"|awk '{print $2}'` ;; esac $NODETOOL stop -- cgit v1.1 From 57e593a3190f9de9894f6ae990b26a23bbf32b48 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Fri, 17 Dec 2010 12:39:31 +0100 Subject: Fix possible export VAR=VALUE bashism --- priv/templates/simplenode.runner | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'priv') diff --git a/priv/templates/simplenode.runner b/priv/templates/simplenode.runner index 262cc1e..10c233b 100755 --- a/priv/templates/simplenode.runner +++ b/priv/templates/simplenode.runner @@ -58,7 +58,8 @@ case "$1" in echo "Node is already running!" exit 1 fi - export HEART_COMMAND="$RUNNER_BASE_DIR/bin/$SCRIPT start" + HEART_COMMAND="$RUNNER_BASE_DIR/bin/$SCRIPT start" + export HEART_COMMAND mkdir -p $PIPE_DIR # Note the trailing slash on $PIPE_DIR/ $ERTS_PATH/run_erl -daemon $PIPE_DIR/ $RUNNER_LOG_DIR "exec $RUNNER_BASE_DIR/bin/$SCRIPT console" 2>&1 -- cgit v1.1 From d8e50e8c2d3af9234d27e8e5a652c5575d1493ad Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Thu, 9 Dec 2010 19:45:58 +0100 Subject: Implement update-deps and disable auto update --- priv/shell-completion/bash/rebar | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'priv') diff --git a/priv/shell-completion/bash/rebar b/priv/shell-completion/bash/rebar index 237255c..ead10ff 100644 --- a/priv/shell-completion/bash/rebar +++ b/priv/shell-completion/bash/rebar @@ -10,7 +10,7 @@ _rebar() lopts=" --help --commands --verbose --force --jobs= --version" cmdsnvars="build-plt check-plt check-deps clean compile \ create create-app create-node ct dialyze doc delete-deps eunit \ - get-deps generate help list-templates version xref \ + get-deps generate help list-templates update-deps version xref \ case= debug_info=1 force=1 jobs= suite= verbose=1 appid= \ skip_deps=1 template= template_dir=" -- cgit v1.1 From 6ce2beebd06d046e1d0e912017717753b62fb85a Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Fri, 21 Jan 2011 16:11:07 +0100 Subject: Synchronize nodetool escript with riak version --- priv/templates/simplenode.nodetool | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'priv') diff --git a/priv/templates/simplenode.nodetool b/priv/templates/simplenode.nodetool index 971f983..f4bedff 100644 --- a/priv/templates/simplenode.nodetool +++ b/priv/templates/simplenode.nodetool @@ -30,7 +30,8 @@ main(Args) -> ["reboot"] -> io:format("~p\n", [rpc:call(TargetNode, init, reboot, [], 60000)]); ["rpc", Module, Function | RpcArgs] -> - case rpc:call(TargetNode, list_to_atom(Module), list_to_atom(Function), [RpcArgs], 60000) of + case rpc:call(TargetNode, list_to_atom(Module), list_to_atom(Function), + [RpcArgs], 60000) of ok -> ok; {badrpc, Reason} -> @@ -39,6 +40,15 @@ main(Args) -> _ -> halt(1) end; + ["rpcterms", Module, Function, ArgsAsString] -> + case rpc:call(TargetNode, list_to_atom(Module), list_to_atom(Function), + consult(ArgsAsString), 60000) of + {badrpc, Reason} -> + io:format("RPC to ~p failed: ~p\n", [TargetNode, Reason]), + halt(1); + Other -> + io:format("~p\n", [Other]) + end; Other -> io:format("Other: ~p\n", [Other]), io:format("Usage: nodetool {ping|stop|restart|reboot}\n") @@ -78,3 +88,28 @@ append_node_suffix(Name, Suffix) -> [Node] -> list_to_atom(lists:concat([Node, Suffix, os:getpid()])) end. + + +%% +%% Given a string or binary, parse it into a list of terms, ala file:consult/0 +%% +consult(Str) when is_list(Str) -> + consult([], Str, []); +consult(Bin) when is_binary(Bin)-> + consult([], binary_to_list(Bin), []). + +consult(Cont, Str, Acc) -> + case erl_scan:tokens(Cont, Str, 0) of + {done, Result, Remaining} -> + case Result of + {ok, Tokens, _} -> + {ok, Term} = erl_parse:parse_term(Tokens), + consult([], Remaining, [Term | Acc]); + {eof, _Other} -> + lists:reverse(Acc); + {error, Info, _} -> + {error, Info} + end; + {more, Cont1} -> + consult(Cont1, eof, Acc) + end. -- cgit v1.1 From ac5948d91029fc9875494be72dce022b2f937ff7 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Fri, 21 Jan 2011 16:12:09 +0100 Subject: Add file local variables to nodetool escript --- priv/templates/simplenode.nodetool | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'priv') diff --git a/priv/templates/simplenode.nodetool b/priv/templates/simplenode.nodetool index f4bedff..cb524ce 100644 --- a/priv/templates/simplenode.nodetool +++ b/priv/templates/simplenode.nodetool @@ -1,4 +1,5 @@ -%% -*- erlang -*- +%% -*- mode:erlang;tab-width:4;erlang-indent-level:4;indent-tabs-mode:nil -*- +%% ex: ft=erlang ts=4 sw=4 et %% ------------------------------------------------------------------- %% %% nodetool: Helper Script for interacting with live nodes -- cgit v1.1 From 5298e93a180e6db87a33f26eb6a2db06e8065dc7 Mon Sep 17 00:00:00 2001 From: joewilliams Date: Thu, 27 Jan 2011 18:15:25 +0100 Subject: Add 'generate-upgrade' command To support OTP release upgrades I have added support for building upgrade packages. Support for this is included in the rebar_upgrade module, specifically generate_upgrade/2. It requires one variable to be set on the command line 'previous_release' which is the absolute path or relative path from 'rel/' to the previous release one is upgrading from. Running an upgrade will create the needed files, including a relup and result in a tarball containing the upgrade being written to 'rel/'. When done it cleans up the temporary files systools created. Usage: $ rebar generate-upgrade previous_release=/path/to/old/version This also includes a dummy application that can be used to test upgrades as well as an example. Special thanks to Daniel Reverri, Jesper Louis Andersen and Richard Jones for comments and patches. --- priv/templates/simplenode.runner | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'priv') diff --git a/priv/templates/simplenode.runner b/priv/templates/simplenode.runner index 10c233b..ec6d7ff 100755 --- a/priv/templates/simplenode.runner +++ b/priv/templates/simplenode.runner @@ -117,13 +117,19 @@ case "$1" in $ERTS_PATH/to_erl $PIPE_DIR ;; - console) + console|console_clean) + # .boot file typically just $SCRIPT (ie, the app name) + # however, for debugging, sometimes start_clean.boot is useful: + case "$1" in + console) BOOTFILE=$SCRIPT ;; + console_clean) BOOTFILE=start_clean ;; + esac # Setup beam-required vars ROOTDIR=$RUNNER_BASE_DIR BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin EMU=beam PROGNAME=`echo $0 | sed 's/.*\\///'` - CMD="$BINDIR/erlexec -boot $RUNNER_BASE_DIR/releases/$APP_VSN/$SCRIPT -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 -embedded -config $RUNNER_ETC_DIR/app.config -args_file $RUNNER_ETC_DIR/vm.args -- ${1+"$@"}" export EMU export ROOTDIR export BINDIR -- cgit v1.1 From f4070bfad7a62c12207ad97935567255a3854593 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Fri, 28 Jan 2011 19:10:19 +0100 Subject: Update shell completion: generate-upgrade Add generate-upgrade and previous_release=. --- priv/shell-completion/bash/rebar | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'priv') diff --git a/priv/shell-completion/bash/rebar b/priv/shell-completion/bash/rebar index ead10ff..581ec0d 100644 --- a/priv/shell-completion/bash/rebar +++ b/priv/shell-completion/bash/rebar @@ -10,9 +10,9 @@ _rebar() lopts=" --help --commands --verbose --force --jobs= --version" cmdsnvars="build-plt check-plt check-deps clean compile \ create create-app create-node ct dialyze doc delete-deps eunit \ - get-deps generate help list-templates update-deps version xref \ - case= debug_info=1 force=1 jobs= suite= verbose=1 appid= \ - skip_deps=1 template= template_dir=" + get-deps generate generate-upgrade help list-templates update-deps \ + version xref case= debug_info=1 force=1 jobs= suite= verbose=1 \ + appid= previous_release= skip_deps=1 template= template_dir=" if [[ ${cur} == --* ]] ; then COMPREPLY=( $(compgen -W "${lopts}" -- ${cur}) ) -- cgit v1.1 From b894682ba92baa0f258908cf5dacb5ec0cd14635 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Thu, 20 Jan 2011 18:56:42 +0100 Subject: Fix bug 294 --- priv/templates/simplenode.nodetool | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'priv') diff --git a/priv/templates/simplenode.nodetool b/priv/templates/simplenode.nodetool index cb524ce..0318ca1 100644 --- a/priv/templates/simplenode.nodetool +++ b/priv/templates/simplenode.nodetool @@ -7,6 +7,7 @@ %% ------------------------------------------------------------------- main(Args) -> + ok = start_epmd(), %% Extract the args {RestArgs, TargetNode} = process_args(Args, [], undefined), @@ -73,6 +74,27 @@ process_args([Arg | Rest], Acc, Opts) -> process_args(Rest, [Arg | Acc], Opts). +start_epmd() -> + [] = os:cmd(epmd_path() ++ " -daemon"), + ok. + +epmd_path() -> + ErtsBinDir = filename:dirname(escript:script_name()), + Name = "epmd", + case os:find_executable(Name, ErtsBinDir) of + false -> + case os:find_executable(Name) of + false -> + io:format("Could not find epmd.~n"), + halt(1); + GlobalEpmd -> + GlobalEpmd + end; + Epmd -> + Epmd + end. + + nodename(Name) -> case string:tokens(Name, "@") of [_Node, _Host] -> -- cgit v1.1 From c466076ffb5a1ea4c00d49fefff0dcfbceb58236 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Mon, 31 Jan 2011 17:43:31 +0100 Subject: Clean up emacs file local variables --- priv/templates/simplenode.nodetool | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'priv') diff --git a/priv/templates/simplenode.nodetool b/priv/templates/simplenode.nodetool index 0318ca1..eb08fa4 100644 --- a/priv/templates/simplenode.nodetool +++ b/priv/templates/simplenode.nodetool @@ -1,4 +1,4 @@ -%% -*- mode:erlang;tab-width:4;erlang-indent-level:4;indent-tabs-mode:nil -*- +%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*- %% ex: ft=erlang ts=4 sw=4 et %% ------------------------------------------------------------------- %% -- cgit v1.1 From 1979da9ee21b90799bdbd3f2b5cdec5e5c982a01 Mon Sep 17 00:00:00 2001 From: Joseph Wayne Norton Date: Sat, 12 Feb 2011 23:50:12 +0900 Subject: Clarify trailing slash for PIPE_DIR The trailing slash for PIPE_DIR is necessary for both start and attach operations. --- priv/templates/simplenode.runner | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'priv') diff --git a/priv/templates/simplenode.runner b/priv/templates/simplenode.runner index ec6d7ff..18fa951 100755 --- a/priv/templates/simplenode.runner +++ b/priv/templates/simplenode.runner @@ -7,6 +7,7 @@ RUNNER_SCRIPT_DIR=$(cd ${0%/*} && pwd) RUNNER_BASE_DIR=${RUNNER_SCRIPT_DIR%/*} RUNNER_ETC_DIR=$RUNNER_BASE_DIR/etc RUNNER_LOG_DIR=$RUNNER_BASE_DIR/log +# Note the trailing slash on $PIPE_DIR/ PIPE_DIR=/tmp/$RUNNER_BASE_DIR/ RUNNER_USER= @@ -61,8 +62,7 @@ case "$1" in HEART_COMMAND="$RUNNER_BASE_DIR/bin/$SCRIPT start" export HEART_COMMAND mkdir -p $PIPE_DIR - # Note the trailing slash on $PIPE_DIR/ - $ERTS_PATH/run_erl -daemon $PIPE_DIR/ $RUNNER_LOG_DIR "exec $RUNNER_BASE_DIR/bin/$SCRIPT console" 2>&1 + $ERTS_PATH/run_erl -daemon $PIPE_DIR $RUNNER_LOG_DIR "exec $RUNNER_BASE_DIR/bin/$SCRIPT console" 2>&1 ;; stop) -- cgit v1.1 From 7810d7bf7cebe7062c5850b5f20eeb12cf5e3284 Mon Sep 17 00:00:00 2001 From: Tim Watson Date: Wed, 26 Jan 2011 11:57:22 +0000 Subject: Add common_test suite template This change adds a simple common_test suite template that can be instantiated with the name of a module under test like so: `rebar create template=ctsuite testmod=mymodule` The template creates an empty test suite in the test directory, automatically exports test functions and sets up a first, skipped test function. --- priv/templates/ctsuite.erl | 167 ++++++++++++++++++++++++++++++++++++++++ priv/templates/ctsuite.template | 2 + 2 files changed, 169 insertions(+) create mode 100644 priv/templates/ctsuite.erl create mode 100644 priv/templates/ctsuite.template (limited to 'priv') diff --git a/priv/templates/ctsuite.erl b/priv/templates/ctsuite.erl new file mode 100644 index 0000000..b8fdfe7 --- /dev/null +++ b/priv/templates/ctsuite.erl @@ -0,0 +1,167 @@ +%% common_test suite for {{testmod}} + +-module({{testmod}}_SUITE). +-include_lib("common_test/include/ct.hrl"). + +-compile(export_all). + +%%-------------------------------------------------------------------- +%% Function: suite() -> Info +%% +%% Info = [tuple()] +%% List of key/value pairs. +%% +%% Description: Returns list of tuples to set default properties +%% for the suite. +%% +%% Note: The suite/0 function is only meant to be used to return +%% default data values, not perform any other operations. +%%-------------------------------------------------------------------- +suite() -> [{timetrap, {seconds, 20}}]. + +%%-------------------------------------------------------------------- +%% Function: groups() -> [Group] +%% +%% Group = {GroupName,Properties,GroupsAndTestCases} +%% GroupName = atom() +%% The name of the group. +%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}] +%% Group properties that may be combined. +%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase] +%% TestCase = atom() +%% The name of a test case. +%% Shuffle = shuffle | {shuffle,Seed} +%% To get cases executed in random order. +%% Seed = {integer(),integer(),integer()} +%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail | +%% repeat_until_any_ok | repeat_until_any_fail +%% To get execution of cases repeated. +%% N = integer() | forever +%% +%% Description: Returns a list of test case group definitions. +%%-------------------------------------------------------------------- +groups() -> []. + +%%-------------------------------------------------------------------- +%% Function: all() -> GroupsAndTestCases +%% +%% GroupsAndTestCases = [{group,GroupName} | TestCase] +%% GroupName = atom() +%% Name of a test case group. +%% TestCase = atom() +%% Name of a test case. +%% +%% Description: Returns the list of groups and test cases that +%% are to be executed. +%% +%% NB: By default, we export all 1-arity user defined functions +%%-------------------------------------------------------------------- +all() -> + [ {exports, Functions} | _ ] = ?MODULE:module_info(), + [ FName || {FName, _} <- lists:filter( + fun ({module_info,_}) -> false ; + ({all,_}) -> false ; + ({init_per_suite,1}) -> false ; + ({end_per_suite,1}) -> false ; + ({_,1}) -> true ; + ({_,_}) -> false + end, Functions)]. + +%%-------------------------------------------------------------------- +%% Function: init_per_suite(Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% +%% Config0 = Config1 = [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Reason = term() +%% The reason for skipping the suite. +%% +%% Description: Initialization before the suite. +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_suite(Config0) -> void() | {save_config,Config1} +%% +%% Config0 = Config1 = [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% +%% Description: Cleanup after the suite. +%%-------------------------------------------------------------------- +end_per_suite(_Config) -> + ok. + +%%-------------------------------------------------------------------- +%% Function: init_per_group(GroupName, Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% +%% GroupName = atom() +%% Name of the test case group that is about to run. +%% Config0 = Config1 = [tuple()] +%% A list of key/value pairs, holding configuration data for the group. +%% Reason = term() +%% The reason for skipping all test cases and subgroups in the group. +%% +%% Description: Initialization before each test case group. +%%-------------------------------------------------------------------- +init_per_group(_group, Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_group(GroupName, Config0) -> +%% void() | {save_config,Config1} +%% +%% GroupName = atom() +%% Name of the test case group that is finished. +%% Config0 = Config1 = [tuple()] +%% A list of key/value pairs, holding configuration data for the group. +%% +%% Description: Cleanup after each test case group. +%%-------------------------------------------------------------------- +end_per_group(_group, Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: init_per_testcase(TestCase, Config0) -> +%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1} +%% +%% TestCase = atom() +%% Name of the test case that is about to run. +%% Config0 = Config1 = [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Reason = term() +%% The reason for skipping the test case. +%% +%% Description: Initialization before each test case. +%% +%% Note: This function is free to add any key/value pairs to the Config +%% variable, but should NOT alter/remove any existing entries. +%%-------------------------------------------------------------------- +init_per_testcase(TestCase, Config) -> + Config. + +%%-------------------------------------------------------------------- +%% Function: end_per_testcase(TestCase, Config0) -> +%% void() | {save_config,Config1} | {fail,Reason} +%% +%% TestCase = atom() +%% Name of the test case that is finished. +%% Config0 = Config1 = [tuple()] +%% A list of key/value pairs, holding the test case configuration. +%% Reason = term() +%% The reason for failing the test case. +%% +%% Description: Cleanup after each test case. +%%-------------------------------------------------------------------- +end_per_testcase(TestCase, Config) -> + Config. + +test_{{testmod}}() -> + [{userdata,[{doc,"Testing the {{testmod}} module"}]}]. + +test_{{testmod}}(_Config) -> + {skip,"Not implemented."}. diff --git a/priv/templates/ctsuite.template b/priv/templates/ctsuite.template new file mode 100644 index 0000000..b7de337 --- /dev/null +++ b/priv/templates/ctsuite.template @@ -0,0 +1,2 @@ +{variables, [{testmod, "mymodule"}]}. +{template, "ctsuite.erl", "test/{{testmod}}_SUITE.erl"}. -- cgit v1.1 From 1b1080719399cc952d244fbe68b0e53bc3e213d3 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Tue, 15 Feb 2011 17:26:01 +0100 Subject: Remove gratuitous spaces --- priv/templates/ctsuite.erl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'priv') diff --git a/priv/templates/ctsuite.erl b/priv/templates/ctsuite.erl index b8fdfe7..33a8fac 100644 --- a/priv/templates/ctsuite.erl +++ b/priv/templates/ctsuite.erl @@ -59,11 +59,11 @@ groups() -> []. all() -> [ {exports, Functions} | _ ] = ?MODULE:module_info(), [ FName || {FName, _} <- lists:filter( - fun ({module_info,_}) -> false ; - ({all,_}) -> false ; - ({init_per_suite,1}) -> false ; - ({end_per_suite,1}) -> false ; - ({_,1}) -> true ; + fun ({module_info,_}) -> false; + ({all,_}) -> false; + ({init_per_suite,1}) -> false; + ({end_per_suite,1}) -> false; + ({_,1}) -> true; ({_,_}) -> false end, Functions)]. -- cgit v1.1