Skip to content

Commit aa82a76

Browse files
authored
Merge pull request #61579 from nate-chandler/test/basic-conveniences
[Test] Add a couple helpers.
2 parents 8240f0b + ffa0cc4 commit aa82a76

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

include/swift/SILOptimizer/Utils/ParseTestSpecification.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ struct Arguments {
125125
untakenIndex = 0;
126126
}
127127

128+
bool hasUntaken() { return untakenIndex < storage.size(); }
129+
128130
Arguments() {}
129131
Arguments(Arguments const &) = delete;
130132
Arguments &operator=(Arguments const &) = delete;
@@ -159,8 +161,11 @@ struct Arguments {
159161
void getTestSpecifications(SILFunction *function,
160162
SmallVectorImpl<std::string> &specifications);
161163

164+
/// Given the string \p specification operand of a test_specification
165+
/// instruction from \p function, parse the arguments which it refers to into
166+
/// \p arguments and the component strings into \p argumentStrings.
162167
void parseTestArgumentsFromSpecification(
163-
SILFunction *, StringRef specification, Arguments &arguments,
168+
SILFunction *function, StringRef specification, Arguments &arguments,
164169
SmallVectorImpl<StringRef> &argumentStrings);
165170

166171
} // namespace test

lib/SILOptimizer/UtilityPasses/UnitTestRunner.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,14 @@ struct VisitAdjacentReborrowsOfPhiTest : UnitTest {
216216
}
217217
};
218218

219+
// Arguments: NONE
220+
// Dumps:
221+
// - the function
222+
struct DumpFunction : UnitTest {
223+
DumpFunction(UnitTestRunner *pass) : UnitTest(pass) {}
224+
void invoke(Arguments &arguments) override { getFunction()->dump(); }
225+
};
226+
219227
/// [new_tests] Add the new UnitTest subclass above this line.
220228

221229
class UnitTestRunner : public SILFunctionTransform {
@@ -245,6 +253,8 @@ class UnitTestRunner : public SILFunctionTransform {
245253
return; \
246254
}
247255

256+
ADD_UNIT_TEST_SUBCLASS("dump-function", DumpFunction)
257+
248258
ADD_UNIT_TEST_SUBCLASS("test-specification-parsing", TestSpecificationTest)
249259
ADD_UNIT_TEST_SUBCLASS("canonicalize-ossa-lifetime",
250260
CanonicalizeOSSALifetimeTest)

0 commit comments

Comments
 (0)