Skip to content

Commit 6d3ad95

Browse files
committed
InlineExpectationsTest: Allow URLs as values
For example, ```py requests.get("http://example.com") # $ clientRequestUrlPart="http://example.com" ``` would not have been allowed previously, since the `//` part of the value for the URL would have caused the rest of the line to be treated as a normal (non-interpreted) comment. Requiring a space before the `//` allows this specific example, while still support all the existing uses of `//` to break expectation tests, which is usually to add a comment explaining why the annotation is like it is.
1 parent eff7cf6 commit 6d3ad95

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

cpp/ql/test/TestUtilities/InlineExpectationsTest.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ abstract class InlineExpectationsTest extends string {
173173
/**
174174
* RegEx pattern to match a comment containing one or more expected results. The comment must have
175175
* `$` as its first non-whitespace character. Any subsequent character
176-
* is treated as part of the expected results, except that the comment may contain a `//` sequence
176+
* is treated as part of the expected results, except that the comment may contain a ` //` sequence
177177
* to treat the remainder of the line as a regular (non-interpreted) comment.
178178
*/
179-
private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|/[^/])*)(?://.*)?" }
179+
private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|[^ ]//|/[^/])*)(?: //.*)?" }
180180

181181
/**
182182
* The possible columns in an expectation comment. The `TDefaultColumn` branch represents the first

csharp/ql/test/TestUtilities/InlineExpectationsTest.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ abstract class InlineExpectationsTest extends string {
173173
/**
174174
* RegEx pattern to match a comment containing one or more expected results. The comment must have
175175
* `$` as its first non-whitespace character. Any subsequent character
176-
* is treated as part of the expected results, except that the comment may contain a `//` sequence
176+
* is treated as part of the expected results, except that the comment may contain a ` //` sequence
177177
* to treat the remainder of the line as a regular (non-interpreted) comment.
178178
*/
179-
private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|/[^/])*)(?://.*)?" }
179+
private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|[^ ]//|/[^/])*)(?: //.*)?" }
180180

181181
/**
182182
* The possible columns in an expectation comment. The `TDefaultColumn` branch represents the first

java/ql/test/TestUtilities/InlineExpectationsTest.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ abstract class InlineExpectationsTest extends string {
173173
/**
174174
* RegEx pattern to match a comment containing one or more expected results. The comment must have
175175
* `$` as its first non-whitespace character. Any subsequent character
176-
* is treated as part of the expected results, except that the comment may contain a `//` sequence
176+
* is treated as part of the expected results, except that the comment may contain a ` //` sequence
177177
* to treat the remainder of the line as a regular (non-interpreted) comment.
178178
*/
179-
private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|/[^/])*)(?://.*)?" }
179+
private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|[^ ]//|/[^/])*)(?: //.*)?" }
180180

181181
/**
182182
* The possible columns in an expectation comment. The `TDefaultColumn` branch represents the first

python/ql/test/TestUtilities/InlineExpectationsTest.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ abstract class InlineExpectationsTest extends string {
173173
/**
174174
* RegEx pattern to match a comment containing one or more expected results. The comment must have
175175
* `$` as its first non-whitespace character. Any subsequent character
176-
* is treated as part of the expected results, except that the comment may contain a `//` sequence
176+
* is treated as part of the expected results, except that the comment may contain a ` //` sequence
177177
* to treat the remainder of the line as a regular (non-interpreted) comment.
178178
*/
179-
private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|/[^/])*)(?://.*)?" }
179+
private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|[^ ]//|/[^/])*)(?: //.*)?" }
180180

181181
/**
182182
* The possible columns in an expectation comment. The `TDefaultColumn` branch represents the first

ruby/ql/test/TestUtilities/InlineExpectationsTest.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,10 @@ abstract class InlineExpectationsTest extends string {
173173
/**
174174
* RegEx pattern to match a comment containing one or more expected results. The comment must have
175175
* `$` as its first non-whitespace character. Any subsequent character
176-
* is treated as part of the expected results, except that the comment may contain a `//` sequence
176+
* is treated as part of the expected results, except that the comment may contain a ` //` sequence
177177
* to treat the remainder of the line as a regular (non-interpreted) comment.
178178
*/
179-
private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|/[^/])*)(?://.*)?" }
179+
private string expectationCommentPattern() { result = "\\s*\\$((?:[^/]|[^ ]//|/[^/])*)(?: //.*)?" }
180180

181181
/**
182182
* The possible columns in an expectation comment. The `TDefaultColumn` branch represents the first

0 commit comments

Comments
 (0)