Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make tests better
Tests show errors and provide a way to clone needed repos.

Add Acme-MITHALDU-XSGrabBag to tests
  • Loading branch information
ingydotnet committed Feb 20, 2015
1 parent a420690 commit 17416a5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 10 deletions.
16 changes: 16 additions & 0 deletions test/devel/test-inline-modules.t
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand All @@ -148,6 +163,7 @@ else
d-g-xs
u-t
s-s
a-m-x
fi

done_testing;
Expand Down
40 changes: 30 additions & 10 deletions 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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit 17416a5

Please sign in to comment.