Skip to content

[Test] Add a couple helpers. #61579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion include/swift/SILOptimizer/Utils/ParseTestSpecification.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ struct Arguments {
untakenIndex = 0;
}

bool hasUntaken() { return untakenIndex < storage.size(); }

Arguments() {}
Arguments(Arguments const &) = delete;
Arguments &operator=(Arguments const &) = delete;
Expand Down Expand Up @@ -159,8 +161,11 @@ struct Arguments {
void getTestSpecifications(SILFunction *function,
SmallVectorImpl<std::string> &specifications);

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

} // namespace test
Expand Down
10 changes: 10 additions & 0 deletions lib/SILOptimizer/UtilityPasses/UnitTestRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ struct VisitAdjacentReborrowsOfPhiTest : UnitTest {
}
};

// Arguments: NONE
// Dumps:
// - the function
struct DumpFunction : UnitTest {
DumpFunction(UnitTestRunner *pass) : UnitTest(pass) {}
void invoke(Arguments &arguments) override { getFunction()->dump(); }
};

/// [new_tests] Add the new UnitTest subclass above this line.

class UnitTestRunner : public SILFunctionTransform {
Expand Down Expand Up @@ -245,6 +253,8 @@ class UnitTestRunner : public SILFunctionTransform {
return; \
}

ADD_UNIT_TEST_SUBCLASS("dump-function", DumpFunction)

ADD_UNIT_TEST_SUBCLASS("test-specification-parsing", TestSpecificationTest)
ADD_UNIT_TEST_SUBCLASS("canonicalize-ossa-lifetime",
CanonicalizeOSSALifetimeTest)
Expand Down