Skip to content

Commit 40f1884

Browse files
committed
Add the concept of a per-impl 'warning todo' which means the output is right but the warning is pending.
1 parent 29cbe95 commit 40f1884

File tree

28 files changed

+146
-14
lines changed

28 files changed

+146
-14
lines changed

lib/sass_spec/annotate/cli.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def annotate
141141
return true
142142
end
143143

144+
# If you change this, also change TestCaseMetadata.merge_options
144145
def annotate_path(path)
145146
report(message: "#{path}:", complete: "") do
146147
options_file = path.end_with?("options.yml") ? path : File.join(path, "options.yml")

lib/sass_spec/test.rb

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ def run_spec_test(test_case, options = {})
2525
return unless handle_unexpected_error!(test_case, status, error, options)
2626
return unless handle_unexpected_pass!(test_case, status, error, options)
2727
return unless handle_output_difference!(test_case, options)
28-
return unless handle_expected_error_message!(test_case, options)
29-
return unless handle_unexpected_error_message!(test_case, options)
28+
29+
if test_case.warning_todo? && !options[:run_todo]
30+
skip "Skipped warning check for #{test_case.folder}"
31+
else
32+
return unless handle_expected_error_message!(test_case, options)
33+
return unless handle_unexpected_error_message!(test_case, options)
34+
end
3035
end
3136

3237
def interact(test_case, default, &block)
@@ -49,11 +54,18 @@ def handle_expected_error_message!(test_case, options)
4954
interact(test_case, :fail) do |i|
5055
i.prompt(error_msg.nil? ? "An error message was expected but wasn't produced." :
5156
"Error output doesn't match what was expected.")
52-
i.choice(:show, "Show diff.") do
53-
display_text_block(
54-
Diffy::Diff.new("Expected\n" + expected_error_msg,
55-
"Actual\n" + error_msg).to_s(:color))
56-
i.restart!
57+
if error_msg.nil?
58+
i.choice(:show, "Show expected error.") do
59+
display_text_block(expected_error_msg)
60+
i.restart!
61+
end
62+
else
63+
i.choice(:show, "Show diff.") do
64+
display_text_block(
65+
Diffy::Diff.new("Expected\n#{expected_error_msg}",
66+
"Actual\n#{error_msg}").to_s(:color))
67+
i.restart!
68+
end
5769
end
5870

5971
i.choice(:overwrite, "Update expected output and pass test.") do
@@ -66,6 +78,11 @@ def handle_expected_error_message!(test_case, options)
6678
return false
6779
end
6880

81+
i.choice(:todo, "Mark warning as todo for #{test_case.impl}.") do
82+
change_options(test_case.options_path, add_warning_todo: [test_case.impl])
83+
return false
84+
end
85+
6986
i.choice(:fail, "Mark as failed.")
7087

7188
i.choice(:exit, "Exit testing.") do
@@ -112,6 +129,11 @@ def handle_unexpected_error_message!(test_case, options)
112129
return false
113130
end
114131

132+
i.choice(:todo, "Mark warning as todo for #{test_case.impl}.") do
133+
change_options(test_case.options_path, add_warning_todo: [test_case.impl])
134+
return false
135+
end
136+
115137
i.choice(:fail, "Mark as failed.")
116138

117139
i.choice(:exit, "Exit testing.") do
@@ -406,12 +428,8 @@ def change_options(options_file, options)
406428
{}
407429
end
408430

409-
existing_options.update(options)
431+
existing_options = SassSpec::TestCaseMetadata.merge_options(existing_options, options)
410432

411-
existing_options.each do |k, v|
412-
existing_options.delete(k) if v.nil?
413-
end
414-
415433
if existing_options.any?
416434
File.open(options_file, "w") do |f|
417435
f.write(existing_options.to_yaml)

lib/sass_spec/test_case.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,16 @@ def should_fail?
7979
@should_fail
8080
end
8181

82+
def impl
83+
@options[:engine_adapter].describe
84+
end
85+
8286
def todo?
83-
@metadata.todo?(@options[:engine_adapter].describe)
87+
@metadata.todo?(impl)
88+
end
89+
90+
def warning_todo?
91+
@metadata.warning_todo?(impl)
8492
end
8593

8694
def metadata

lib/sass_spec/test_case_metadata.rb

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,36 @@ def self.cache
66
@metadata_cache ||= {}
77
end
88

9-
ACCUMULATED_OPTIONS = [:todo, :expect_failure]
9+
# If you change this, also change Annotate::CLI#annotate_path
10+
def self.merge_options(existing_opts, new_opts)
11+
existing_opts = existing_opts.dup
12+
13+
new_opts.each do |key, value|
14+
if key =~ /add_(.*)/
15+
key = $1.to_sym
16+
existing_opts[key] ||= []
17+
value.each do |v|
18+
existing_opts[key] << v
19+
end
20+
existing_opts[key].uniq!
21+
elsif key =~ /remove_(.*)/
22+
key = $1.to_sym
23+
existing_opts[key] ||= []
24+
value.each do |v|
25+
existing_opts[key].delete(v)
26+
end
27+
existing_opts.delete(key) if existing_opts[key].empty?
28+
elsif value.nil?
29+
existing_opts.delete(key)
30+
else
31+
existing_opts[key] = value
32+
end
33+
end
34+
35+
existing_opts
36+
end
37+
38+
ACCUMULATED_OPTIONS = [:todo, :expect_failure, :warning_todo]
1039

1140
attr_reader :options
1241

@@ -47,6 +76,10 @@ def resolve_options(dir)
4776
self.class.cache[dir] ||= _resolve_options(dir).freeze
4877
end
4978

79+
def warning_todo?(impl)
80+
@options[:warning_todo] && @options[:warning_todo].include?(impl)
81+
end
82+
5083
def todo?(impl)
5184
@options[:todo] && @options[:todo].include?(impl)
5285
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
:warning_todo:
3+
- libsass
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
:warning_todo:
3+
- libsass
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
:warning_todo:
3+
- libsass
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
:warning_todo:
3+
- libsass
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
:warning_todo:
3+
- libsass
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
:warning_todo:
3+
- libsass

0 commit comments

Comments
 (0)