Skip to content

Commit 97152d4

Browse files
committed
[ruby/yarp] Name test methods from relative paths
Full path name of the source directory is a useless noise as tests. ruby/prism@44a7ae2e64
1 parent 261e366 commit 97152d4

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

test/yarp/parse_test.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,16 @@ def test_parse_takes_file_path
6161
assert_equal filepath, find_source_file_node(parsed_result.value).filepath
6262
end
6363

64-
Dir[File.expand_path("fixtures/**/*.txt", __dir__)].each do |filepath|
65-
relative = filepath.delete_prefix("#{File.expand_path("fixtures", __dir__)}/")
64+
base = File.join(__dir__, "fixtures")
65+
Dir["**/*.txt", base: base].each do |relative|
6666
next if known_failures.include?(relative)
6767

68+
filepath = File.join(base, relative)
6869
snapshot = File.expand_path(File.join("snapshots", relative), __dir__)
6970
directory = File.dirname(snapshot)
7071
FileUtils.mkdir_p(directory) unless File.directory?(directory)
7172

72-
define_method "test_filepath_#{filepath}" do
73+
define_method "test_filepath_#{relative}" do
7374
# First, read the source from the filepath. Use binmode to avoid converting CRLF on Windows,
7475
# and explicitly set the external encoding to UTF-8 to override the binmode default.
7576
source = File.read(filepath, binmode: true, external_encoding: Encoding::UTF_8)

0 commit comments

Comments
 (0)