diff --git a/.travis.yml b/.travis.yml index 6a857799..db2fdcef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,4 @@ compiler: before_install: - sudo apt-get install libboost-regex1.48-dev install: script/configure.sh -D USE_BOOST_REGEX -script: script/test.sh +script: script/test_all.sh diff --git a/script/test.sh b/script/test.sh deleted file mode 100755 index 1a8ecbce..00000000 --- a/script/test.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -set -e - -make compiler_specs -time out/Default/compiler_specs - -make runtime_specs -time out/Default/runtime_specs diff --git a/script/test_all.sh b/script/test_all.sh new file mode 100755 index 00000000..8846b489 --- /dev/null +++ b/script/test_all.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -e + +script/test_compiler.sh +script/test_runtime.sh diff --git a/script/test_compiler.sh b/script/test_compiler.sh new file mode 100755 index 00000000..18d43188 --- /dev/null +++ b/script/test_compiler.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e -u + +make compiler_specs +source `dirname $0`/util/run_tests.sh +run_tests out/Default/compiler_specs "$@" diff --git a/script/test_runtime.sh b/script/test_runtime.sh new file mode 100755 index 00000000..9a5a503a --- /dev/null +++ b/script/test_runtime.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e -u + +make runtime_specs +source `dirname $0`/util/run_tests.sh +run_tests out/Default/runtime_specs "$@" diff --git a/script/util/run_tests.sh b/script/util/run_tests.sh new file mode 100644 index 00000000..74a15aff --- /dev/null +++ b/script/util/run_tests.sh @@ -0,0 +1,37 @@ +function run_tests { + local cmd=$1 + shift + + local debug= + local args= + + while getopts "dvf:" option; do + case ${option} in + d) + debug=true + ;; + f) + args="$args --only='${OPTARG}'" + ;; + v) + args="$args --reporter=spec" + ;; + *) + exit + ;; + esac + done + + if [[ -n $debug ]]; then + if which -s gdb; then + eval gdb $cmd -- $args + elif which -s lldb; then + eval lldb $cmd -- $args + else + echo "No debugger found" + exit 1 + fi + else + eval time $cmd $args + fi +} diff --git a/spec/compiler/compiler_specs.cc b/spec/compiler/compiler_specs.cc index e4bbd479..5ecb47a8 100644 --- a/spec/compiler/compiler_specs.cc +++ b/spec/compiler/compiler_specs.cc @@ -1,11 +1,5 @@ #include "compiler/compiler_spec_helper.h" int main(int argc, char *argv[]) { - const char *args[] = { - "", - "--no-color", - "--only=" - "" - }; - return bandit::run(4, const_cast(args)); + return bandit::run(argc, argv); } diff --git a/spec/runtime/runtime_specs.cc b/spec/runtime/runtime_specs.cc index b5f5acb5..85b84012 100644 --- a/spec/runtime/runtime_specs.cc +++ b/spec/runtime/runtime_specs.cc @@ -1,11 +1,5 @@ #include "runtime/runtime_spec_helper.h" int main(int argc, char *argv[]) { - const char *args[] = { - "", - "--no-color", - "--only=" - "" - }; - return bandit::run(4, const_cast(args)); + return bandit::run(argc, argv); }