Expand gtest suites into individual run_tests tests
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index 7b2bc53..bdda368 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -160,12 +160,34 @@
else:
binary = 'bins/%s/%s' % (self.config.build_config, target['name'])
if os.path.isfile(binary):
- cmdline = [binary] + target['args']
- out.append(self.config.job_spec(cmdline, [binary],
- shortname=' '.join(cmdline),
- cpu_cost=target['cpu_cost'],
- environ={'GRPC_DEFAULT_SSL_ROOTS_FILE_PATH':
- _ROOT + '/src/core/tsi/test_creds/ca.pem'}))
+ if 'gtest' in target and target['gtest']:
+ with open(os.devnull, 'w') as fnull:
+ tests = subprocess.check_output([binary, '--gtest_list_tests'],
+ stderr=fnull)
+ base = None
+ for line in tests.split('\n'):
+ i = line.find('#')
+ if i >= 0: line = line[:i]
+ if not line: continue
+ if line[0] != ' ':
+ base = line
+ else:
+ assert base is not None
+ assert line[1] == ' '
+ test = base + line[2:]
+ cmdline = [binary] + ['--gtest_filter=%s' % test]
+ out.append(self.config.job_spec(cmdline, [binary],
+ shortname='%s:%s' % (binary, test),
+ cpu_cost=target['cpu_cost'],
+ environ={'GRPC_DEFAULT_SSL_ROOTS_FILE_PATH':
+ _ROOT + '/src/core/tsi/test_creds/ca.pem'}))
+ else:
+ cmdline = [binary] + target['args']
+ out.append(self.config.job_spec(cmdline, [binary],
+ shortname=' '.join(cmdline),
+ cpu_cost=target['cpu_cost'],
+ environ={'GRPC_DEFAULT_SSL_ROOTS_FILE_PATH':
+ _ROOT + '/src/core/tsi/test_creds/ca.pem'}))
elif self.args.regex == '.*' or self.platform == 'windows':
print '\nWARNING: binary not found, skipping', binary
return sorted(out)