Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/prism/ruby/parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def assert_equal_parses(fixture, compare_asts: true, compare_tokens: true, compa
ignore_warnings { Prism::Translation::Parser33.new.tokenize(buffer) }

if expected_ast == actual_ast
if !compare_asts
if !compare_asts && !Fixture.custom_base_path?
puts "#{fixture.path} is now passing"
end

Expand All @@ -178,7 +178,7 @@ def assert_equal_parses(fixture, compare_asts: true, compare_tokens: true, compa
rescue Test::Unit::AssertionFailedError
raise if compare_tokens
else
puts "#{fixture.path} is now passing" if !compare_tokens
puts "#{fixture.path} is now passing" if !compare_tokens && !Fixture.custom_base_path?
end

assert_equal_comments(expected_comments, actual_comments) if compare_comments
Expand Down
4 changes: 4 additions & 0 deletions test/prism/snapshots_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

require_relative "test_helper"

# We don't want to generate snapshots when running
# against files outside of the project folder.
return if Prism::TestCase::Fixture.custom_base_path?

module Prism
class SnapshotsTest < TestCase
# When we pretty-print the trees to compare against the snapshots, we want
Expand Down
9 changes: 7 additions & 2 deletions test/prism/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TestCase < ::Test::Unit::TestCase
# are used to define test methods that assert against each fixture in some
# way.
class Fixture
BASE = File.join(__dir__, "fixtures")
BASE = ENV.fetch("FIXTURE_BASE", File.join(__dir__, "fixtures"))

attr_reader :path

Expand All @@ -63,9 +63,14 @@ def test_name
end

def self.each(except: [], &block)
paths = Dir[ENV.fetch("FOCUS") { File.join("**", "*.txt") }, base: BASE] - except
glob_pattern = ENV.fetch("FOCUS") { custom_base_path? ? File.join("**", "*.rb") : File.join("**", "*.txt") }
paths = Dir[glob_pattern, base: BASE] - except
paths.each { |path| yield Fixture.new(path) }
end

def self.custom_base_path?
ENV.key?("FIXTURE_BASE")
end
end

# Yield each encoding that we want to test, along with a range of the
Expand Down
Loading