Skip to content

Commit 8e873ee

Browse files
committed
simplify tagged testing
1 parent bb38577 commit 8e873ee

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_tagged_unittests.py

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,12 @@ def working_tests():
7171
for working_test in working_tests():
7272
def make_test_func(working_test):
7373
def fun():
74-
if not working_test[1]: # no selectors, run entire test module
75-
# TODO: remove branch
76-
subprocess.check_call([sys.executable, "-m", "test." + working_test[0]])
77-
else:
78-
cmd = [sys.executable, "-m", "unittest"]
79-
for testpattern in working_test[1]:
80-
cmd.extend(["-k", testpattern])
81-
testmod = working_test[0].rpartition(".")[2]
82-
cmd.append(os.path.join(os.path.dirname(test.__file__), "%s.py" % testmod))
83-
subprocess.check_call(cmd)
74+
cmd = [sys.executable, "-m", "unittest"]
75+
for testpattern in working_test[1]:
76+
cmd.extend(["-k", testpattern])
77+
testmod = working_test[0].rpartition(".")[2]
78+
cmd.append(os.path.join(os.path.dirname(test.__file__), "%s.py" % testmod))
79+
subprocess.check_call(cmd)
8480

8581
fun.__name__ = working_test[0]
8682
return fun
@@ -110,24 +106,21 @@ def fun():
110106
tagfile = os.path.join(TAGS_DIR, testfile_stem + ".txt")
111107
test_selectors = working_selectors(tagfile)
112108

113-
if not test_selectors:
114-
# TODO: remove branch
115-
print("Testing", testmod)
116-
cmd += [testmod, "-v"]
117-
else:
118-
print("Testing tagged subset of", testmod)
119-
cmd += ["unittest", "-v"]
120-
for selector in test_selectors:
121-
cmd += ["-k", selector]
122-
cmd.append(testfile)
109+
print("Testing ", testmod)
110+
cmd += ["unittest", "-v"]
111+
for selector in test_selectors:
112+
cmd += ["-k", selector]
113+
cmd.append(testfile)
123114

115+
print(" ".join(cmd))
124116
p = subprocess.run(cmd, **kwargs)
125117
print("*stdout*")
126118
print(p.stdout)
127119
print("*stderr*")
128120
print(p.stderr)
129121

130-
if p.returncode == 0:
122+
if p.returncode == 0 and not os.path.exists(tagfile):
123+
# if we're re-tagging a test without tags, all passed
131124
with open(tagfile, "w") as f:
132125
pass
133126
else:

0 commit comments

Comments
 (0)