Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Bazel's TESTBRIDGE_TEST_ONLY env var
Closes #2490
- Loading branch information
Showing
4 changed files
with
121 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright Catch2 Authors | ||
# Distributed under the Boost Software License, Version 1.0. | ||
# (See accompanying file LICENSE_1_0.txt or copy at | ||
# https://www.boost.org/LICENSE_1_0.txt) | ||
|
||
# SPDX-License-Identifier: BSL-1.0 | ||
|
||
import os | ||
import sys | ||
import subprocess | ||
|
||
""" | ||
Test that Catch2 recognizes `TESTBRIDGE_TEST_ONLY` env variable and applies | ||
the provided test spec properly. | ||
Requires 1 arguments, path to Catch2 binary to test. | ||
""" | ||
if len(sys.argv) != 2: | ||
print("Wrong number of arguments: {}".format(len(sys.argv))) | ||
print("Usage: {} test-bin-path".format(sys.argv[0])) | ||
exit(1) | ||
|
||
|
||
bin_path = os.path.abspath(sys.argv[1]) | ||
|
||
print('bin path:', bin_path) | ||
|
||
env = os.environ.copy() | ||
env["TESTBRIDGE_TEST_ONLY"] = "Passing test case" | ||
|
||
try: | ||
ret = subprocess.run( | ||
bin_path, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
check=True, | ||
universal_newlines=True, | ||
env=env | ||
) | ||
stdout = ret.stdout | ||
except subprocess.SubprocessError as ex: | ||
print('Could not run "{}"'.format(bin_path)) | ||
print("Return code: {}".format(ex.returncode)) | ||
print("stdout: {}".format(ex.stdout)) | ||
print("stderr: {}".format(ex.stderr)) | ||
raise | ||
|
||
if not 'All tests passed (1 assertion in 1 test case)' in stdout: | ||
print('Unexpected output: {}'.format(stdout)) | ||
exit(2) |