[sdk][bazel] Add flag to run the tests only once.
Test: suite passes both with and without flag.
Change-Id: Ibbc21c81a6878ff6a438662c1032aa11b2888d87
diff --git a/sdk/bazel/templates/tests/run_py.mako b/sdk/bazel/templates/tests/run_py.mako
index 7880ca8..621c73f 100755
--- a/sdk/bazel/templates/tests/run_py.mako
+++ b/sdk/bazel/templates/tests/run_py.mako
@@ -19,6 +19,17 @@
]
+def program_exists(name):
+ """Returns True if an executable with the name exists"""
+ if len(name) > 0 and name[0] == '/':
+ return os.path.isfile(name) and os.access(name, os.X_OK)
+ for path in os.environ["PATH"].split(os.pathsep):
+ fname = os.path.join(path, name)
+ if os.path.isfile(fname) and os.access(fname, os.X_OK):
+ return True
+ return False
+
+
class BazelTester(object):
def __init__(self, without_sdk, with_ignored, bazel_bin,
@@ -101,21 +112,34 @@
parser.add_argument('--bazel',
help='Path to the Bazel tool',
default='bazel')
+ parser.add_argument('--once',
+ help='Whether to only run tests once',
+ action='store_true')
args = parser.parse_args()
if not program_exists(args.bazel):
print('"%s": command not found' % (args.bazel))
return 1
+ def print_test_start(arch, cpp_version):
+ print('')
+ print('-----------------------------------')
+ print('| Testing %s / %s' % (arch, cpp_version))
+ print('-----------------------------------')
+
for arch in ARCHES:
- print('--> Testing for %s target' % arch)
+ print_test_start(arch, 'C++14')
config_flags = ['--config=fuchsia_%s' % arch]
- print(' (A) Testing with C++14 (default)')
cpp14_flags = ['--cxxopt=-Wc++14-compat', '--cxxopt=-Wc++17-extensions']
if not BazelTester(args.no_sdk, args.ignored, args.bazel,
optional_flags=config_flags + cpp14_flags).run():
return 1
- print(' (B) Testing with C++17')
+
+ if args.once:
+ print('Single iteration requested, done.')
+ break
+
+ print_test_start(arch, 'C++17')
cpp17_flags = ['--cxxopt=-std=c++17', '--cxxopt=-Wc++17-compat']
if not BazelTester(args.no_sdk, args.ignored, args.bazel,
optional_flags=config_flags + cpp17_flags).run():
@@ -123,16 +147,5 @@
return 0
-def program_exists(name):
- """Returns True if an executable with the name exists"""
- if len(name) > 0 and name[0] == '/':
- return os.path.isfile(name) and os.access(name, os.X_OK)
- for path in os.environ["PATH"].split(os.pathsep):
- fname = os.path.join(path, name)
- if os.path.isfile(fname) and os.access(fname, os.X_OK):
- return True
- return False
-
-
if __name__ == '__main__':
sys.exit(main())