File: run_tutorials

package info (click to toggle)
polymake 4.12-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 35,992 kB
  • sloc: cpp: 168,768; perl: 43,375; javascript: 31,575; ansic: 3,007; java: 2,654; python: 633; sh: 268; xml: 117; makefile: 61
file content (133 lines) | stat: -rw-r--r-- 4,207 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#  Copyright (c) 1997-2024
#  Ewgenij Gawrilow, Michael Joswig, and the polymake team
#  Technische Universität Berlin, Germany
#  https://polymake.org
#
#  This program is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the
#  Free Software Foundation; either version 2, or (at your option) any
#  later version: http://www.gnu.org/licenses/gpl.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#-------------------------------------------------------------------------------
#
#  Script to validate tutorials
#

use Polymake::Test;

require Polymake::Test::Tutorials;

##################################################################
#
#  Option parsing and preparations
#

my (@tutorials, $jenkins_report, $annotate_mode, $emacs_style, $shuffle_seed,
    $cpperl_root, $exit, $base_dir);

if ( !GetOptions('jenkins-report=s' => \$jenkins_report,
                 'annotate-mode=s' => \$annotate_mode,
                 'base-dir=s' => \$base_dir,
                 'emacs-style' => \$emacs_style,
                 'shuffle:i' => \$shuffle_seed,
                 'cpperl-root=s' => \$cpperl_root,
                )
     or $jenkins_report ? ($emacs_style || @ARGV) : ($annotate_mode)) {
die <<'.'
usage: polymake --script run_tutorials [ options ] [ FILE.ipynb | PATTERN ... ]
or: polymake --script run_tutorials [ options ] --jenkins-report REPORT

If no tutorial files or shell-style file patterns are specified, all existing tutorials are executed.

Options are:

--shuffle [SEED]
    permute tutorials randomly
    specify an integer SEED to reproduce a (failed) run;
    if omitted, a random seed is generated and reported on stdout
--cpperl-root PATH
    write new or updated cpperl files beneath the given root directory
--jenkins-report REPORT
    produce a JUnit-compatible test report REPORT_tutorials.xml,
    do not print any test results or warnings to STDOUT.
--annotate-mode MODE
    annotate every testcase in JUnit test reports with '@MODE',
    allowing to distinguish tests repeatedly run in different build modes
--emacs-style
    produce simple report without colors, cursor control, and with error messages
    comprehensible to emacs compilation mode
--base-dir
    directory containing the tutorial files, default 'demo'
.
}

my $env=new Test::Environment($Scope, shuffle_seed => $shuffle_seed,
                              annotate_mode => $annotate_mode,
                              preserve_load => 1);

if ($jenkins_report) {
   $jenkins_report =~ s{^(?=[^/.])}{$InstallTop/};
} else {
   $env->prepare_pretty_output($emacs_style);
}

if ($base_dir) {
   $base_dir =~ s{^(?=[^/.])}{$InstallTop/};
} else {
   $base_dir = "$InstallTop/demo";
}


if (defined $shuffle_seed) {
   print "\n*** RANDOM SEED=", $env->shuffle_seed, " ***\n";
}

unless (@tutorials = @ARGV) {
   push @tutorials, "*";
}

local $Core::CPlusPlus::code_generation = $cpperl_root eq "/dev/null" ? "none" : "shared";
$Core::CPlusPlus::cpperl_src_root = "$cpperl_root/$$" if defined($cpperl_root);

# include test.rules from application common for polydb
application("common")->include_rules("*/test.rules");
application("common")->configured->{"db_test.rules\@bundled:polydb"} > 0 && PolyDB::Test::prepare();


$env->start_testsuite($jenkins_report, "tutorials");

foreach my $pattern (@tutorials) {
   my $group = new Test::Tutorials($env, $pattern, $base_dir);
   if (@{$group->subgroups}) {
      my $OK = $group->run;
      $exit ||= $OK <= 0;
   } elsif (@tutorials > 1 || $tutorials[0] ne "*") {
      warn("No tutorials found matching $pattern\n");
      $exit = 1;
   } else {
      print "No tutorials found\n";
   }
}
$env->close_testsuite;

if (!$jenkins_report) {
   $env->print_summary;
}

# suppress saving any custom variables or preferences
forget AtEnd("Customize");
forget AtEnd("Preference");

exit($exit) if $exit;

# Local Variables:
# mode: perl
# cperl-indent-level:3
# indent-tabs-mode:nil
# End: