From 93468c962073ae82397a0582530d3eec0ff7ef11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingy=20d=C3=B6t=20Net?= Date: Fri, 20 Feb 2015 07:01:58 -0800 Subject: [PATCH] Make tests better Tests show errors and provide a way to clone needed repos. Add Acme-MITHALDU-XSGrabBag to tests --- test/devel/test-inline-modules.t | 16 +++++++++++++ test/devel/test-module.sh | 40 ++++++++++++++++++++++++-------- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/test/devel/test-inline-modules.t b/test/devel/test-inline-modules.t index f282c36..9c92a58 100644 --- a/test/devel/test-inline-modules.t +++ b/test/devel/test-inline-modules.t @@ -9,6 +9,7 @@ source "$dir/test-module.sh" # Default testing values: { test_dir=acme-math-xs-pm + test_author=ingydotnet test_repo_url=$TEST_HOME/../acme-math-xs-pm/.git test_prove_run=('prove -lv t/') test_test_run=('perl Makefile.PL' 'make test') @@ -129,6 +130,20 @@ s-s() { test_module } +a-m-x() { + local test_dir=Acme-MITHALDU-XSGrabBag + local test_author=wchristian + local test_repo_url=$TEST_HOME/../Acme-MITHALDU-XSGrabBag/.git + local test_dist=Acme-MITHALDU-XSGrabBag + local test_branch='master' + local test_dist_files=( + MANIFEST + lib/Acme/MITHALDU/XSGrabBag/Inline.pm + lib/Acme/MITHALDU/XSGrabBag.pm + ) + test_module +} + # You can run specific tests like this: # prove -v test/devel/test-inline-modules.t :: dz cpp d-g-xs if [ $# -gt 0 ]; then @@ -148,6 +163,7 @@ else d-g-xs u-t s-s + a-m-x fi done_testing; diff --git a/test/devel/test-module.sh b/test/devel/test-module.sh index 8aa10c8..a1f6739 100644 --- a/test/devel/test-module.sh +++ b/test/devel/test-module.sh @@ -1,10 +1,30 @@ #!/usr/bin/env bash test_module() { - [ -n "$test_dir" ] || die - [ -e "$test_dir" ] || + [ -n "$test_dir" ] || die "'\$test_dir' not set" + if [ ! -e "$test_dir" ]; then + if [ ! -e "$test_repo_url" ]; then + local github_repo="https://github.com/$test_author/$test_dir" + local test_repo="${test_repo_url%/.git}" + if [ -z "$CLONE_OK" ]; then + cat <<... +The repo '$test_repo' is missing. Either run: + + git clone $github_repo $test_repo + +or rerun this command with the env var: + + CLONE_OK=1 + +… +... + exit 1 + fi + git clone "$github_repo" "$test_repo" + fi git clone $test_repo_url &>/dev/null - [ -e "$test_dir" ] || die + fi + [ -e "$test_dir" ] || die "'$test_dir' does not exist" local test_home="$(pwd)" if [ -n "$test_inline_build_dir" ]; then inline_module=true @@ -19,7 +39,7 @@ test_module() { { for cmd in "${test_prove_run[@]}"; do - $cmd &>>out + $cmd &>>out || die "$(cat out)" done pass "Acme::Math::XS ($test_branch) passes its tests w/ prove" if $inline_module; then @@ -32,7 +52,7 @@ test_module() { git clean -dxf &>/dev/null if [ -n "$test_test_run" ]; then for cmd in "${test_test_run[@]}"; do - $cmd &>>out + $cmd &>>out || die "$(cat out)" done pass "Acme::Math::XS ($test_branch) passes its test runner" fi @@ -41,7 +61,7 @@ test_module() { { git clean -dxf &>/dev/null for cmd in "${test_make_distdir[@]}"; do - $cmd &>>out + $cmd &>>out || die "$(cat out)" done dd=( $test_dist-* ) [ -n "$dd" ] || die @@ -57,11 +77,11 @@ test_module() { ( cd $dd if [ -e Build.PL ]; then - perl Build.PL &>>../out - ./Build test &>>../out + perl Build.PL &>>../out || die "$(cat out)" + ./Build test &>>../out || die "$(cat out)" else - perl Makefile.PL &>>../out - make test &>>../out + perl Makefile.PL &>>../out || die "$(cat out)" + make test &>>../out || die "$(cat out)" fi ) pass "$dd passes its tests"