File tree Expand file tree Collapse file tree 8 files changed +102
-43
lines changed
Expand file tree Collapse file tree 8 files changed +102
-43
lines changed Original file line number Diff line number Diff line change 6565 - name : Run test
6666 run : |
6767 bundle exec rake ${{ matrix.job }}
68- valgrind :
69- runs-on : ubuntu-latest
70- steps :
71- - uses : actions/checkout@v4
72- - uses : ruby/setup-ruby@v1
73- with :
74- ruby-version : " 3.4"
75- bundler-cache : none
76- - name : Set working directory as safe
77- run : git config --global --add safe.directory $(pwd)
78- - name : Install dependencies
79- run : |
80- sudo apt-get update
81- sudo apt-get install -y libdb-dev curl autoconf automake m4 libtool python3 valgrind
82- - name : Update rubygems & bundler
83- run : |
84- ruby -v
85- gem update --system
86- - name : bin/setup
87- run : |
88- bin/setup
89- - run : bundle exec rake test:valgrind
90- env :
91- RUBY_FREE_AT_EXIT : 1
9268 C99_compile :
9369 runs-on : macos-latest
9470 strategy :
@@ -112,6 +88,10 @@ jobs:
11288 gem update --system
11389 - name : clang version
11490 run : clang --version
91+ - name : bundle config set force_ruby_platform true if head
92+ if : ${{ contains(matrix.ruby, 'head') }}
93+ run : |
94+ bundle config set force_ruby_platform true
11595 - name : bin/setup
11696 run : |
11797 bin/setup
Original file line number Diff line number Diff line change 1+ name : Valgrind
2+
3+ on :
4+ push :
5+ branches :
6+ - master
7+ paths :
8+ - " ext/**"
9+ - " include/**"
10+ - " src/**"
11+ pull_request : {}
12+ merge_group : {}
13+
14+ jobs :
15+ valgrind :
16+ runs-on : ubuntu-latest
17+ steps :
18+ - uses : actions/checkout@v4
19+ - uses : ruby/setup-ruby@v1
20+ with :
21+ ruby-version : " 3.4"
22+ bundler-cache : none
23+ - name : Set working directory as safe
24+ run : git config --global --add safe.directory $(pwd)
25+ - name : Install dependencies
26+ run : |
27+ sudo apt-get update
28+ sudo apt-get install -y libdb-dev curl autoconf automake m4 libtool python3 valgrind
29+ - name : Update rubygems & bundler
30+ run : |
31+ ruby -v
32+ gem update --system
33+ - name : bin/setup
34+ run : |
35+ bin/setup
36+ - run : bundle exec rake test:valgrind
37+ env :
38+ RUBY_FREE_AT_EXIT : 1
Original file line number Diff line number Diff line change 4343 erb (5.0.1 )
4444 extconf_compile_commands_json (0.0.7 )
4545 ffi (1.17.2 )
46+ ffi (1.17.2-arm64-darwin )
4647 fileutils (1.7.3 )
4748 goodcheck (3.1.0 )
4849 marcel (>= 1.0 , < 2.0 )
6364 logger (1.7.0 )
6465 marcel (1.0.4 )
6566 memory_profiler (1.1.0 )
66- mini_portile2 (2.8.9 )
6767 minitest (5.25.5 )
6868 mutex_m (0.3.0 )
6969 net-protocol (0.2.2 )
7070 timeout
7171 net-smtp (0.5.1 )
7272 net-protocol
7373 nkf (0.2.0 )
74- nokogiri (1.18.8 )
75- mini_portile2 (~> 2.8.2 )
74+ nokogiri (1.18.8-arm64-darwin )
7675 racc (~> 1.4 )
7776 ostruct (0.6.1 )
7877 parallel (1.27.0 )
8685 psych (4.0.6 )
8786 stringio
8887 public_suffix (6.0.2 )
89- raap (1.2 .0 )
90- rbs (~> 3.0 )
88+ raap (1.3 .0 )
89+ rbs (~> 3.9. 0 )
9190 timeout (~> 0.4 )
9291 racc (1.8.1 )
9392 rainbow (3.1.1 )
176175 zlib (3.2.1 )
177176
178177PLATFORMS
178+ arm64-darwin-24
179179
180180DEPENDENCIES
181181 abbrev
Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ test_config = lambda do |t|
2525 t . test_files = FileList [ "test/**/*_test.rb" ] . reject do |path |
2626 path =~ %r{test/stdlib/}
2727 end
28+ t . verbose = true
29+ t . options = '-v'
2830end
2931
3032Rake ::TestTask . new ( test : :compile , &test_config )
Original file line number Diff line number Diff line change @@ -29,19 +29,24 @@ def line_count
2929
3030 def ranges
3131 @ranges ||= begin
32- lines = content . lines
33- lines << "" if content . end_with? ( "\n " )
34-
35- ranges = [ ] #: Array[Range[Integer]]
36- offset = 0
37-
38- lines . each do |line |
39- size0 = line . size
40- line = line . chomp
41- range = offset ...( offset +line . size )
42- ranges << range
43-
44- offset += size0
32+ if content . empty?
33+ ranges = [ 0 ...0 ] #: Array[Range[Integer]]
34+ lines = [ "" ]
35+ else
36+ lines = content . lines
37+ lines << "" if content . end_with? ( "\n " )
38+
39+ ranges = [ ] #: Array[Range[Integer]]
40+ offset = 0
41+
42+ lines . each do |line |
43+ size0 = line . size
44+ line = line . chomp
45+ range = offset ...( offset +line . size )
46+ ranges << range
47+
48+ offset += size0
49+ end
4550 end
4651
4752 ranges
Original file line number Diff line number Diff line change 5252 rbs (>= 3 , < 5 )
5353 sorbet-runtime (>= 0.5.10782 )
5454 securerandom (0.4.1 )
55- sorbet-runtime (0.5.12174 )
55+ sorbet-runtime (0.5.12189 )
5656 steep (1.10.0 )
5757 activesupport (>= 5.1 )
5858 concurrent-ruby (>= 1.1.10 )
Original file line number Diff line number Diff line change @@ -144,6 +144,21 @@ def test_each_paragraph
144144 end
145145 end
146146
147+ def test_each_paragraph__empty
148+ buffer , comments = parse_comments ( <<~RUBY )
149+ #
150+ RUBY
151+
152+ block = CommentBlock . new ( buffer , comments )
153+
154+ paragraphs = block . each_paragraph ( [ ] ) . to_a
155+
156+ paragraphs [ 0 ] . tap do |paragraph |
157+ assert_instance_of RBS ::Location , paragraph
158+ assert_equal "" , paragraph . local_source
159+ end
160+ end
161+
147162 def test_each_paragraph_colon
148163 buffer , comments = parse_comments ( <<~RUBY )
149164 # : Foo
Original file line number Diff line number Diff line change @@ -96,4 +96,23 @@ def test_sub_buffer
9696 assert_equal [ 3 , 0 ] , sub_buffer . pos_to_loc ( 6 )
9797 end
9898 end
99+
100+ def test_empty_buffer
101+ buffer = Buffer . new ( name : Pathname ( "foo.rbs" ) , content : "" )
102+
103+ assert_equal "" , buffer . content
104+ assert_equal [ "" ] , buffer . lines
105+ assert_equal [ 0 ...0 ] , buffer . ranges
106+ assert_equal "" , buffer . content
107+ end
108+
109+ def test_empty_sub_buffer
110+ buffer = Buffer . new ( name : Pathname ( "foo.rbs" ) , content : "" )
111+
112+ sub_buffer = buffer . sub_buffer ( lines : [ 0 ...0 ] )
113+ assert_equal "" , sub_buffer . content
114+ assert_equal [ "" ] , sub_buffer . lines
115+ assert_equal [ 0 ...0 ] , sub_buffer . ranges
116+ assert_equal "" , sub_buffer . content
117+ end
99118end
You can’t perform that action at this time.
0 commit comments