Skip to content

Commit

Permalink
feat(test): skipping non-test (helper state) files
Browse files Browse the repository at this point in the history
Closes: #74
  • Loading branch information
nergal-perm committed Oct 1, 2024
1 parent aebf26f commit 5f13198
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/ru/ewc/checklogic/testing/CheckFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import ru.ewc.decisions.api.RuleFragments;
import ru.ewc.decisions.commands.Assignment;
import ru.ewc.decisions.conditions.Condition;
import ru.ewc.decisions.core.Coordinate;

/**
* I am a single file containing one or more tests. I am responsible for performing all the tests
Expand Down Expand Up @@ -73,6 +74,7 @@ public CheckFile(final String file, final List<RuleFragments> tests, final Strin
public List<TestResult> performChecks(final String root, final CheckSuite files) {
this.suite = files;
return this.tests.stream()
.filter(rule -> rule.getFragments().stream().anyMatch(f -> f.nonEmptyOfType("CND")))
.map(rule -> this.getTestResult(rule, ServerContextFactory.create(root).context()))
.toList();
}
Expand All @@ -93,7 +95,7 @@ private TestResult getTestResult(final RuleFragments rule, final ComputationCont
if (!check.evaluate(ctx)) {
failures.add(new CheckFailure(check.asString(), check.result()));
}
} catch (final DecitaException exception) {
} catch (final DecitaException | IllegalArgumentException exception) {
failures.add(
new CheckFailure(
check.asString(),
Expand All @@ -104,7 +106,7 @@ private TestResult getTestResult(final RuleFragments rule, final ComputationCont
} else {
try {
this.perform(fragment, ctx);
} catch (DecitaException exception) {
} catch (final DecitaException | IllegalArgumentException exception) {
failures.add(new CheckFailure("", exception.getMessage()));
}
}
Expand All @@ -123,7 +125,9 @@ private void perform(final RuleFragment fragment, final ComputationContext ctx)
case "ASG" -> new Assignment(fragment.left(), fragment.right()).performIn(ctx);
case "EXE" -> {
if ("command".equals(fragment.left())) {
ctx.perform(fragment.right());
final Coordinate coordinate = Coordinate.from(fragment.right());
coordinate.resolveIn(ctx);
ctx.perform(coordinate.valueIn(ctx));
ctx.resetComputationState(this.request);
}
if ("include".equals(fragment.left())) {
Expand Down

0 comments on commit 5f13198

Please sign in to comment.