Skip to content

Commit ba5de4d

Browse files
committed
[GR-61863] TRegex: exclude test projects from coverage reports.
PullRequest: graal/20561
2 parents 65786d6 + baccdb1 commit ba5de4d

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

regex/mx.regex/suite.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@
113113
"checkstyle" : "com.oracle.truffle.regex",
114114
"javaCompliance" : "17+",
115115
"workingSets" : "Truffle,Regex",
116+
"testProject" : True,
117+
"jacoco" : "exclude",
116118
},
117119

118120
"com.oracle.truffle.regex.test.dummylang" : {
@@ -127,6 +129,8 @@
127129
"checkstyle" : "com.oracle.truffle.regex",
128130
"javaCompliance" : "17+",
129131
"workingSets" : "Truffle,Regex",
132+
"testProject" : True,
133+
"jacoco" : "exclude",
130134
},
131135
},
132136

@@ -177,6 +181,7 @@
177181
"description" : "Truffle regular expressions testing dummy language.",
178182
"allowsJavadocWarnings": True,
179183
"maven" : False,
184+
"testDistribution": True,
180185
},
181186

182187
"TREGEX_UNIT_TESTS" : {
@@ -192,6 +197,7 @@
192197
"regex:TREGEX_TEST_DUMMY_LANG",
193198
],
194199
"maven" : False,
200+
"testDistribution": True,
195201
},
196202

197203
"TREGEX_GRAALVM_SUPPORT" : {

regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/nodes/TRegexExecNode.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
import com.oracle.truffle.api.CallTarget;
4747
import com.oracle.truffle.api.CompilerDirectives;
4848
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
49+
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
50+
import com.oracle.truffle.api.frame.MaterializedFrame;
4951
import com.oracle.truffle.api.frame.VirtualFrame;
5052
import com.oracle.truffle.api.nodes.Node;
5153
import com.oracle.truffle.api.strings.TruffleString;
@@ -142,13 +144,7 @@ public final RegexResult execute(VirtualFrame frame, TruffleString input, int fr
142144
assert !sticky || source.getOptions().isBooleanMatch() || result == RegexResult.getNoMatchInstance() || RegexResult.RegexResultGetStartNode.getUncached().execute(result, 0) == fromIndex;
143145
assert validResult(input, fromIndex, maxIndex, regionFrom, regionTo, result);
144146
if (regressionTestMode) {
145-
if (!(backtrackerProducesSameResult(frame, input, fromIndex, maxIndex, regionFrom, regionTo, result) &&
146-
nfaProducesSameResult(frame, input, fromIndex, maxIndex, regionFrom, regionTo, result) &&
147-
noSimpleCGLazyDFAProducesSameResult(frame, input, fromIndex, maxIndex, regionFrom, regionTo, result) &&
148-
(source.getOptions().isBooleanMatch() || eagerAndLazyDFAProduceSameResult(frame, input, fromIndex, maxIndex, regionFrom, regionTo, result)))) {
149-
CompilerDirectives.transferToInterpreterAndInvalidate();
150-
throw new AssertionError("Inconsistent results between different matching modes");
151-
}
147+
runInternalRegressionTests(frame.materialize(), input, fromIndex, maxIndex, regionFrom, regionTo, result);
152148
}
153149

154150
if (CompilerDirectives.inInterpreter() && !backtrackingMode) {
@@ -206,15 +202,25 @@ private boolean validResult(Object input, int fromIndex, int maxIndex, int regio
206202
return true;
207203
}
208204

209-
private RegexResult regressionTestRun(VirtualFrame frame, RunRegexSearchNode node, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo) {
205+
@TruffleBoundary
206+
private void runInternalRegressionTests(MaterializedFrame frame, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, RegexResult result) {
207+
if (!(backtrackerProducesSameResult(frame, input, fromIndex, maxIndex, regionFrom, regionTo, result) &&
208+
nfaProducesSameResult(frame, input, fromIndex, maxIndex, regionFrom, regionTo, result) &&
209+
noSimpleCGLazyDFAProducesSameResult(frame, input, fromIndex, maxIndex, regionFrom, regionTo, result) &&
210+
(source.getOptions().isBooleanMatch() || eagerAndLazyDFAProduceSameResult(frame, input, fromIndex, maxIndex, regionFrom, regionTo, result)))) {
211+
throw new AssertionError("Inconsistent results between different matching modes");
212+
}
213+
}
214+
215+
private RegexResult regressionTestRun(MaterializedFrame frame, RunRegexSearchNode node, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo) {
210216
RunRegexSearchNode old = runnerNode;
211217
runnerNode = insert(node);
212218
RegexResult result = runnerNode.run(frame, input, fromIndex, maxIndex, regionFrom, regionTo);
213219
runnerNode = insert(old);
214220
return result;
215221
}
216222

217-
private boolean backtrackerProducesSameResult(VirtualFrame frame, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, RegexResult result) {
223+
private boolean backtrackerProducesSameResult(MaterializedFrame frame, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, RegexResult result) {
218224
RegexResult btResult = regressionTestRun(frame, regressTestBacktrackingNode, input, fromIndex, maxIndex, regionFrom, regionTo);
219225
if (resultsEqual(result, btResult, getNumberOfCaptureGroups())) {
220226
return true;
@@ -223,7 +229,7 @@ private boolean backtrackerProducesSameResult(VirtualFrame frame, TruffleString
223229
return false;
224230
}
225231

226-
private boolean nfaProducesSameResult(VirtualFrame frame, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, RegexResult result) {
232+
private boolean nfaProducesSameResult(MaterializedFrame frame, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, RegexResult result) {
227233
if (lazyDFANode == LAZY_DFA_BAILED_OUT) {
228234
return true;
229235
}
@@ -236,7 +242,7 @@ private boolean nfaProducesSameResult(VirtualFrame frame, TruffleString input, i
236242
return false;
237243
}
238244

239-
private boolean noSimpleCGLazyDFAProducesSameResult(VirtualFrame frame, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, RegexResult result) {
245+
private boolean noSimpleCGLazyDFAProducesSameResult(MaterializedFrame frame, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, RegexResult result) {
240246
if (lazyDFANode == LAZY_DFA_BAILED_OUT || !lazyDFANode.isSimpleCG() || regressTestNoSimpleCGLazyDFANode == LAZY_DFA_BAILED_OUT) {
241247
return true;
242248
}
@@ -249,7 +255,7 @@ private boolean noSimpleCGLazyDFAProducesSameResult(VirtualFrame frame, TruffleS
249255
return false;
250256
}
251257

252-
private boolean eagerAndLazyDFAProduceSameResult(VirtualFrame frame, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, RegexResult resultOfCurrentSearchNode) {
258+
private boolean eagerAndLazyDFAProduceSameResult(MaterializedFrame frame, TruffleString input, int fromIndex, int maxIndex, int regionFrom, int regionTo, RegexResult resultOfCurrentSearchNode) {
253259
if (lazyDFANode.captureGroupEntryNode == null || eagerDFANode == EAGER_DFA_BAILED_OUT) {
254260
return true;
255261
}

0 commit comments

Comments
 (0)