Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / utils / lit / tests / Inputs / googletest-detect-duplicate / DummySubDir / OneTest.py
blobbd48ccc6d63a6d6e474687e66ba66d1174f611c1
1 #!/usr/bin/env python
3 import os
4 import sys
6 if len(sys.argv) == 3 and sys.argv[1] == "--gtest_list_tests":
7 if sys.argv[2] != "--gtest_filter=-*DISABLED_*":
8 raise ValueError("unexpected argument: %s" % (sys.argv[2]))
9 print(
10 """\
11 FirstTest.
12 subTestA"""
14 sys.exit(0)
15 elif len(sys.argv) != 1:
16 # sharding and json output are specified using environment variables
17 raise ValueError("unexpected argument: %r" % (" ".join(sys.argv[1:])))
19 for e in ["GTEST_TOTAL_SHARDS", "GTEST_SHARD_INDEX", "GTEST_OUTPUT"]:
20 if e not in os.environ:
21 raise ValueError("missing environment variables: " + e)
23 if not os.environ["GTEST_OUTPUT"].startswith("json:"):
24 raise ValueError("must emit json output: " + os.environ["GTEST_OUTPUT"])
26 output = """\
28 "random_seed": 123,
29 "testsuites": [
31 "name": "FirstTest",
32 "testsuite": [
34 "name": "subTestA",
35 "result": "COMPLETED",
36 "time": "0.001s"
41 }"""
43 dummy_output = """\
45 "testsuites": [
47 }"""
49 json_filename = os.environ["GTEST_OUTPUT"].split(":", 1)[1]
50 with open(json_filename, "w", encoding="utf-8") as f:
51 if os.environ["GTEST_SHARD_INDEX"] == "0":
52 f.write(output)
53 else:
54 f.write(dummy_output)
55 exit_code = 0
57 sys.exit(exit_code)