Skip to content

Commit

Permalink
Add spec tests for compressed mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed Jul 15, 2019
1 parent a62d330 commit 191d802
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/sass_spec/engine_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ def describe
@description
end

def compile(sass_filename, precision)
def compile(sass_filename, precision, style)
command = File.absolute_path(@command)
dirname, basename = File.split(sass_filename)
result = capture3_with_timeout(
command, "--precision", precision.to_s, "-t", "expanded",
command, "--precision", precision.to_s, "-t", style,
"-I", File.absolute_path("spec"), *@args&.split(/\s+/), basename,
binmode: true, timeout: @timeout, chdir: dirname)

Expand Down Expand Up @@ -106,7 +106,7 @@ def describe
"dart-sass"
end

def compile(sass_filename, precision)
def compile(sass_filename, precision, style)
dirname, basename = File.split(sass_filename)
@stdin.puts "!cd #{File.absolute_path(dirname)}"
@stdin.puts("--no-color --no-unicode -I #{File.absolute_path("spec")} " +
Expand Down
3 changes: 2 additions & 1 deletion lib/sass_spec/test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ def run(engine_adapter)
@dir.with_real_files do
engine_adapter.compile(
File.join(@dir.path, @dir.glob("input.*").first),
@metadata.precision || 10)
@metadata.precision || 10,
@metadata.output_style || "expanded")
end
end

Expand Down
4 changes: 4 additions & 0 deletions lib/sass_spec/test_case_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ def precision
@options[:precision]
end

def output_style
@options[:output_style]
end

def valid_for_impl?(impl)
!ignore_for?(impl)
end
Expand Down
10 changes: 10 additions & 0 deletions spec/compressed/color.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<===> input.scss
a {
b: yellow;
c: #FF9933;
d: #F00;
}

<===> output.css
a{b:#ff0;c:#f93;d:red;}

5 changes: 5 additions & 0 deletions spec/compressed/color/input.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
a {
b: yellow;
c: #FF9933;
c: #F00;
}
1 change: 1 addition & 0 deletions spec/compressed/color/output.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a {b:#ff0;c:#f93;d:red;}
6 changes: 6 additions & 0 deletions spec/compressed/comment.hrx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<===> input.scss
/*! preserve comment */
/* remove when compressed */

<===> output.css
/*! preserve comment */
2 changes: 2 additions & 0 deletions spec/compressed/comment/input.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/*! preserve comment */
/* remove when compressed */
1 change: 1 addition & 0 deletions spec/compressed/comment/output.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*! preserve comment */
2 changes: 2 additions & 0 deletions spec/compressed/options.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
:output_style: compressed

0 comments on commit 191d802

Please sign in to comment.