@@ -524,7 +524,7 @@ module Make<InlineExpectationsTestSig Impl> {
524524 * is treated as part of the expected results, except that the comment may contain a `//` or `#`
525525 * sequence to treat the remainder of the line as a regular (non-interpreted) comment.
526526 */
527- private string expectationCommentPattern ( ) { result = "\\s*\\$ ((?:[^/]|/[^/])*)(?:(//|#).*)?" }
527+ private string expectationCommentPattern ( ) { result = "\\s*\\$ ((?:[^/# ]|/[^/])*)(?:(//|#).*)?" }
528528
529529/**
530530 * The possible columns in an expectation comment. The `TDefaultColumn` branch represents the first
@@ -1180,22 +1180,22 @@ module TestPostProcessing {
11801180 * Holds if `comment` carries a trailing regular (non-interpreted) note `note`, with the note's
11811181 * own comment marker and surrounding whitespace stripped. This is either:
11821182 *
1183- * - the text after a `//` that follows the expectations in an expectation comment (for example
1184- * `note` in `// $ Alert // note` or `# $ Alert // note`), which the framework treats as an
1185- * ordinary comment (see `expectationCommentPattern`); or
1183+ * - the text after a `//` or `#` that follows the expectations in an expectation comment (for
1184+ * example `note` in `// $ Alert // note`, `# $ Alert // note`, or
1185+ * `# $ Alert # note`), which the framework treats as an ordinary comment (see
1186+ * `expectationCommentPattern`); or
11861187 * - the whole content of a plain comment that carries no expectation at all (for example `note`
11871188 * in `// note` or `# note`), into which `--learn` may merge a freshly learned tag.
11881189 *
11891190 * `codeql test run --learn` keeps this note when it rewrites, deletes, or merges into the
11901191 * comment, re-wrapping it with the appropriate markers (`<marker> $ ... // note` when
11911192 * expectations remain, or `<marker> note` when none do), so an explanatory note written next to
1192- * code is never lost. Only `//` delimits such a note within an expectation comment, mirroring
1193- * `expectationCommentPattern`'s `(?:[^/]|/[^/])*` expectation region, which ends only at `//`; a
1194- * `#` never does, so `# $ Alert # note` reads `note` as a tag rather than a note.
1193+ * code is never lost.
11951194 */
11961195 private string getTrailingNote ( TestImpl2:: ExpectationComment comment ) {
11971196 (
1198- result = comment .getContents ( ) .regexpCapture ( "\\s*\\$ (?:[^/]|/[^/])*//(.*)" , 1 ) .trim ( )
1197+ result =
1198+ comment .getContents ( ) .regexpCapture ( "\\s*\\$ (?:[^/#]|/[^/])*(?://|#)(.*)" , 1 ) .trim ( )
11991199 or
12001200 // A plain comment with no expectation of its own: its whole content is the note.
12011201 not hasExpectation ( comment , _, _, _, _) and
@@ -1409,12 +1409,12 @@ module TestPostProcessing {
14091409 exists ( string body , string trailingSuffix |
14101410 // Preserve a trailing regular note (e.g. the `note` in `// $ Alert // note`) that sits
14111411 // after the expectations, so rewriting the expectations never drops an explanatory note.
1412- // The inner delimiter is always `//`, which the framework recognises regardless of the
1413- // outer comment marker (so a `#`-comment file renders `# $ Alert // note`) .
1412+ // Use the file's line-comment marker for the inner delimiter, so a `#`-comment file renders
1413+ // `# $ Alert # note`.
14141414 (
14151415 exists ( string note |
14161416 note = getTrailingNote ( comment ) and
1417- trailingSuffix = " // " + note
1417+ trailingSuffix = " " + Input :: getStartCommentMarker ( relativePath ) + " " + note
14181418 )
14191419 or
14201420 not exists ( getTrailingNote ( comment ) ) and trailingSuffix = ""
0 commit comments