summaryrefslogtreecommitdiffstats
path: root/t/css.t
blob: 520fd45af60119f9e8eb0d29aa0306ef675d4e54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This Source Code Form is "Incompatible With Secondary Licenses", as
# defined by the Mozilla Public License, v. 2.0.
use strict;
use warnings;
use 5.10.1;
use lib qw( . lib local/lib/perl5 );
use File::Spec;
use File::Slurp qw(read_file);
use File::Find qw(find);
use Cwd qw(realpath cwd);
use Test::More;

my $root = cwd();

find(
  {
    wanted => sub {
      if (/\.css$/) {
        my $css_file = $File::Find::name;
        my $content  = read_file($_);
        while ($content =~ m{url\(["']?([^\?\)"']+)(?:\?.+)?['"]?\)}g) {
          my $file = $1;
          my $file_rel_root
            = File::Spec->abs2rel(realpath(File::Spec->rel2abs($file)), $root);

          ok(-f $file, "$css_file references $file ($file_rel_root)");
        }
      }
    },
  },
  'skins'
);

done_testing;