Skip to content

Commit 2fdb1f6

Browse files
committed
Add mode to probe for passing todo tests
1 parent 5028e70 commit 2fdb1f6

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

lib/sass_spec/cli.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ def self.parse
6868
options[:run_todo] = true
6969
end
7070

71+
opts.on("--probe-todo", "Run and report tests marked as todo that unexpectedly pass. Defaults to false.") do
72+
options[:probe_todo] = options[:run_todo] = true
73+
end
74+
7175
opts.on("--impl NAME", "Sets the name of the implementation being tested. Defaults to 'sass'") do |name|
7276
options[:implementation] = name
7377
end

lib/sass_spec/runner.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,18 @@ def run
4242
Minitest.reporter = Minitap::TapY
4343
end
4444

45-
Minitest.run(minioptions)
45+
result = Minitest.run(minioptions)
46+
47+
if @options[:probe_todo]
48+
puts "Reporting successfully probed todo tests"
49+
test_cases.each do |test_case|
50+
if test_case.todo? && test_case.result?
51+
puts test_case.folder
52+
end
53+
end
54+
end
55+
56+
result
4657
end
4758

4859
def language_version

lib/sass_spec/test.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def run_spec_test(test_case, options = {})
1616

1717
if test_case.overwrite?
1818
overwrite_test!(test_case)
19-
return
19+
return true
2020
end
2121

2222
return unless handle_missing_output!(test_case)
@@ -30,6 +30,8 @@ def run_spec_test(test_case, options = {})
3030
return unless handle_expected_error_message!(test_case, options)
3131
return unless handle_unexpected_error_message!(test_case, options)
3232
end
33+
34+
return true
3335
end
3436

3537
# if the test case is interactive it will do the interaction and return
@@ -51,6 +53,7 @@ def handle_expected_error_message!(test_case, options)
5153
expected_error_msg = _extract_error_message(test_case.expected_error, options)
5254

5355
if expected_error_msg != error_msg
56+
return false if test_case.probe_todo?
5457
interact(test_case, :fail) do |i|
5558
i.prompt(error_msg.nil? ? "An error message was expected but wasn't produced." :
5659
"Error output doesn't match what was expected.")
@@ -106,13 +109,14 @@ def handle_expected_error_message!(test_case, options)
106109

107110
def handle_unexpected_error_message!(test_case, options)
108111
return true if test_case.verify_stderr?
109-
112+
110113
_output, _clean_output, error, _status = test_case.output
111114

112115
error_msg = _extract_error_message(error, options)
113116

114117
return true if error_msg.nil? || error_msg.length == 0
115118

119+
return false if test_case.probe_todo?
116120
interact(test_case, :fail) do |i|
117121
i.prompt "Unexpected output to stderr"
118122

@@ -160,6 +164,7 @@ def handle_output_difference!(test_case, options)
160164
return false
161165
end
162166

167+
return false if test_case.probe_todo?
163168
interact(test_case, :fail) do |i|
164169
i.prompt "output does not match expectation"
165170

@@ -201,6 +206,7 @@ def handle_missing_output!(test_case)
201206
return true if File.exists?(test_case.expected_path)
202207

203208
output, _, error, _ = test_case.output
209+
return false if test_case.probe_todo?
204210
choice = interact(test_case, :fail) do |i|
205211
i.prompt "in #{test_case.name}\n" +
206212
"Expected output file does not exist."
@@ -253,6 +259,7 @@ def handle_unexpected_pass!(test_case, options)
253259
return false
254260
end
255261

262+
return false if test_case.probe_todo?
256263
choice = interact(test_case, :fail) do |i|
257264
i.prompt "In #{test_case.name}\n" +
258265
"A failure was expected but it compiled instead."
@@ -302,6 +309,7 @@ def handle_unexpected_error!(test_case, options)
302309
return false
303310
end
304311

312+
return false if test_case.probe_todo?
305313
choice = interact(test_case, :fail) do |i|
306314
i.prompt "In #{test_case.name}\n" +
307315
"An unexpected compiler error was encountered."
@@ -401,7 +409,7 @@ def migrate_test!(test_case, options)
401409
end
402410

403411
start_version_index = SassSpec::LANGUAGE_VERSIONS.index(
404-
test_case.metadata.start_version.to_s)
412+
test_case.metadata.start_version.to_s)
405413

406414
if start_version_index >= current_version_index
407415
puts "Cannot migrate test. Test does not apply to an earlier version."
@@ -548,7 +556,7 @@ class SassSpec::Test < Minitest::Test
548556
def self.create_tests(test_cases, options = {})
549557
test_cases[0..options[:limit]].each do |test_case|
550558
define_method("test__#{test_case.name}") do
551-
run_spec_test(test_case, options)
559+
test_case.finalize(run_spec_test(test_case, options))
552560
end
553561
end
554562
end

lib/sass_spec/test_case.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def initialize(folder, options = {})
1111
@status_path = File.join(folder, "status")
1212
@options_path = File.join(folder, "options.yml")
1313
@options = options
14+
@result = false
1415

1516
# Probe filesystem once and cache the results
1617
@should_fail = File.file?(@status_path)
@@ -27,6 +28,14 @@ def find_input_path(folder)
2728
input_files.first
2829
end
2930

31+
def result?
32+
@result
33+
end
34+
35+
def finalize(result)
36+
@result = result
37+
end
38+
3039
def folder
3140
@folder
3241
end
@@ -91,6 +100,11 @@ def todo?
91100
@metadata.todo?(impl)
92101
end
93102

103+
def probe_todo?
104+
# run todo tests but do not fail runner if one does not pass
105+
@options[:probe_todo] && (todo? || warning_todo?) && !interactive?
106+
end
107+
94108
def warning_todo?
95109
@metadata.warning_todo?(impl)
96110
end

0 commit comments

Comments
 (0)