File: 070_script.t

package info (click to toggle)
libhtml-gentoc-perl 3.20-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 436 kB
  • ctags: 60
  • sloc: perl: 1,173; php: 51; makefile: 2
file content (71 lines) | stat: -rw-r--r-- 2,184 bytes parent folder | download | duplicates (4)
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
use Test::More tests => 8;

require 't/compare.pl';

#--------------------------------------------------------------------
# Insert your test code below
#--------------------------------------------------------------------

# clear files
if (-f 'test1_anch.wml') {
    unlink('test1_anch.wml');
}
if (-f 'test1_toc.html') {
    unlink('test1_toc.html');
}

# now test the script
my $command = "$^X -I lib scripts/hypertoc --quiet --gen_anchors --outfile test1_anch.wml tfiles/test1.wml";
my $result = system($command);
ok($result == 0, 'hypertoc generated anchors from test1.wml');

# compare the files
$result = compare('test1_anch.wml', 'tfiles/good_test1_anch.wml');
ok($result, 'hypertoc: test1_anch.wml matches tfiles/good_test1_anch.wml exactly');

$command = "$^X -I lib scripts/hypertoc --gen_toc --quiet --outfile test1_toc.html test1_anch.wml";
my $result2 = system($command);
ok($result2 == 0, 'hypertoc generated toc from test1_anch.wml');

# compare the files
$result2 = compare('test1_toc.html', 'tfiles/good_test1_toc.html');
ok($result2, 'hypertoc: test1_toc.html matches tfiles/good_test1_toc.html exactly');

# clean up test1
if ($result && $result2) {
    unlink('test1_anch.wml');
    unlink('test1_toc.html');
}

#
# test with both generate options together
#
$command = "$^X -I lib scripts/hypertoc --gen_anchors --quiet --gen_toc --outfile test1a_toc.html tfiles/test1.wml";
$result = system($command);
ok($result == 0, 'hypertoc generated toc from test1.wml');

# compare the files
$result = compare('test1a_toc.html', 'tfiles/good_test1a_toc.html');
ok($result, 'hypertoc: test1a_toc.html matches tfiles/good_test1a_toc.html exactly');

# clean up test1
if ($result) {
    unlink('test1a_toc.html');
}

#
# test with option file
#
$command = "$^X -I lib scripts/hypertoc --argfile tfiles/test1b.args tfiles/test1.wml";
$result = system($command);
ok($result == 0, 'hypertoc generated toc (argfile) from test1.wml');

# compare the files
$result = compare('test1b_toc.html', 'tfiles/good_test1a_toc.html');
ok($result, 'hypertoc: test1b_toc.html matches tfiles/good_test1a_toc.html exactly');

# clean up test1
if ($result) {
    unlink('test1b_toc.html');
}