Skip to content

Commit 7594e86

Browse files
committed
Update sass-spec and spec runner
1 parent 322731b commit 7594e86

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

t/99_sass_specs.t

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ sub new {
2020
my $boundary = $1;
2121
while ($data =~ s/^$boundary[ \f\t]*//s) {
2222
if ($data =~ s/^([^\r\n]+)\r?\n(.*?)(?=$boundary|\z)//s) {
23-
$hrx->{main::catfile($1)} = $2;
23+
my $fname = main::catfile($1);
24+
if (exists $hrx->{$fname}) {
25+
warn "Overwriting ", $path, " => ", $fname, "\n";
26+
}
27+
$hrx->{$fname} = $2;
2428
}
2529
elsif ($data =~ s/^\r?\n(.*?)(?=$boundary|\z)//s) {}
2630
else { die "No HRX file block found\n"; }
@@ -77,7 +81,9 @@ package SPEC;
7781

7882
use CSS::Sass;
7983
use Cwd qw(getcwd);
84+
use Cwd qw(abs_path);
8085
use Carp qw(croak);
86+
use File::Basename;
8187
use File::Spec::Functions;
8288

8389
my $cwd = getcwd;
@@ -102,7 +108,9 @@ my $norm_output = sub ($) {
102108
$_[0] =~ s/\Q$cwd_win\E[\/\\]t[\/\\]sass-spec[\/\\]/\/sass\//g;
103109
$_[0] =~ s/\Q$cwd_nix\E[\/\\]t[\/\\]sass-spec[\/\\]/\/sass\//g;
104110
# normalize nth-child binomial whitespace
105-
$_[0] =~ s/\(\s*(\d+n)\s*([+-])\s*(\d+)\s*\)/($1 $2 $3)/g;
111+
# $_[0] =~ s/\(\s*(\d+n)\s*([+-])\s*(\d+)\s*\)/($1 $2 $3)/g;
112+
# empty file (only linebreaks)
113+
$_[0] =~ s/^(?:\r?\n)+$//g;
106114
}
107115
};
108116

@@ -176,7 +184,7 @@ sub stdmsg
176184
$stderr =~ s/^(?:DEPRECATION )?WARNING(?:[^\n]+\n)*\n*//gm;
177185
}
178186
# clean error messages
179-
$stderr =~ s/^Error(?:[^\n]+\n)*\n*//gm;
187+
$stderr =~ s/^(?:Internal )?Error(?:[^\n]+\n)*\n*//gm;
180188
$stderr =~ s/\n.*\Z//s;
181189
utf8::decode($stderr);
182190
return $stderr;
@@ -272,8 +280,13 @@ sub execute
272280
$spec->query('prec'),
273281
'output_style',
274282
$spec->style,
283+
'include_paths',
284+
[abs_path('t/sass-spec/spec')],
285+
'dont_die', 1
275286
);
276287

288+
my $cwd = getcwd();
289+
chdir(dirname($spec->{file}));
277290
my $comp = CSS::Sass->new(%options);
278291

279292
# save stderr
@@ -282,17 +295,20 @@ sub execute
282295

283296
# redirect stderr to file
284297
open(STDERR, "+>:raw:utf8", "specs.stderr.log"); select(STDERR); $| = 1;
285-
my $css = eval { $comp->compile_file($spec->{file}) }; my $err = $@;
286-
sysseek(STDERR, 0, 0); sysread(STDERR, my $msg, 65536); close(STDERR);
298+
my ($css, $stats) = eval { $comp->compile_file(basename($spec->{file})) }; my $err = $@;
299+
sysseek(STDERR, 0, 0); sysread(STDERR, my $msg, 65536);
300+
close(STDERR); unlink("specs.stderr.log");
287301

288302
# reset stderr
289303
open STDERR, '>&OLDFH';
290304

291305
# store the results
292306
$spec->{css} = $css;
293-
$spec->{err} = $err;
307+
$spec->{err} = $stats->{"error_message"};
294308
$spec->{msg} = $msg;
295309

310+
chdir($cwd);
311+
296312
# return the results
297313
return $css, $err;
298314

@@ -315,6 +331,8 @@ sub query { shift->{root}->query(@_); }
315331
################################################################################
316332
package main;
317333
################################################################################
334+
our $unpackOnce; BEGIN { $unpackOnce = 0; }
335+
################################################################################
318336

319337
use Carp qw(croak);
320338

@@ -339,6 +357,7 @@ sub write_file($$)
339357
# ********************************************************************
340358
sub unpack_hrx()
341359
{
360+
return if $unpackOnce && -f 't/sass-spec/.unpacked';
342361
my @dirs = (['t/sass-spec/spec', new DIR]);
343362
# walk through all directories
344363
# no recursion for performance
@@ -374,10 +393,16 @@ sub unpack_hrx()
374393
closedir($dh);
375394

376395
}
396+
# Mark that it was unpacked
397+
if ($unpackOnce) {
398+
write_file('t/sass-spec/.unpacked', '');
399+
}
377400
}
378401
# ********************************************************************
379402
sub revert_hrx()
380403
{
404+
return if $unpackOnce && -f 't/sass-spec/.unpacked';
405+
unlink 't/sass-spec/.unpacked' if -f 't/sass-spec/.unpacked';
381406
my @dirs = (['t/sass-spec/spec', new DIR]);
382407
# walk through all directories
383408
# no recursion for performance
@@ -443,11 +468,11 @@ sub load_tests()
443468
$test->{style} = $yaml->{':output_style'};
444469
$test->{start} = $yaml->{':start_version'};
445470
$test->{end} = $yaml->{':end_version'};
446-
$test->{ignore} = grep /^libsass$/i,
471+
$test->{ignore} = grep /libsass/i,
447472
@{$yaml->{':ignore_for'} || []};
448-
$test->{wtodo} = grep /^libsass$/i,
473+
$test->{wtodo} = grep /libsass/i,
449474
@{$yaml->{':warning_todo'} || []};
450-
$test->{todo} = grep /^libsass$/i,
475+
$test->{todo} = grep /libsass/i,
451476
@{$yaml->{':todo'} || []};
452477
}
453478

t/sass-spec

Submodule sass-spec updated 626 files

0 commit comments

Comments
 (0)