Skip to content

Commit 5d8e7ae

Browse files
committed
Merge pull request #674 from mgreter/feature/error-path-cleaning
Add path cleaning for error spec tests
2 parents 554b1a1 + ad18e6f commit 5d8e7ae

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

lib/sass_spec/test.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,16 @@ def run_spec_test(test_case, options = {})
7676
end
7777

7878
def _clean_debug_path(error)
79-
error.sub(/^.*?(input.scss:\d+ DEBUG:)/, '\1')
79+
pwd = Dir.pwd
80+
url = pwd.gsub(/\\/, '\/')
81+
error.gsub(/^.*?(input.scss:\d+ DEBUG:)/, '\1')
82+
.gsub(/[ ]+/, " ")
83+
.gsub(/#{Regexp.quote(url)}\//, "/sass/sass-spec/")
84+
.gsub(/#{Regexp.quote(pwd)}\//, "/sass/sass-spec/")
85+
.gsub(/(?:\/todo_|_todo\/)/, "/")
86+
.gsub(/\/libsass\-[a-z]+\-test\//, "/")
87+
.gsub(/\/libsass\-[a-z]+\-issue/, "/libsass-issue")
88+
.strip
8089
end
8190

8291

lib/sass_spec/test_case.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def expected
8484
end
8585

8686
def expected_error
87-
@expected_error = File.read(@error_path, :encoding => "utf-8")
87+
@expected_error = _clean_error(File.read(@error_path, :encoding => "utf-8"))
8888
end
8989

9090
def expected_status
@@ -116,4 +116,18 @@ def _clean_output(css)
116116
.strip
117117
end
118118

119+
def _clean_error(err)
120+
pwd = Dir.pwd
121+
url = pwd.gsub(/\\/, '/')
122+
err = err.force_encoding('iso-8859-1').encode('utf-8')
123+
err.gsub(/^.*?(input.scss:\d+ DEBUG:)/, '\1')
124+
.gsub(/[ ]+/, " ")
125+
.gsub(/#{Regexp.quote(url)}\//, "/sass/sass-spec/")
126+
.gsub(/#{Regexp.quote(pwd)}\//, "/sass/sass-spec/")
127+
.gsub(/(?:\/todo_|_todo\/)/, "/")
128+
.gsub(/\/libsass\-[a-z]+\-test\//, "/")
129+
.gsub(/\/libsass\-[a-z]+\-issue/, "/libsass-issue")
130+
.strip
131+
end
132+
119133
end

0 commit comments

Comments
 (0)