summaryrefslogtreecommitdiff
path: root/tools/build/v2/test/engine/test.sh
blob: 5c092836a79f6958a4a6ecae3d20ae96b6200c56 (plain)
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
#!/bin/sh

#~ Copyright 2006-2008 Rene Rivera.
#~ Distributed under the Boost Software License, Version 1.0.
#~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)

#~ BJAM=bjam
#~ BJAM_SRC=../src
#~ BJAM_BIN=`ls -1 ${BJAM_SRC}/bin.*/bjam`

# Run a command, and echo before doing so. Also checks the exit
# status and quits if there was an error.
echo_run ()
{
    echo "$@"
    $@
    r=$?
    if test $r -ne 0 ; then
        exit $r
    fi
}

# Check that a command is in the PATH.
test_path ()
{
    if `command -v command 1>/dev/null 2>/dev/null`; then
        command -v $1 1>/dev/null 2>/dev/null
    else
        hash $1 1>/dev/null 2>/dev/null
    fi
}

Guess_BJAM ()
{
    if test_path bjam ; then BJAM=bjam
    elif test -r ./bjam ; then BJAM=./bjam
    elif test -r "${BJAM_BIN}" ; then BJAM="${BJAM_BIN}"
    fi
}

Build_BJAM_To_Test ()
{
    cwd=`pwd`
    if test "${BJAM_SRC}" = "" ; then BJAM_SRC=../src ; fi
    cd "${BJAM_SRC}"
    ./build.sh
    if test "${BJAM_BIN}" = "" ; then BJAM_BIN=`ls -1 ${BJAM_SRC}/bin.*/bjam` ; fi
    cd "${cwd}"
}

Build_BJAM_To_Test
Guess_BJAM
echo_run "${BJAM}" -f test.jam "-sBJAM=${BJAM_BIN}" "$@"