Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7901942

Proposed update for TagTestFinder.scanFile

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P3 P3
    • jt6.0
    • None
    • tools
    • None
    • Fix Understood

      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++;
                       }

            dbessono Dmitry Bessonov
            jjg Jonathan Gibbons
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: