Skip to content

App Engine testrunner should exit with a non-zero exit code when tests fail #503

@maltem-za

Description

@maltem-za

This doesn't seem significant enough for me to want to fill out a CLA... / please add this.

I'm trying out Bitbucket Pipelines and noticed that my builds were passing even though tests were failing. This is due to the fact that the testrunner always exits with code 0 (someone else had a similar problem with PHP tests).

I suspect the same is true for other build agents. The following patch takes care of it:

--- a/runner.py    Tue Sep 06 17:49:32 2016 +0200
+++ b/runner.py    Wed Sep 07 10:56:25 2016 +0200
@@ -76,7 +76,7 @@

     # Discover and run tests.
     suite = unittest.loader.TestLoader().discover(test_path, "*_test.py")
-    unittest.TextTestRunner(verbosity=2).run(suite)
+    return unittest.TextTestRunner(verbosity=2).run(suite)


 if __name__ == '__main__':
@@ -88,6 +88,8 @@
         sys.exit(1)
     SDK_PATH = args[0]
     TEST_PATH = args[1]
-    main(SDK_PATH, TEST_PATH)
+    result = main(SDK_PATH, TEST_PATH)
+    if not result.wasSuccessful():
+        sys.exit(1)

 # [END runner]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions