Skip to content

Commit ebf0bb8

Browse files
committed
Ruby: add some integration tests for diagnostic messages
1 parent 22c6c53 commit ebf0bb8

File tree

7 files changed

+90
-0
lines changed

7 files changed

+90
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
4 %%% 5
2+
3+
if 1; 2
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"helpLinks": [
3+
"https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning"
4+
],
5+
"location": {
6+
"endColumn": 5,
7+
"endLine": 1,
8+
"file": "<test-root-directory>/bad.rb",
9+
"startColumn": 4,
10+
"startLine": 1
11+
},
12+
"markdownMessage": "A parse error occurred. Check the syntax of the file. If the file is invalid, correct the error or [exclude](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning) the file from analysis.",
13+
"plaintextMessage": "A parse error occurred. Check the syntax of the file. If the file is invalid, correct the error or exclude the file from analysis.",
14+
"severity": "Error",
15+
"source": {
16+
"extractorName": "ruby",
17+
"id": "ruby/parse-error",
18+
"name": "Parse error"
19+
},
20+
"visibility": {
21+
"statusPage": true
22+
}
23+
}
24+
{
25+
"helpLinks": [
26+
"https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning"
27+
],
28+
"location": {
29+
"endColumn": 7,
30+
"endLine": 3,
31+
"file": "<test-root-directory>/bad.rb",
32+
"startColumn": 8,
33+
"startLine": 3
34+
},
35+
"markdownMessage": "A parse error occurred (expected `end` symbol). Check the syntax of the file. If the file is invalid, correct the error or [exclude](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning) the file from analysis.",
36+
"plaintextMessage": "A parse error occurred (expected end symbol). Check the syntax of the file. If the file is invalid, correct the error or exclude the file from analysis.",
37+
"severity": "Error",
38+
"source": {
39+
"extractorName": "ruby",
40+
"id": "ruby/parse-error",
41+
"name": "Parse error"
42+
},
43+
"visibility": {
44+
"statusPage": true
45+
}
46+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import os
2+
from create_database_utils import *
3+
from diagnostics_test_utils import *
4+
5+
run_codeql_database_create([], lang="ruby", runFunction = runSuccessfully, db = None)
6+
7+
check_diagnostics()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"helpLinks": [
3+
"https://docs.ruby-lang.org/en/master/syntax/comments_rdoc.html#label-encoding+Directive"
4+
],
5+
"location": {
6+
"file": "<test-root-directory>/encoding.rb"
7+
},
8+
"markdownMessage": "Unknown character encoding `silly` in `#encoding:` [directive](https://docs.ruby-lang.org/en/master/syntax/comments_rdoc.html#label-encoding+Directive).",
9+
"plaintextMessage": "Unknown character encoding silly in #encoding: directive.",
10+
"severity": "Warning",
11+
"source": {
12+
"extractorName": "ruby",
13+
"id": "ruby/unknown-character-encoding",
14+
"name": "Unknown character encoding"
15+
},
16+
"visibility": {
17+
"statusPage": true
18+
}
19+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# encoding: silly
2+
3+
def f
4+
puts "hello"
5+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import os
2+
from create_database_utils import *
3+
from diagnostics_test_utils import *
4+
5+
run_codeql_database_create([], lang="ruby", runFunction = runSuccessfully, db = None)
6+
7+
check_diagnostics()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dependencies:
2+
codeql/ruby-all: '*'
3+
codeql/ruby-queries: '*'

0 commit comments

Comments
 (0)