brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · f8fe95c Raw
57 lines · python
1#!/usr/bin/env python2 3import os4import sys5 6if 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        """\11FirstTest.12  subTestA13  subTestB14  subTestC15  subTestD16ParameterizedTest/0.17  subTest18ParameterizedTest/1.19  subTest"""20    )21    sys.exit(0)22elif len(sys.argv) != 1:23    # sharding and json output are specified using environment variables24    raise ValueError("unexpected argument: %r" % (" ".join(sys.argv[1:])))25 26for e in ["GTEST_TOTAL_SHARDS", "GTEST_SHARD_INDEX", "GTEST_OUTPUT"]:27    if e not in os.environ:28        raise ValueError("missing environment variables: " + e)29 30if not os.environ["GTEST_OUTPUT"].startswith("json:"):31    raise ValueError("must emit json output: " + os.environ["GTEST_OUTPUT"])32 33dummy_output = """\34{35"testsuites": [36]37}"""38 39if os.environ["GTEST_SHARD_INDEX"] == "0":40    print(41        """\42[----------] 4 test from FirstTest43[ RUN      ] FirstTest.subTestA44[       OK ] FirstTest.subTestA (18 ms)45[ RUN      ] FirstTest.subTestB""",46        flush=True,47    )48    print("I am about to crash", file=sys.stderr, flush=True)49    exit_code = 150else:51    json_filename = os.environ["GTEST_OUTPUT"].split(":", 1)[1]52    with open(json_filename, "w", encoding="utf-8") as f:53        f.write(dummy_output)54    exit_code = 055 56sys.exit(exit_code)57