From 1ee4398ade6834994a6a9d07ae7c525a9c4d45d8 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Fri, 6 Dec 2013 21:08:31 +0000 Subject: [PATCH] Set pipefail for wrapper scripts Previously if the testr list command was failing subunit2py would return a 0 making the test runs that use the pretty_tox scripts also return 0 despite testr actually failing. This commit gets around this condition by setting pipefail in the pretty_tox scripts to ensure that we actually fail. Change-Id: I9cbaf83cfea7c02133b27fe639e7ea12edb48f7e --- tempest/tests/test_wrappers.py | 8 ++++---- tools/pretty_tox.sh | 4 +++- tools/pretty_tox_serial.sh | 4 +++- tox.ini | 10 +++++----- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/tempest/tests/test_wrappers.py b/tempest/tests/test_wrappers.py index dbf1809c20..88bef9b32c 100644 --- a/tempest/tests/test_wrappers.py +++ b/tempest/tests/test_wrappers.py @@ -56,7 +56,7 @@ class TestWrappers(base.TestCase): # version or an sdist to work. so make the test directory a git repo # too. subprocess.call(['git', 'init']) - exit_code = subprocess.call('sh pretty_tox.sh tests.passing', + exit_code = subprocess.call('bash pretty_tox.sh tests.passing', shell=True, stdout=DEVNULL, stderr=DEVNULL) self.assertEqual(exit_code, 0) @@ -71,7 +71,7 @@ class TestWrappers(base.TestCase): # version or an sdist to work. so make the test directory a git repo # too. subprocess.call(['git', 'init']) - exit_code = subprocess.call('sh pretty_tox.sh', shell=True, + exit_code = subprocess.call('bash pretty_tox.sh', shell=True, stdout=DEVNULL, stderr=DEVNULL) self.assertEqual(exit_code, 1) @@ -82,7 +82,7 @@ class TestWrappers(base.TestCase): # Change directory, run wrapper and check result self.addCleanup(os.chdir, os.path.abspath(os.curdir)) os.chdir(self.directory) - exit_code = subprocess.call('sh pretty_tox_serial.sh tests.passing', + exit_code = subprocess.call('bash pretty_tox_serial.sh tests.passing', shell=True, stdout=DEVNULL, stderr=DEVNULL) self.assertEqual(exit_code, 0) @@ -93,6 +93,6 @@ class TestWrappers(base.TestCase): # Change directory, run wrapper and check result self.addCleanup(os.chdir, os.path.abspath(os.curdir)) os.chdir(self.directory) - exit_code = subprocess.call('sh pretty_tox_serial.sh', shell=True, + exit_code = subprocess.call('bash pretty_tox_serial.sh', shell=True, stdout=DEVNULL, stderr=DEVNULL) self.assertEqual(exit_code, 1) diff --git a/tools/pretty_tox.sh b/tools/pretty_tox.sh index a5a607662e..07c35a06d6 100755 --- a/tools/pretty_tox.sh +++ b/tools/pretty_tox.sh @@ -1,4 +1,6 @@ -#!/bin/sh +#!/usr/bin/env bash + +set -o pipefail TESTRARGS=$1 python setup.py testr --slowest --testr-args="--subunit $TESTRARGS" | subunit2pyunit diff --git a/tools/pretty_tox_serial.sh b/tools/pretty_tox_serial.sh index 45f05bdd69..42ce760a79 100755 --- a/tools/pretty_tox_serial.sh +++ b/tools/pretty_tox_serial.sh @@ -1,4 +1,6 @@ -#!/bin/sh +#!/usr/bin/env bash + +set -o pipefail TESTRARGS=$@ diff --git a/tox.ini b/tox.ini index 9389cf4984..1d7e1b7f76 100644 --- a/tox.ini +++ b/tox.ini @@ -31,19 +31,19 @@ sitepackages = True # The regex below is used to select which tests to run and exclude the slow tag: # See the testrepostiory bug: https://bugs.launchpad.net/testrepository/+bug/1208610 commands = - sh tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario|thirdparty|cli)) {posargs}' + bash tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario|thirdparty|cli)) {posargs}' [testenv:testr-full] sitepackages = True commands = - sh tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario|thirdparty|cli)) {posargs}' + bash tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])(^tempest\.(api|scenario|thirdparty|cli)) {posargs}' [testenv:heat-slow] sitepackages = True setenv = OS_TEST_TIMEOUT=1200 # The regex below is used to select heat api/scenario tests tagged as slow. commands = - sh tools/pretty_tox_serial.sh '(?=.*\[.*\bslow\b.*\])(^tempest\.(api|scenario)\.orchestration) {posargs}' + bash tools/pretty_tox_serial.sh '(?=.*\[.*\bslow\b.*\])(^tempest\.(api|scenario)\.orchestration) {posargs}' [testenv:large-ops] sitepackages = True @@ -79,7 +79,7 @@ commands = [testenv:smoke] sitepackages = True commands = - sh tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])((smoke)|(^tempest\.scenario)) {posargs}' + bash tools/pretty_tox.sh '(?!.*\[.*\bslow\b.*\])((smoke)|(^tempest\.scenario)) {posargs}' [testenv:smoke-serial] sitepackages = True @@ -87,7 +87,7 @@ sitepackages = True # https://bugs.launchpad.net/tempest/+bug/1216076 so the neutron smoke # job would fail if we moved it to parallel. commands = - sh tools/pretty_tox_serial.sh '(?!.*\[.*\bslow\b.*\])((smoke)|(^tempest\.scenario)) {posargs}' + bash tools/pretty_tox_serial.sh '(?!.*\[.*\bslow\b.*\])((smoke)|(^tempest\.scenario)) {posargs}' [testenv:stress] sitepackages = True