1
1
# -*- perl -*-
2
2
3
- # Usefult for debugging the xs with prints:
4
- # cd text-sass-xs && ./Build && perl -Mlib=blib/arch -Mlib=blib/lib t/04_perl_functions.t
5
-
6
3
use strict;
7
4
use warnings;
8
5
9
- my (@dirs , @tests );
6
+ my (@dirs , @tests , @todos );
10
7
11
8
BEGIN
12
9
{
13
10
11
+ our $todo = 0;
12
+ my $skip_todo = 0;
13
+
14
14
@dirs = (' t/sass-spec/spec' );
15
15
16
16
while (my $dir = shift (@dirs ))
17
17
{
18
18
opendir (my $dh , $dir ) or die " error opening specs dir $dir " ;
19
19
while (my $ent = readdir ($dh ))
20
20
{
21
+ local $todo = $todo ;
21
22
next if $ent eq " ." ;
22
23
next if $ent eq " .." ;
23
- next if $ent eq " todo" ;
24
+ $todo = $todo || $ent eq " todo" ||
25
+ $ent eq " libsass-todo-tests" ||
26
+ $ent eq " libsass-todo-issues" ;
24
27
my $path = join (" /" , $dir , $ent );
28
+ next if ($skip_todo && $todo );
25
29
push @dirs , $path if -d $path ;
26
- push @tests , [$dir , $ent ] if $ent =~ m / ^input/ ;
30
+ if ($ent =~ m / ^input\. / )
31
+ {
32
+ push @tests , [$dir , $ent ];
33
+ }
27
34
}
28
35
closedir ($dh );
29
36
}
32
39
33
40
}
34
41
35
- use Test::More tests => scalar ( @tests ) * 2 ;
42
+ use Test::More tests => scalar @tests ;
36
43
37
44
use CSS::Sass;
38
45
@@ -48,25 +55,74 @@ my ($r, $err);
48
55
my ($src , $expect );
49
56
my $ignore_whitespace = 1;
50
57
58
+ my @false_negatives ;
59
+
51
60
foreach my $test (@tests )
52
61
{
53
62
my $input_file = join (" /" , @{$test });
54
63
my $expected_file = join (" /" , $test -> [0], ' expected_output.css' );
55
64
56
- $sass = CSS::Sass-> new(include_paths => [' t/inc' ], output_style => SASS_STYLE_NESTED);
57
- $r = eval { $sass -> compile_file($input_file ) };
58
- warn $@ if $@ ;
59
- $expect = read_file($expected_file );
60
- $expect =~ s / [\r\n ]+/ \n / g if $ignore_whitespace ;
61
- $r =~ s / [\r\n ]+/ \n / g if $ignore_whitespace ;
62
- # output format seems to be off by some newlines
63
- # ignore for now as the meaning does not change
64
- $expect =~ s / [\s ]+// g if $ignore_whitespace ;
65
- $r =~ s / [\s ]+// g if $ignore_whitespace ;
66
- chomp ($expect ) if $ignore_whitespace ;
67
- chomp ($r ) if $ignore_whitespace ;
68
-
69
- is ($r , $expect , " sass-spec " . $input_file );
70
- is ($err , undef , " sass-spec " . $input_file );
65
+ die " no expected file" unless defined $expected_file ;
66
+
67
+ if ($input_file =~ m / todo/ )
68
+ {
69
+ $sass = CSS::Sass-> new(include_paths => [' t/inc' ], output_style => SASS_STYLE_NESTED);
70
+ $r = eval { $sass -> compile_file($input_file ) };
71
+ $err = $@ ;
72
+ $expect = read_file($expected_file );
73
+ $expect =~ s / [\r\n ]+/ \n / g if $ignore_whitespace ;
74
+ $expect =~ s / [\s ]+// g if $ignore_whitespace ;
75
+ chomp ($expect ) if $ignore_whitespace ;
76
+ if (defined $r )
77
+ {
78
+ $r =~ s / [\r\n ]+/ \n / g if $ignore_whitespace ;
79
+ $r =~ s / [\s ]+// g if $ignore_whitespace ;
80
+ chomp ($r ) if $ignore_whitespace ;
81
+ }
82
+
83
+ my $is_expected = defined $r && $r eq $expect && !$err ? 1 : 0;
84
+ is ($is_expected , 0, " sass todo text unexpectedly passed: " . $input_file );
85
+ push @false_negatives , $input_file if $is_expected ;
86
+
87
+ }
88
+ else
89
+ {
90
+ $sass = CSS::Sass-> new(include_paths => [' t/inc' ], output_style => SASS_STYLE_NESTED);
91
+ $r = eval { $sass -> compile_file($input_file ) };
92
+ $err = $@ ; warn $@ if $@ ;
93
+ $expect = read_file($expected_file );
94
+ $expect =~ s / [\r\n ]+/ \n / g if $ignore_whitespace ;
95
+ $expect =~ s / [\s ]+// g if $ignore_whitespace ;
96
+ chomp ($expect ) if $ignore_whitespace ;
97
+ if (defined $r )
98
+ {
99
+ $r =~ s / [\r\n ]+/ \n / g if $ignore_whitespace ;
100
+ $r =~ s / [\s ]+// g if $ignore_whitespace ;
101
+ chomp ($r ) if $ignore_whitespace ;
102
+ }
103
+
104
+ is ($r , $expect , " sass-spec " . $input_file );
105
+
106
+ }
71
107
72
108
}
109
+
110
+ __DATA__
111
+
112
+ require File::Basename;
113
+ require File::Spec::Functions;
114
+
115
+ # print git mv commands
116
+ warn join "\n", (map {
117
+ $_ =~ s/\/+/\\/g;
118
+ $_ =~ s /\\input\.[a-z]+$//;
119
+ my $org = $_;
120
+ my $root = File::Basename::dirname($org);
121
+ $_ =~ s /\\libsass\-todo\-(?:tests|issues)//;
122
+ sprintf("pushd \"%s\"\n", $root).
123
+ sprintf("git mv %s %s\n",
124
+ File::Spec->rel2abs($org, $root),
125
+ File::Spec->abs2rel($_, $root)
126
+ ).
127
+ sprintf("popd\n");
128
+ } @false_negatives), "\n";
0 commit comments