Skip to content

Commit 15e70d9

Browse files
authored
Merge branch 'master' into fix-encoding-converter-test
2 parents e37b322 + b088f68 commit 15e70d9

File tree

8 files changed

+102
-43
lines changed

8 files changed

+102
-43
lines changed

.github/workflows/ruby.yml

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -65,30 +65,6 @@ jobs:
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

.github/workflows/valgrind.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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

Gemfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ GEM
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)
@@ -63,16 +64,14 @@ GEM
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)
@@ -86,8 +85,8 @@ GEM
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)
@@ -176,6 +175,7 @@ GEM
176175
zlib (3.2.1)
177176

178177
PLATFORMS
178+
arm64-darwin-24
179179

180180
DEPENDENCIES
181181
abbrev

Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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'
2830
end
2931

3032
Rake::TestTask.new(test: :compile, &test_config)

lib/rbs/buffer.rb

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff 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

steep/Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ GEM
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)

test/rbs/ast/ruby/comment_block_test.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff 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

test/rbs/buffer_test.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff 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
99118
end

0 commit comments

Comments
 (0)