Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file if the variable is present. If a file already exists at this location, this function will write over it. If the variable is present, but the file cannot be created, prints an error and exits.
| 6821 | // function will write over it. If the variable is present, but the file cannot |
| 6822 | // be created, prints an error and exits. |
| 6823 | void WriteToShardStatusFileIfNeeded() { |
| 6824 | const char* const test_shard_file = posix::GetEnv(kTestShardStatusFile); |
| 6825 | if (test_shard_file != nullptr) { |
| 6826 | FILE* const file = posix::FOpen(test_shard_file, "w"); |
| 6827 | if (file == nullptr) { |
| 6828 | ColoredPrintf(COLOR_RED, |
| 6829 | "Could not write to the test shard status file \"%s\" " |
| 6830 | "specified by the %s environment variable.\n", |
| 6831 | test_shard_file, kTestShardStatusFile); |
| 6832 | fflush(stdout); |
| 6833 | exit(EXIT_FAILURE); |
| 6834 | } |
| 6835 | fclose(file); |
| 6836 | } |
| 6837 | } |
| 6838 | |
| 6839 | // Checks whether sharding is enabled by examining the relevant |
| 6840 | // environment variable values. If the variables are present, |
no test coverage detected