1#!/usr/bin/perl -w 2# ----------------------------------------------------------------------------- 3 4use strict; 5use lib ($0 =~ m|^(.*/)| ? $1 : "."); 6use GnumericTest; 7 8&message ("Check that the svg image export works."); 9 10my $xmllint = &GnumericTest::find_program ("xmllint"); 11 12my @sources = ("$samples/chart-tests.gnumeric"); 13 14my $tmpdir = $0; 15$tmpdir =~ s|^.*/||; 16$tmpdir =~ s|\.pl$|-tmp|; 17if (-e $tmpdir || ($tmpdir =~ m{/}) || ($tmpdir eq '')) { 18 print STDERR "$0: unexpected $tmpdir present\n"; 19 die "Fail\n"; 20} 21END { rmdir $tmpdir; } 22 23if (!mkdir $tmpdir) { 24 print STDERR "$0: failed to create $tmpdir\n"; 25 die "Fail\n"; 26} 27 28my $nskipped = 0; 29my $ngood = 0; 30my $nbad = 0; 31 32foreach my $src (@sources) { 33 if (!-r $src) { 34 $nskipped++; 35 next; 36 } 37 38 print STDERR "Checking $src\n"; 39 40 system ("$ssconvert --export-graphs $src $tmpdir/image-%n.svg"); 41 my @images = sort <$tmpdir/image-[0-9]*.svg>; 42 if (@images == 0) { 43 print STDERR "ssconvert failed to produce images in $tmpdir\n"; 44 die "Fail\n"; 45 } 46 &GnumericTest::junkfile ($_) foreach (reverse @images); 47 48 my $good = 1; 49 foreach my $image (@images) { 50 my $out = `$xmllint --nonet --noout $image 2>&1`; 51 if ($out ne '') { 52 print STDERR "While checking $image:\n"; 53 &GnumericTest::dump_indented ($out); 54 $good = 0; 55 last; 56 } 57 &GnumericTest::removejunk ($image); 58 } 59 if ($good) { 60 print STDERR "Checked ", scalar @images, " generated image files.\n"; 61 $ngood++; 62 } else { 63 $nbad++; 64 } 65} 66 67&GnumericTest::report_skip ("No source files present") if $nbad + $ngood == 0; 68 69if ($nskipped > 0) { 70 print STDERR "$nskipped files skipped.\n"; 71} 72 73if ($nbad > 0) { 74 die "Fail\n"; 75} else { 76 print STDERR "Pass\n"; 77} 78