[ValueTracking] test trunc to i1 as condition in dominating condition. (NFC)
[llvm-project.git] / llvm / utils / lit / tests / Inputs / googletest-timeout / DummySubDir / OneTest.py
blobd1698c69f4d12ba24fd3d7601337f0c76b300b79
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 """\
12 QuickSubTest
13 InfiniteLoopSubTest
14 """
16 sys.exit(0)
17 elif len(sys.argv) != 1:
18 # sharding and json output are specified using environment variables
19 raise ValueError("unexpected argument: %r" % (" ".join(sys.argv[1:])))
21 for e in ["GTEST_TOTAL_SHARDS", "GTEST_SHARD_INDEX", "GTEST_OUTPUT", "GTEST_FILTER"]:
22 if e not in os.environ:
23 raise ValueError("missing environment variables: " + e)
25 if not os.environ["GTEST_OUTPUT"].startswith("json:"):
26 raise ValueError("must emit json output: " + os.environ["GTEST_OUTPUT"])
28 output = """\
30 "testsuites": [
32 "name": "T",
33 "testsuite": [
35 "name": "QuickSubTest",
36 "result": "COMPLETED",
37 "time": "2s"
42 }"""
44 dummy_output = """\
46 "testsuites": [
48 }"""
50 json_filename = os.environ["GTEST_OUTPUT"].split(":", 1)[1]
52 if os.environ["GTEST_SHARD_INDEX"] == "0":
53 test_name = os.environ["GTEST_FILTER"]
54 if test_name == "QuickSubTest":
55 with open(json_filename, "w", encoding="utf-8") as f:
56 f.write(output)
57 exit_code = 0
58 elif test_name == "InfiniteLoopSubTest":
59 while True:
60 pass
61 else:
62 raise SystemExit("error: invalid test name: %r" % (test_name,))
63 else:
64 with open(json_filename, "w", encoding="utf-8") as f:
65 f.write(dummy_output)
66 exit_code = 0
68 sys.exit(exit_code)