t6590-samples.pl 2.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
#!/usr/bin/perl -w
# -----------------------------------------------------------------------------

use strict;
use lib ($0 =~ m|^(.*/)| ? $1 : ".");
use GnumericTest;
$GnumericTest::default_subtests = '*,-biff7';

my $csvfile = "samples.csv";
&GnumericTest::junkfile ($csvfile);
{
12
    my $cmd = "$sstest --samples-file=$csvfile";
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 39 40 41 42 43
    print STDERR "# $cmd\n" if $GnumericTest::verbose;
    system ($cmd);
    if (!-r $csvfile) {
	print STDERR "gnumeric failed to produce $csvfile\n";
	die "Fail\n";
    }
}

my $file = "samples.gnumeric";
&GnumericTest::junkfile ($file);
{
    my $cmd = "$ssconvert $csvfile $file";
    print STDERR "# $cmd\n" if $GnumericTest::verbose;
    system ($cmd);
    if (!-r $file) {
	print STDERR "ssconvert failed to produce $file\n";
	die "Fail\n";
    }
}
&GnumericTest::removejunk ($csvfile);


if (&subtest ("gnumeric")) {
    &message ("Check documentation samples gnumeric roundtrip.");
    &test_roundtrip ($file,
		     'format' => 'Gnumeric_XmlIO:sax',
		     'ext' => "gnm");
}

if (&subtest ("ods")) {
    &message ("Check documentation samples ods roundtrip.");
44 45 46

    # Replace calls to boolean functions with constants
    my $bool_func_filter = "$PERL -p -e 's{\\b(true|false)\\(\\)}{uc(\$1)}e'";
47
    my $concat_filter = "$PERL -p -e 's{\\bconcatenate\\b}{concat} and s{\\baa\\b}{bb}'";
48

49 50 51
    &test_roundtrip ($file,
		     'format' => 'Gnumeric_OpenCalc:odf',
		     'ext' => "ods",
52
		     'filter0' => "$bool_func_filter | $concat_filter",
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
		     'filter2' => 'std:drop_generator',
		     'ignore_failure' => 1);
}

if (&subtest ("biff7")) {
    &message ("Check documentation samples xls/BIFF7 roundtrip.");
    &test_roundtrip ($file,
		     'format' => 'Gnumeric_Excel:excel_biff7',
		     'ext' => "xls",
		     'resize' => '16384x256',
		     'filter2' => 'std:drop_codepage',
		     'ignore_failure' => 1);
}

if (&subtest ("biff8")) {
    &message ("Check documentation samples xls/BIFF8 roundtrip.");
    &test_roundtrip ($file,
		     'format' => 'Gnumeric_Excel:excel_biff8',
		     'ext' => "xls",
		     'filter2' => 'std:drop_codepage',
		     'ignore_failure' => 1);
}

if (&subtest ("xlsx")) {
    &message ("Check documentation samples xlsx roundtrip.");
78 79 80 81

    # Don't care about cum argument being required in XL.
    my $hypgeom_filter = "$PERL -p -e 'if (/\\bhypgeomdist\\b/) { s{,FALSE\\)}{)}'}";

82 83 84 85
    &test_roundtrip ($file,
		     'format' => 'Gnumeric_Excel:xlsx',
		     'ext' => "xlsx",
		     'resize' => '1048576x16384',
86
		     'filter' => $hypgeom_filter,
87 88
		     'ignore_failure' => 1);
}