Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 98 lines (78 sloc) 2.264 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
#!/bin/sh
# -*- tab-width:4;indent-tabs-mode:nil -*-
# ex: ts=4 sw=4 etSRC_DIR=/Users/benoitc/refuge/couchdb

RUNNER_SCRIPT_DIR={{runner_script_dir}}
RUNNER_SCRIPT=${0##*/}


RUNNER_BASE_DIR={{runner_base_dir}}
RUNNER_ETC_DIR={{runner_etc_dir}}
RUNNER_LOG_DIR={{runner_log_dir}}

# Make sure CWD is set to runner base dir
cd $RUNNER_BASE_DIR

# Extract the target node name from node.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 '^-setcookie' $RUNNER_ETC_DIR/vm.args`
if [ -z "$COOKIE_ARG" ]; then
echo "vm.args needs to have a -setcookie parameter."
    exit 1
fi

# Parse out release and erts info
START_ERL=`cat $RUNNER_BASE_DIR/releases/start_erl.data`
ERTS_VSN=${START_ERL% *}
APP_VSN=${START_ERL#* }

# Add ERTS bin dir to our path
ERTS_PATH=$RUNNER_BASE_DIR/erts-$ERTS_VSN/bin
SCRIPT_DIR=$RUNNER_BASE_DIR/share/www/script
JS_TEST_DIR=$RUNNER_BASE_DIR/test/javascript
COUCH_URI=$RUNNER_BASE_DIR/test/couch.uri

COUCHJS=$RUNNER_BASE_DIR/bin/couchjs
COUCHBIN=$RUNNER_BASE_DIR/bin/couch_dev
NODETOOL="$ERTS_PATH/escript $ERTS_PATH/nodetool $NAME_ARG $COOKIE_ARG"


if [ "$#" -eq 0 ];
then
TEST_SRC="$SCRIPT_DIR/test/*.js"
else
TEST_SRC="$1"
    if [ ! -f $TEST_SRC ]; then
TEST_SRC="$SCRIPT_DIR/test/$1"
        if [ ! -f $TEST_SRC ]; then
TEST_SRC="$SCRIPT_DIR/test/$1.js"
            if [ ! -f $TEST_SRC ]; then
echo "file $1 does not exist"
                exit 1
            fi
fi
fi
fi


STARTED=`$NODETOOL ping`
# stop couch if needed
if [ "$STARTED" = "pong" ]; then
    $COUCHBIN stop
fi

# start a new couch instance
$COUCHBIN start
sleep 1 # give it a sec

# start the tests
echo "http://127.0.0.1:{{couchdb_port}}/" > $COUCH_URI

$COUCHJS -H -u $COUCH_URI \
$SCRIPT_DIR/json2.js \
$SCRIPT_DIR/sha1.js \
$SCRIPT_DIR/oauth.js \
$SCRIPT_DIR/couch.js \
$SCRIPT_DIR/couch_test_runner.js \
$SCRIPT_DIR/couch_tests.js \
$TEST_SRC \
$JS_TEST_DIR/couch_http.js \
$JS_TEST_DIR/cli_runner.js
RESULT=$?

STARTED=`$NODETOOL ping`

if [ "$STARTED" = "pong" ]; then
# stop CouchDB
$COUCHBIN stop
trap - 0
fi

exit $RESULT
Something went wrong with that request. Please try again.