File tree Expand file tree Collapse file tree 5 files changed +81
-0
lines changed Expand file tree Collapse file tree 5 files changed +81
-0
lines changed Original file line number Diff line number Diff line change 20
20
node-version : 16
21
21
- run : npm install
22
22
- run : npm test
23
+ - if : runner.os == 'Linux'
24
+ uses : actions/setup-ruby@v1
25
+ with :
26
+ ruby-version : ' 3.1'
27
+ - if : runner.os == 'Linux'
28
+ run : npm run-script test-compare
23
29
test_windows :
24
30
runs-on : windows-2019
25
31
steps :
Original file line number Diff line number Diff line change 22
22
"prebuild" : " prebuild -r electron -t 3.0.0 -t 4.0.0 -t 4.0.4 -t 5.0.0 --strip && prebuild -t 8.16.0 -t 10.12.0 --strip" ,
23
23
"prebuild:upload" : " prebuild --upload-all" ,
24
24
"test" : " tree-sitter test && script/parse-examples" ,
25
+ "test-compare" : " script/parse-examples --compare" ,
25
26
"test-windows" : " tree-sitter test"
26
27
},
27
28
"repository" : " https://github.com/tree-sitter/tree-sitter-ruby" ,
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ set -o pipefail
3
+
4
+ SCRIPT_DIR=$( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd )
5
+
6
+ file=" $1 "
7
+ " ${SCRIPT_DIR} /print-ast.rb" " $file " > " $file .1"
8
+ if [ " $? " != " 0" ]; then
9
+ echo " print-ast failure: $file "
10
+ rm " $file .1"
11
+ exit 1
12
+ fi
13
+ " ${SCRIPT_DIR} /../node_modules/tree-sitter-cli/cli.js" parse " $file " | \
14
+ sed ' s/ \[[0-9]\+, [0-9]\+\] - \[[0-9]\+, [0-9]\+\]//' | \
15
+ tr $' \n ' $' \t ' | sed ' s/\(^\|[[:space:]]*\)(comment)//g' | tr $' \t ' $' \n ' > " $file .2"
16
+
17
+ if [ " $? " != " 0" ]; then
18
+ echo " parse failure: $file "
19
+ rm " $file .1" " $file .2"
20
+ exit 1
21
+ fi
22
+ diff " $file .1" " $file .2" > " $file .diff"
23
+ if [ " $? " != " 0" ]; then
24
+ echo " diff: $file "
25
+ exit 1
26
+ else
27
+ rm " $file " .{diff,1,2}
28
+ fi
29
+
Original file line number Diff line number Diff line change
1
+ ### differences caused by bugs in tree-sitter-ruby ###
2
+
3
+ # single quoted heredocs do not contain interpolation
4
+ diff: examples/ruby_spec/core/exception/interrupt_spec.rb
5
+ diff: examples/ruby_spec/language/fixtures/squiggly_heredoc.rb
6
+ diff: examples/ruby_spec/language/heredoc_spec.rb
7
+ diff: examples/ruby_spec/library/bigdecimal/BigDecimal_spec.rb
8
+
9
+ # string array with escape sequences like `%w[\\]`
10
+ diff: examples/ruby_spec/language/array_spec.rb
11
+ diff: examples/ruby_spec/language/fixtures/classes.rb
12
+
13
+ # bad escape handling for `/\c#{str}/`
14
+ diff: examples/ruby_spec/language/regexp/interpolation_spec.rb
15
+
16
+ ### benign differences ###
17
+
18
+ # ripper does not distinguish between empty `then` and missing `then`
19
+ diff: examples/ruby_spec/language/case_spec.rb
20
+ diff: examples/ruby_spec/language/if_spec.rb
21
+ diff: examples/ruby_spec/language/pattern_matching_spec.rb
22
+
23
+ # ripper does not emit events for parentheses in define? and not statements
24
+ diff: examples/ruby_spec/language/defined_spec.rb
25
+ diff: examples/ruby_spec/language/precedence_spec.rb
26
+
Original file line number Diff line number Diff line change @@ -39,3 +39,22 @@ success_percent=$(bc -l <<< "100*${success_count}/${example_count}")
39
39
printf \
40
40
" Successfully parsed %d of %d example files (%.1f%%)\n" \
41
41
$success_count $example_count $success_percent
42
+
43
+ if [ " $1 " == " --compare" ]; then
44
+
45
+ find examples -name ' *.rb' | grep -v -f script/known_failures.txt \
46
+ | xargs -P8 -n1 script/compare-ast.sh | sort > script/known_differences.actual
47
+
48
+ difference_count=$( wc -l < " script/known_differences.actual" )
49
+
50
+ (cat script/known_differences.expected | sed -e ' s/\s*#.*//' -e ' /^$/d' | sort \
51
+ | diff --label script/known_differences.expected - script/known_differences.actual \
52
+ ) || (echo " Files script/known_differences.expected and script/known_differences.actual differ" ; exit 1)
53
+
54
+ rm -f script/known_differences.actual
55
+
56
+ printf \
57
+ " %d of %d example files were parsed differently compared to Ruby::Ripper\n" \
58
+ $difference_count $success_count
59
+
60
+ fi
You can’t perform that action at this time.
0 commit comments