1#!/usr/bin/perl -w
2# -----------------------------------------------------------------------------
3
4use strict;
5use lib ($0 =~ m|^(.*/)| ? $1 : ".");
6use GnumericTest;
7
8&message ("Check that dependency tracking works.");
9
10$GnumericTest::default_corpus = 'random:20';
11my @sources = &GnumericTest::corpus();
12# Must avoid volatile functions
13@sources = grep { !m{(^|/)(chart-tests\.gnumeric|datefuns\.xls|vba-725220\.xls|docs-samples\.gnumeric|numbermatch\.gnumeric)$} } @sources;
14# Avoid slow stuff
15@sources = grep { !m{(^|/)(address\.xls|bitwise\.xls|operator\.xls|linest\.xls)$} } @sources;
16@sources = grep { !m{(^|/)(amath\.gnumeric|gamma\.gnumeric|crlibm\.gnumeric)$} } @sources;
17@sources = grep { !m{(^|/)(numtheory\.gnumeric)$} } @sources;
18# Currently fails, dending investigation
19@sources = grep { !m{(^|/)(arrays\.xls)$} } @sources;
20
21
22my $nskipped = 0;
23my $ngood = 0;
24my $nbad = 0;
25
26foreach my $src (@sources) {
27    if (!-r $src) {
28	$nskipped++;
29	next;
30    }
31
32    print STDERR "Checking $src\n";
33
34    my $cmd = &GnumericTest::quotearg ($sstest, 'test_recalc', $src);
35    my $actual = `$cmd 2>&1`;
36    my $err = $?;
37    if ($err) {
38	$nbad++;
39	next;
40    }
41
42    if ($actual =~ /^Changing the contents of \d+ cells, one at a time\.\.\.$/) {
43	$ngood++;
44	next;
45    }
46
47    my @lines = split ("\n", $actual);
48    my $toolong = (@lines > 25);
49    splice @lines, 25 if $toolong;
50    foreach (@lines) {
51	print "| $_\n";
52    }
53    print "...\n" if $toolong;
54    $nbad++;
55}
56
57&GnumericTest::report_skip ("No source files present") if $nbad + $ngood == 0;
58
59if ($nskipped > 0) {
60    print STDERR "$nskipped files skipped.\n";
61}
62
63if ($nbad > 0) {
64    die "Fail\n";
65} else {
66    print STDERR "Pass\n";
67}
68