From 4146c9e22c1ad57769fa11357d38608cb1c811aa Mon Sep 17 00:00:00 2001 From: Ian O'Connell Date: Thu, 28 Jul 2016 16:18:25 -0700 Subject: [PATCH] Add better outputs about test progress and success (#82) * Update test rules * Fix repl test --- test_run.sh | 55 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/test_run.sh b/test_run.sh index 27340ebca..d61a98391 100755 --- a/test_run.sh +++ b/test_run.sh @@ -52,23 +52,46 @@ test_transitive_deps() { } test_repl() { - echo "import scala.test._; HelloLib.printMessage(\"foo\")" | bazel-bin/test/HelloLibRepl | grep "foo scala" && + echo "import scala.test._; HelloLib.printMessage(\"foo\")" | bazel-bin/test/HelloLibRepl | grep "foo java" && echo "import scala.test._; TestUtil.foo" | bazel-bin/test/HelloLibTestRepl | grep "bar" && echo "import scala.test._; ScalaLibBinary.main(Array())" | bazel-bin/test/ScalaLibBinaryRepl | grep "A hui hou" } -bazel build test/... \ - && bazel run test:ScalaBinary \ - && bazel run test:ScalaLibBinary \ - && bazel run test:JavaBinary \ - && bazel run test:JavaBinary2 \ - && bazel run test:MixJavaScalaLibBinary \ - && bazel run test/src/main/scala/scala/test/twitter_scrooge:justscrooges \ - && bazel test test/... \ - && find -L ./bazel-testlogs -iname "*.xml" \ - && (find -L ./bazel-testlogs -iname "*.xml" | xargs -n1 xmllint > /dev/null) \ - && test_disappearing_class \ - && test_build_is_identical \ - && test_transitive_deps \ - && test_repl \ - && echo "all good" +NC='\033[0m' +GREEN='\033[0;32m' +RED='\033[0;31m' + +function run_test() { + set +e + TEST_ARG=$@ + echo "running test $TEST_ARG" + RES=$($TEST_ARG 2>&1) + RESPONSE_CODE=$? + if [ $RESPONSE_CODE -eq 0 ]; then + echo -e "${GREEN} Test $TEST_ARG successful $NC" + else + echo $RES + echo -e "${RED} Test $TEST_ARG failed $NC" + exit $RESPONSE_CODE + fi +} + +xmllint_test() { + find -L ./bazel-testlogs -iname "*.xml" | xargs -n1 xmllint > /dev/null +} +run_test bazel build test/... +run_test bazel test test/... +run_test bazel run test/src/main/scala/scala/test/twitter_scrooge:justscrooges +run_test bazel run test:JavaBinary +run_test bazel run test:JavaBinary2 +run_test bazel run test:MixJavaScalaLibBinary +run_test bazel run test:ScalaBinary +run_test bazel run test:ScalaLibBinary +run_test test_disappearing_class +run_test find -L ./bazel-testlogs -iname "*.xml" +run_test xmllint_test +run_test test_disappearing_class +run_test test_build_is_identical +run_test test_transitive_deps +run_test test_repl +