TagTestFinder.scanFile does not assign an id to the first test description in a file, ever. It then assigns ids to subsequent test descriptions if any. This causes an anomaly in the naming, such that it is ambiguous whether the file name refers to the first test in the file, or all tests in the file.
It would be better to update TagTestFinder so that it always assigns ids to test descriptions whenever more than one is found in a file. This can be done with a relatively small change to scanFile, to look ahead for more comments. Here is a proposed patch:
$ hg diff
diff -r 3cdb84aceb5d src/com/sun/javatest/finder/TagTestFinder.java
--- a/src/com/sun/javatest/finder/TagTestFinder.java Wed Apr 05 16:13:36 2017 +0300
+++ b/src/com/sun/javatest/finder/TagTestFinder.java Mon Apr 10 16:40:24 2017 -0700
@@ -274,14 +274,20 @@
if (fastScan)
cs.setFastScan(true);
- String comment;
- while ((comment = cs.readComment()) != null) {
+ String comment = cs.readComment();
+ while (comment != null) {
Map tagValues = parseComment(comment, file);
+
+ // Look ahead to see if there are more comments
+ comment = cs.readComment();
+
if (tagValues.isEmpty())
continue;
if (tagValues.get("id") == null) {
- if (testDescNumber != 0)
+ // if there are more comments to come, or if there have already
+ // been additional comments, set an explicit id for each set of tags
+ if (comment != null || testDescNumber != 0)
tagValues.put("id", "id" + (new Integer(testDescNumber)).toString());
testDescNumber++;
}
It would be better to update TagTestFinder so that it always assigns ids to test descriptions whenever more than one is found in a file. This can be done with a relatively small change to scanFile, to look ahead for more comments. Here is a proposed patch:
$ hg diff
diff -r 3cdb84aceb5d src/com/sun/javatest/finder/TagTestFinder.java
--- a/src/com/sun/javatest/finder/TagTestFinder.java Wed Apr 05 16:13:36 2017 +0300
+++ b/src/com/sun/javatest/finder/TagTestFinder.java Mon Apr 10 16:40:24 2017 -0700
@@ -274,14 +274,20 @@
if (fastScan)
cs.setFastScan(true);
- String comment;
- while ((comment = cs.readComment()) != null) {
+ String comment = cs.readComment();
+ while (comment != null) {
Map tagValues = parseComment(comment, file);
+
+ // Look ahead to see if there are more comments
+ comment = cs.readComment();
+
if (tagValues.isEmpty())
continue;
if (tagValues.get("id") == null) {
- if (testDescNumber != 0)
+ // if there are more comments to come, or if there have already
+ // been additional comments, set an explicit id for each set of tags
+ if (comment != null || testDescNumber != 0)
tagValues.put("id", "id" + (new Integer(testDescNumber)).toString());
testDescNumber++;
}
- blocks
-
CODETOOLS-7901944 Remove workaround for CODETOOLS-7901942
-
- New
-
- relates to
-
CODETOOLS-7901914 Failure to find multiple @test in a single file
-
- Resolved
-
-
CODETOOLS-7900144 Implement multiple tests in one file in jtreg
-
- Resolved
-
-
CODETOOLS-7901940 support multiple @test in one test file
-
- Resolved
-