From dad975effbd5a7ced2968532c4ddb799fadf77f4 Mon Sep 17 00:00:00 2001 From: Dataliberate Date: Fri, 2 Aug 2019 16:39:48 +0100 Subject: [PATCH] Added capability for run_tests to return a success/failure exit codes --- scripts/buildreleasefiles.sh | 17 +++++++++++++++++ scripts/run_tests.py | 8 ++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/scripts/buildreleasefiles.sh b/scripts/buildreleasefiles.sh index a4fd0ca3b8..d476e77e90 100755 --- a/scripts/buildreleasefiles.sh +++ b/scripts/buildreleasefiles.sh @@ -97,6 +97,22 @@ then fi echo +echo "Running Unit Tests... " +./scripts/run_tests.py +if [ $? -eq 0 ] +then + echo + echo " Unit Tests ran succesfully" +else + echo + echo " Unit Tests failed!!" + echo "$RES" + echo + echo "Manually run ./scripts/run_tests.py for more details" + echo "Aborting..." + exit 1 +fi + echo -n "Preparing by running buildTermConfig.sh... " ./scripts/buildTermConfig.sh echo " Prepared." @@ -129,6 +145,7 @@ rm -f $DIR/schemaorg.owl 2>&1 > /dev/null echo " cleaned." sleep 2 + echo -n "Copying schema.rdfa and README.md into release directory... " cp ./data/schema.rdfa $DIR cp ./README.md $DIR diff --git a/scripts/run_tests.py b/scripts/run_tests.py index 1265f38cab..117e1e86f0 100755 --- a/scripts/run_tests.py +++ b/scripts/run_tests.py @@ -95,8 +95,12 @@ def main(test_path, args): else: suite = unittest.loader.TestLoader().discover(test_path, pattern="test*.py") - unittest.TextTestRunner(verbosity=2).run(suite) - + res = unittest.TextTestRunner(verbosity=2).run(suite) + + count = len(res.failures) + len(res.errors) + sys.exit(count) + + if __name__ == '__main__': parser = argparse.ArgumentParser(description='Configurable testing of schema.org.') parser.add_argument('--skipbasics', action='store_true', help='Skip basic tests.')