Skip to content

Commit 7789f2f

Browse files
committed
[bfops/fix-list-tests]: Fix running smoketests --list
1 parent 353cc0d commit 7789f2f

1 file changed

Lines changed: 33 additions & 34 deletions

File tree

smoketests/__main__.py

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,39 @@ def main():
7979
parser.add_argument("--spacetime-login", action="store_true", help="Use `spacetime login` for these tests (and disable tests that don't work with that)")
8080
args = parser.parse_args()
8181

82+
if args.docker:
83+
# have docker logs print concurrently with the test output
84+
if args.compose_file:
85+
smoketests.COMPOSE_FILE = args.compose_file
86+
if not args.no_docker_logs:
87+
if args.compose_file:
88+
subprocess.Popen(["docker", "compose", "-f", args.compose_file, "logs", "-f"])
89+
else:
90+
docker_container = check_docker()
91+
subprocess.Popen(["docker", "logs", "-f", docker_container])
92+
smoketests.HAVE_DOCKER = True
93+
94+
if not args.skip_dotnet:
95+
smoketests.HAVE_DOTNET = check_dotnet()
96+
if not smoketests.HAVE_DOTNET:
97+
print("no suitable dotnet installation found")
98+
exit(1)
99+
100+
add_prefix = lambda testlist: [TESTPREFIX + test for test in testlist]
101+
import fnmatch
102+
excludelist = add_prefix(args.exclude)
103+
testlist = add_prefix(args.test)
104+
105+
loader = ExclusionaryTestLoader(excludelist)
106+
loader.testNamePatterns = args.testNamePatterns
107+
108+
tests = loader.loadTestsFromNames(testlist)
109+
if args.list:
110+
print("Selected tests:\n")
111+
for test in itertools.chain(*itertools.chain(*tests)):
112+
print(f"{test}")
113+
exit(0)
114+
82115
if not args.no_build_cli:
83116
logging.info("Compiling spacetime cli...")
84117
smoketests.run_cmd("cargo", "build", cwd=TEST_DIR.parent, capture_stderr=False)
@@ -100,18 +133,6 @@ def main():
100133

101134
os.environ["SPACETIME_SKIP_CLIPPY"] = "1"
102135

103-
if args.docker:
104-
# have docker logs print concurrently with the test output
105-
if args.compose_file:
106-
smoketests.COMPOSE_FILE = args.compose_file
107-
if not args.no_docker_logs:
108-
if args.compose_file:
109-
subprocess.Popen(["docker", "compose", "-f", args.compose_file, "logs", "-f"])
110-
else:
111-
docker_container = check_docker()
112-
subprocess.Popen(["docker", "logs", "-f", docker_container])
113-
smoketests.HAVE_DOCKER = True
114-
115136
with tempfile.NamedTemporaryFile(mode="w+b", suffix=".toml", buffering=0, delete_on_close=False) as config_file:
116137
with BASE_STDB_CONFIG_PATH.open("rb") as src, config_file.file as dst:
117138
shutil.copyfileobj(src, dst)
@@ -130,28 +151,6 @@ def main():
130151
smoketests.STDB_CONFIG = Path(config_file.name).read_text()
131152

132153
build_template_target()
133-
134-
if not args.skip_dotnet:
135-
smoketests.HAVE_DOTNET = check_dotnet()
136-
if not smoketests.HAVE_DOTNET:
137-
print("no suitable dotnet installation found")
138-
exit(1)
139-
140-
add_prefix = lambda testlist: [TESTPREFIX + test for test in testlist]
141-
import fnmatch
142-
excludelist = add_prefix(args.exclude)
143-
testlist = add_prefix(args.test)
144-
145-
loader = ExclusionaryTestLoader(excludelist)
146-
loader.testNamePatterns = args.testNamePatterns
147-
148-
tests = loader.loadTestsFromNames(testlist)
149-
if args.list:
150-
print("Selected tests:\n")
151-
for test in itertools.chain(*itertools.chain(*tests)):
152-
print(f"{test}")
153-
exit(0)
154-
155154
buffer = not args.show_all_output
156155
verbosity = 2
157156

0 commit comments

Comments
 (0)