use of org.eclipse.n4js.tests.issues.IssueExpectations in project n4js by eclipse.
the class AccessControlTest method executeSpecification.
private static void executeSpecification(TestSpecification specification) throws IOException {
deleteFixtureDirectory();
boolean failOnExit = specification.getExpectation().isFixMe();
Map<MemberType, List<String>> fixMeMessages = new HashMap<>();
for (MemberType memberType : MemberType.values()) {
createFixtureDirectory(memberType);
ScenarioGenerator generator = new ScenarioGenerator(specification, memberType);
generator.generateScenario(Paths.get(FIXTURE_ROOT, memberType.name()));
List<Issue> issues = new ArrayList<>(compile(memberType));
issues.removeIf(issue -> N4JSLanguageConstants.DEFAULT_SUPPRESSED_ISSUE_CODES_FOR_TESTS.contains(issue.getCode()));
IssueExpectations expectations = generator.createIssues();
if (specification.getExpectation().isFixMe()) {
// We want the entire test case to fail only if none of the tested scenarios match their
// expectations.
List<String> messages = new ArrayList<>();
final boolean fixMeFailed = !expectations.matchesExactly(issues, messages);
if (fixMeFailed)
fixMeMessages.put(memberType, messages);
failOnExit &= fixMeFailed;
} else {
List<String> messages = new ArrayList<>();
boolean result = expectations.matchesExactly(issues, messages);
assertTrue(Joiner.on(", ").join(messages), result);
messages.clear();
}
}
if (failOnExit) {
StringBuilder message = new StringBuilder();
for (Map.Entry<MemberType, List<String>> entry : fixMeMessages.entrySet()) {
final MemberType memberType = entry.getKey();
final List<String> messages = entry.getValue();
message.append("FixMe test failed for member type ").append(memberType).append(": \n");
for (String line : messages) message.append(" ").append(line).append("\n");
}
fail(message.toString());
}
}
Aggregations