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]))
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"])
35 "name": "QuickSubTest",
36 "result": "COMPLETED",
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
:
58 elif test_name
== "InfiniteLoopSubTest":
62 raise SystemExit("error: invalid test name: %r" % (test_name
,))
64 with
open(json_filename
, "w", encoding
="utf-8") as f
: