Skip to content

Commit 2898875

Browse files
committed
[SILUnitTests] Added function dumper.
Being able to dump the function with a separate test allows other unit-tests to skip that step and for FileChecking to focus only on the specific things dumped between the begin and end of the unit test in question.
1 parent 6d62770 commit 2898875

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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)