Module: Canopus::TestRunner
- Defined in:
- lib/canopus/test_runner.rb,
lib/canopus/test_runner/rspec.rb,
lib/canopus/test_runner/minitest.rb,
lib/canopus/test_runner/discovery.rb,
lib/canopus/test_runner/execution.rb,
lib/canopus/test_runner/safe_walker.rb,
lib/canopus/test_runner/bounded_ignore.rb
Defined Under Namespace
Classes: BoundedIgnore, Discovery, Execution, Minitest, RSpec, Result, SafeWalker, Test
Constant Summary
collapse
- MAX_PATH_BYTES =
16_384
Class Method Summary
collapse
Class Method Details
.framework_for(path) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/canopus/test_runner.rb', line 29
def framework_for(path)
path = normalize_path(path)
return unless path&.end_with?(".rb")
name = File.basename(path)
return :rspec if name.end_with?("_spec.rb")
return :minitest if name.end_with?("_test.rb") || name.start_with?("test_")
path.split("/")[0...-1].reverse_each do |directory|
return :minitest if directory == "test"
return :rspec if directory == "spec"
end
nil
end
|
.normalize_path(path) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/canopus/test_runner.rb', line 16
def normalize_path(path)
return unless path.is_a?(String) && path.bytesize <= MAX_PATH_BYTES && !path.include?("\0")
value = path.encode(Encoding::UTF_8)
value = value.tr(File::ALT_SEPARATOR, "/") if File::ALT_SEPARATOR
return unless value.valid_encoding? && !value.start_with?("/")
return if value.split("/").any? { |part| part.empty? || part == "." || part == ".." }
value.freeze
rescue EncodingError
nil
end
|