Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void enterSimpleRule(final SimpleRuleContext ctx) {

@Override
public void exitSimpleRule(final SimpleRuleContext ctx) {
this.commitRule(ctx.asClause(), ctx.forClause());
this.commitRule(ctx.asClause(), ctx.forClause(), ctx.scopeClause());
}

@Override
Expand All @@ -138,7 +138,7 @@ public void enterConditionalRule(final ConditionalRuleContext ctx) {

@Override
public void exitConditionalRule(final ConditionalRuleContext ctx) {
this.commitRule(ctx.asClause(), ctx.forClause());
this.commitRule(ctx.asClause(), ctx.forClause(), ctx.scopeClause());
}

@Override
Expand All @@ -148,7 +148,7 @@ public void enterFallbackRule(final FallbackRuleContext ctx) {

@Override
public void exitFallbackRule(final FallbackRuleContext ctx) {
this.commitRule(ctx.asClause(), ctx.forClause());
this.commitRule(ctx.asClause(), ctx.forClause(), ctx.scopeClause());
}

private void pushRuleFrame() {
Expand All @@ -157,8 +157,19 @@ private void pushRuleFrame() {
this.stack.push(ruleFrame);
}

private void commitRule(final AsClauseContext asClause, final ForClauseContext forClause) {
private boolean isPostOnly(final ScopeClauseContext scopeClause) {
return scopeClause != null
&& scopeClause.scopeAnnotation() != null
&& scopeClause.scopeAnnotation().Post() != null;
}

private void commitRule(final AsClauseContext asClause, final ForClauseContext forClause,
final ScopeClauseContext scopeClause) {
final DependencySet ruleDeps = this.stack.pop();

if (this.isPostOnly(scopeClause)) {
return;
}
final String ruleId = asClause.ruleId().getText().replaceAll("^\"|\"$", "");

final String targetId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ void testMultipleStages() throws IOException {
assertDependencyGraph("testMultipleStages");
}

@Test
void testGlobalAndStageVariables() throws IOException {
assertDependencyGraph("testGlobalAndStageVariables");
}

// #endregion: Structure

// #region: Comprehensive ----------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,9 @@ WITH ND-Root
ASSERT BT-00-Code in [...accessibility]
AS ERROR R-C02-003
FOR BT-00-Code IN *

// Rule 9: @POST rule — should be excluded from the dependency graph
WITH ND-Root
ASSERT BT-00-Number > 0 and BT-00-Text is present
AS ERROR R-C02-004
FOR BT-00-Indicator IN * SCOPE @POST
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"fields" : [ {
"id" : "BT-00-Code",
"dependsOn" : {
"assert" : [ {
"ruleId" : "R-GS0-001",
"fields" : [ "BT-00-Text", "BT-00-Number" ],
"nodes" : [ "ND-Root" ]
} ]
}
}, {
"id" : "BT-00-Text",
"requiredBy" : {
"assert" : {
"fields" : [ "BT-00-Code" ]
}
}
}, {
"id" : "BT-00-Number",
"requiredBy" : {
"assert" : {
"fields" : [ "BT-00-Code" ]
}
}
} ],
"nodes" : [ {
"id" : "ND-Root",
"requiredBy" : {
"assert" : {
"fields" : [ "BT-00-Code" ]
}
}
} ]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Test: Dependencies inherited through global and stage variables

LET text:$globalLabel = BT-00-Text;

---- STAGE test ----

LET number:$stageThreshold = BT-00-Number;

WITH ND-Root
ASSERT $globalLabel == 'expected' and $stageThreshold > 0
AS ERROR R-GS0-001
FOR BT-00-Code IN *
Loading