Skip to content

Commit

Permalink
Ensure file listing is sorted consistently across environments
Browse files Browse the repository at this point in the history
  • Loading branch information
buty4649 committed Nov 4, 2023
1 parent b446fa6 commit b29cd12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 2 additions & 6 deletions mrblib/rf/directory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ class Node

def initialize(path)
@path = path
@dir = Dir.open(path)
@children = Dir.entries(path).reject { |e| ['.', '..'].include?(e) }.sort
end

def next
child = loop do
child = @dir.read
return unless child
break child unless %w[. ..].include?(child)
end
return unless child = @children.shift

File.join(@path, child)
end
Expand Down
6 changes: 3 additions & 3 deletions spec/glonal_options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
context 'with -R option' do
let(:output) do
<<~OUTPUT
./foo/bar: foobar
./a/b/c: abc
./foo/bar: foobar
OUTPUT
end

before do
FileUtils.mkdir_p(expand_path('foo'))
write_file('foo/bar', 'foobar')
FileUtils.mkdir_p(expand_path('a/b'))
write_file('a/b/c', 'abc')
FileUtils.mkdir_p(expand_path('foo'))
write_file('foo/bar', 'foobar')

run_rf('-R _ .')
end
Expand Down

0 comments on commit b29cd12

Please sign in to comment.