Skip to content

Commit 4f41444

Browse files
committed
chore: add script to run tests
This is the equivalent of the prow test, but avoids bazel and can more easily be run locally.
1 parent b54f8b1 commit 4f41444

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python3
2+
3+
import json
4+
import os
5+
import urllib.request
6+
import subprocess
7+
import glob
8+
9+
def find_go_modules():
10+
"""Finds all go.mod files in the repository."""
11+
go_mod_files = []
12+
for file in glob.glob("**/go.mod", recursive=True):
13+
# Ignore matches under vendor and bazel-*
14+
if file.startswith("vendor/") or file.startswith("bazel-"):
15+
continue
16+
go_mod_files.append(file)
17+
if os.path.exists("go.mod"):
18+
go_mod_files.append("go.mod")
19+
return go_mod_files
20+
21+
22+
def main():
23+
"""
24+
Runs go tests for all go modules in the repository.
25+
"""
26+
for mod_path in find_go_modules():
27+
dir = os.path.dirname(mod_path) or "."
28+
if dir == "test/e2e":
29+
continue
30+
print(f"Running go test in {dir}")
31+
subprocess.run(["go", "test", "-v", "./..."], cwd=dir, check=True)
32+
33+
if __name__ == "__main__":
34+
main()

0 commit comments

Comments
 (0)