Skip to content

Commit 3a9889c

Browse files
authored
Merge pull request #1436 from sass/merge-master
Merge origin/master into feature.use
2 parents e9b1764 + d0d1985 commit 3a9889c

File tree

160 files changed

+11370
-10622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+11370
-10622
lines changed

lib/sass_spec/cli.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,21 @@ def self.parse
4848

4949
opts.on("-c", "--command COMMAND", "Sets a specific binary to run") do |v|
5050
options[:engine_adapter] = ExecutableEngineAdapter.new(v)
51+
options[:engine_adapter].args = options[:cmd_args]
5152
end
5253

5354
opts.on("--dart PATH", "Run Dart Sass, whose repo should be at the given path.") do |path|
5455
options[:engine_adapter] = DartEngineAdapter.new(path)
55-
options[:engine_adapter].args = options[:dart_args]
56+
options[:engine_adapter].args = options[:cmd_args]
5657
end
5758

58-
opts.on("--dart-args ARGS", "Pass ARGS to Dart Sass.") do |args|
59+
opts.on("--cmd-args ARGS", "Pass ARGS to command or Dart Sass.") do |args|
5960
if (adapter = options[:engine_adapter]) && adapter.is_a?(DartEngineAdapter)
6061
adapter.args = args
62+
elsif (adapter = options[:engine_adapter]) && adapter.is_a?(ExecutableEngineAdapter)
63+
adapter.args = args
6164
else
62-
options[:dart_args] = args
65+
options[:cmd_args] = args
6366
end
6467
end
6568

lib/sass_spec/directory.rb

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -164,24 +164,14 @@ def delete_dir!
164164
def with_real_files
165165
return yield unless @archive
166166

167-
files = @archive.entries.select {|entry| entry.is_a?(HRX::File)}
168-
169-
# If any files in this directory contain "../"s that reach out of this
170-
# directory, materialize the appropriate level of parent directory instead.
171-
if parent.hrx? &&
172-
files.any? do |file|
173-
levels_up = file.content.
174-
scan(%r{(?:\.\./)+}).
175-
map {|s| s.count("/")}.
176-
max
177-
(levels_up || 0) > file.path.count("/")
178-
end
167+
files = @archive.entries.select {|entry| entry.is_a?(HRX::File)}.to_a
168+
if parent.hrx? && files.any? {|file| _reaches_out?(file)}
179169
return parent.with_real_files {yield}
180170
end
181171

182172
outermost_new_dir = SassSpec::Util.each_directory(@path).find {|dir| !Dir.exist?(dir)}
183173

184-
@archive.entries.select {|entry| entry.is_a?(HRX::File)}.each do |file|
174+
files.each do |file|
185175
path = File.join(@path, file.path)
186176
FileUtils.mkdir_p(File.dirname(path))
187177
File.write(path, file.content)
@@ -210,6 +200,13 @@ def to_s
210200

211201
private
212202

203+
# Returns whether `file` contains enough `../` references to reach outside
204+
# this directory.
205+
def _reaches_out?(file)
206+
depth = file.path.count("/")
207+
file.content.scan(%r{(?:\.\./)+}).any? {|match| match.count("/") > depth}
208+
end
209+
213210
# Writes `@parent_archive` to disk.
214211
def _write!
215212
@parent_archive.write!(@parent_archive_path)

lib/sass_spec/engine_adapter.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def not_implemented
2222

2323
class ExecutableEngineAdapter < EngineAdapter
2424
include CaptureWithTimeout
25+
attr_accessor :args
2526

2627
def initialize(command, description = nil)
2728
@command = command
@@ -42,7 +43,8 @@ def compile(sass_filename, precision)
4243
command = File.absolute_path(@command)
4344
dirname, basename = File.split(sass_filename)
4445
result = capture3_with_timeout(
45-
command, "--precision", precision.to_s, "-t", "expanded", basename,
46+
command, "--precision", precision.to_s, "-t", "expanded",
47+
"-I", File.absolute_path("spec"), *@args&.split(/\s+/), basename,
4648
binmode: true, timeout: @timeout, chdir: dirname)
4749

4850
if result[:timeout]
@@ -107,7 +109,8 @@ def describe
107109
def compile(sass_filename, precision)
108110
dirname, basename = File.split(sass_filename)
109111
@stdin.puts "!cd #{File.absolute_path(dirname)}"
110-
@stdin.puts "--no-color --no-unicode #{@args} #{basename}"
112+
@stdin.puts("--no-color --no-unicode -I #{File.absolute_path("spec")} " +
113+
"#{@args} #{basename}")
111114
[next_chunk(@stdout), next_chunk(@stderr), next_chunk(@stdout).to_i]
112115
end
113116

lib/sass_spec/test_case_metadata.rb

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,21 @@ def self.merge_options(existing_opts, new_opts)
1212
existing_opts = existing_opts.dup
1313

1414
new_opts.each do |key, value|
15-
if key =~ /add_(.*)/
16-
key = $1.to_sym
17-
existing_opts[key] ||= []
18-
value.each do |v|
19-
existing_opts[key] << v
20-
end
21-
existing_opts[key].uniq!
22-
elsif key =~ /remove_(.*)/
23-
key = $1.to_sym
24-
existing_opts[key] ||= []
25-
value.each do |v|
26-
existing_opts[key].delete(v)
27-
end
28-
existing_opts.delete(key) if existing_opts[key].empty?
15+
if added_key = key[/^add_(.*)/, 1]
16+
added_key = added_key.to_sym
17+
(existing_opts[added_key] ||= [])
18+
.concat(value)
19+
.uniq!
20+
elsif removed_key = key[/^remove_((?:warning_)?todo)/, 1]
21+
removed_key = removed_key.to_sym
22+
(existing_opts[removed_key] ||= [])
23+
.delete_if {|name| value.include?(_normalize_todo(name))}
24+
existing_opts.delete(removed_key) if existing_opts[removed_key].empty?
25+
elsif removed_key = key[/^remove_(.*)/, 1]
26+
removed_key = removed_key.to_sym
27+
(existing_opts[removed_key] ||= [])
28+
.delete_if {|name| value.include?(name)}
29+
existing_opts.delete(removed_key) if existing_opts[removed_key].empty?
2930
elsif value.nil?
3031
existing_opts.delete(key)
3132
else
@@ -84,11 +85,17 @@ def _resolve_options(dir)
8485
def _normalize_todos(options, field)
8586
if options.include?(field)
8687
options[field] = options[field]
87-
.map {|name| name =~ %r{^sass/(.*)#} ? $1 : name}
88+
.map {|name| self.class._normalize_todo(name)}
8889
.to_set
8990
end
9091
end
9192

93+
# Normalize a single TODO value to convert a GitHub issue reference to an
94+
# implementation name.
95+
def self._normalize_todo(value)
96+
value =~ %r{^sass/(.*)#} ? $1 : value
97+
end
98+
9299
def todo?(impl)
93100
@options[:todo] && @options[:todo].include?(impl)
94101
end

spec/basic/43_str_length/input.scss

Lines changed: 0 additions & 9 deletions
This file was deleted.

spec/basic/43_str_length/output.css

Lines changed: 0 additions & 9 deletions
This file was deleted.

spec/basic/45_str_insert/input.scss

Lines changed: 0 additions & 26 deletions
This file was deleted.

spec/basic/45_str_insert/output.css

Lines changed: 0 additions & 25 deletions
This file was deleted.

spec/basic/46_str_index/input.scss

Lines changed: 0 additions & 15 deletions
This file was deleted.

spec/basic/46_str_index/output.css

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)