Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b4fb7cc

Browse files
null77Commit Bot
authored andcommitted
Test Runner: Print reproduction steps on a batch failure.
This prints out a large gtest_filter of the tests in a batch. Makes reproducing a particular failure much easier. In the future we could potentially look at using an encoding to reproduce a specific batch: e.g. a flag that acceps a batch / shard number and runs those tests based on using the same internal counts. Bug: angleproject:5172 Change-Id: Iefad8f5ca23761417ad1ceb11fd664c9cf23c8be Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2475455 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
1 parent 7882260 commit b4fb7cc

2 files changed

Lines changed: 39 additions & 18 deletions

File tree

src/tests/test_utils/runner/TestSuite.cpp

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ ProcessInfo &ProcessInfo::operator=(ProcessInfo &&rhs)
783783
resultsFileName = std::move(rhs.resultsFileName);
784784
filterFileName = std::move(rhs.filterFileName);
785785
commandLine = std::move(rhs.commandLine);
786+
filterString = std::move(rhs.filterString);
786787
return *this;
787788
}
788789

@@ -936,26 +937,31 @@ TestSuite::TestSuite(int *argc, char **argv)
936937
exit(EXIT_FAILURE);
937938
}
938939

939-
testSet =
940-
GetShardTests(testSet, mShardIndex, mShardCount, &mTestFileLines, alsoRunDisabledTests);
941-
942-
if (!mBotMode)
940+
// If there's only one shard, we can use the testSet as defined above.
941+
if (mShardCount > 1)
943942
{
944-
mFilterString = GetTestFilter(testSet);
943+
testSet = GetShardTests(testSet, mShardIndex, mShardCount, &mTestFileLines,
944+
alsoRunDisabledTests);
945945

946-
if (filterArgIndex.valid())
946+
if (!mBotMode)
947947
{
948-
argv[filterArgIndex.value()] = const_cast<char *>(mFilterString.c_str());
949-
}
950-
else
951-
{
952-
// Note that we only add a filter string if we previously deleted a shard
953-
// index/count argument. So we will have space for the new filter string in argv.
954-
AddArg(argc, argv, mFilterString.c_str());
955-
}
948+
mFilterString = GetTestFilter(testSet);
949+
950+
if (filterArgIndex.valid())
951+
{
952+
argv[filterArgIndex.value()] = const_cast<char *>(mFilterString.c_str());
953+
}
954+
else
955+
{
956+
// Note that we only add a filter string if we previously deleted a shard
957+
// index/count argument. So we will have space for the new filter string in
958+
// argv.
959+
AddArg(argc, argv, mFilterString.c_str());
960+
}
956961

957-
// Force-re-initialize GoogleTest flags to load the shard filter.
958-
testing::internal::ParseGoogleTestFlagsOnly(argc, argv);
962+
// Force-re-initialize GoogleTest flags to load the shard filter.
963+
testing::internal::ParseGoogleTestFlagsOnly(argc, argv);
964+
}
959965
}
960966
}
961967

@@ -1085,6 +1091,8 @@ bool TestSuite::launchChildTestProcess(uint32_t batchId,
10851091
fprintf(fp, "%s", filterString.c_str());
10861092
fclose(fp);
10871093

1094+
processInfo.filterString = filterString;
1095+
10881096
std::string filterFileArg = kFilterFileArg + processInfo.filterFileName;
10891097

10901098
// Create a temporary file to store the test output.
@@ -1167,6 +1175,17 @@ bool TestSuite::finishProcess(ProcessInfo *processInfo)
11671175
const TestIdentifier &id = batchResults.results.begin()->first;
11681176
std::string config = GetConfigNameFromTestIdentifier(id);
11691177
printf("Completed batch with config: %s\n", config.c_str());
1178+
1179+
for (const auto &resultIter : batchResults.results)
1180+
{
1181+
const TestResult &result = resultIter.second;
1182+
if (result.type != TestResultType::Skip && result.type != TestResultType::Pass)
1183+
{
1184+
printf("To reproduce the batch, use filter:\n%s\n",
1185+
processInfo->filterString.c_str());
1186+
break;
1187+
}
1188+
}
11701189
}
11711190

11721191
// Process results and print unexpected errors.
@@ -1224,8 +1243,9 @@ bool TestSuite::finishProcess(ProcessInfo *processInfo)
12241243
// Clean up any dirty temporary files.
12251244
for (const std::string &tempFile : {processInfo->filterFileName, processInfo->resultsFileName})
12261245
{
1227-
// Note: we should be aware that this cleanup won't happen if the harness itself crashes.
1228-
// If this situation comes up in the future we should add crash cleanup to the harness.
1246+
// Note: we should be aware that this cleanup won't happen if the harness itself
1247+
// crashes. If this situation comes up in the future we should add crash cleanup to the
1248+
// harness.
12291249
if (!angle::DeleteFile(tempFile.c_str()))
12301250
{
12311251
std::cerr << "Warning: Error cleaning up temp file: " << tempFile << "\n";

src/tests/test_utils/runner/TestSuite.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ struct ProcessInfo : angle::NonCopyable
108108
std::string resultsFileName;
109109
std::string filterFileName;
110110
std::string commandLine;
111+
std::string filterString;
111112
};
112113

113114
using TestQueue = std::queue<std::vector<TestIdentifier>>;

0 commit comments

Comments
 (0)