File: leaks.t

package info (click to toggle)
libcss-minifier-xs-perl 0.13-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 216 kB
  • sloc: perl: 630; makefile: 3
file content (34 lines) | stat: -rw-r--r-- 1,002 bytes parent folder | download
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
#!/usr/bin/perl

use strict;
use warnings;
use Test::More;
use File::Which qw(which);
use CSS::Minifier::XS qw(minify);

BEGIN {
    eval "use Test::LeakTrace";
    plan skip_all => "Test::LeakTrace required for leak testing" if $@;
}
use Test::LeakTrace;

###############################################################################
# What CSS docs do we want to try compressing?
my $curl = which('curl');
my @libs = qw(
    https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css
    https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css
);

###############################################################################
# Make sure we're not leaking memory when we minify
foreach my $url (@libs) {
  subtest $url => sub {
    my $css = qx{$curl --silent $url};
    ok $css, 'got some CSS to minify';
    no_leaks_ok { minify($css) } "no leaks when minifying; $url";
  };
}

###############################################################################
done_testing();