File: import

package info (click to toggle)
tcllib 2.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 83,560 kB
  • sloc: tcl: 306,798; ansic: 14,272; sh: 3,035; xml: 1,766; yacc: 1,157; pascal: 881; makefile: 124; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (174 lines) | stat: -rw-r--r-- 6,097 bytes parent folder | download | duplicates (3)
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# -*- tcl -*-
# idx_import.testsuite: Tests for the managed of index import plugins.
#
# Copyright (c) 2009 Andreas Kupries <andreas_kupries@users.sourceforge.net>
# All rights reserved.
#
# RCS: @(#) $Id: import,v 1.1 2009/04/01 04:28:37 andreas_kupries Exp $

# -------------------------------------------------------------------------

# Tests are run for all formats we have an import plugin for.

# -------------------------------------------------------------------------

set mytestdir      data
set mytestconfig   {fox dog lazy jump}
set mytestincludes [TestFilesGlob $mytestdir]

# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# docidx markup

# We are checking that the various forms of docidx markup, as can be
# generated by doctools::idx(::format::docidx) are valid input to the
# docidx parser.

foreach {k section} {
    0 {}
    1 -ultracompact
    2 -compact
    3 -indented
    4 -aligned
    5 -indalign
} {
    TestFilesProcess $mytestdir ok docidx$section serial-print -> n label input data expected {
	test doctools-idx-import-plugin-docidx-20.$k.$n "doctools::idx::import text /docidx, $label$section, ok" -setup {
	    doctools::idx::import I
	    foreach {n v} $mytestconfig { I config set $n $v }
	    foreach p $mytestincludes   { I include add $p }
	} -body {
	    doctools::idx::structure print [I import text $data docidx]
	} -cleanup {
	    I destroy
	} -result $expected
    }

    TestFilesProcess $mytestdir ok docidx$section serial-print -> n label input data expected {
	test doctools-idx-import-plugin-docidx-21.$k.$n "doctools::idx::import file /docidx, $label$section, ok" -setup {
	    doctools::idx::import I
	    foreach {n v} $mytestconfig { I config set $n $v }
	    foreach p $mytestincludes   { I include add $p }
	} -body {
	    doctools::idx::structure print [I import file $input docidx]
	} -cleanup {
	    I destroy
	} -result $expected
    }
}

# We test the error messages and codes thrown by the parser for a
# variety of failure possibilities.

TestFilesProcess $mytestdir fail docidx emsg -> n label input data expected {
    test doctools-idx-import-plugin-docidx-22.$n "doctools::idx::import text /docidx, $label, error message" -setup {
	doctools::idx::import I
	foreach {n v} $mytestconfig { I config set $n $v }
	foreach p $mytestincludes   { I include add $p }
    } -body {
	I import text $data docidx
    } -cleanup {
	I destroy
    } -returnCodes error -result $expected
}

TestFilesProcess $mytestdir fail docidx ecode -> n label input data expected {
    test doctools-idx-import-plugin-docidx-23.$n "doctools::idx::import text /docidx, $label, error code" -setup {
	doctools::idx::import I
	foreach {n v} $mytestconfig { I config set $n $v }
	foreach p $mytestincludes   { I include add $p }
    } -body {
	# Catch and rethrow using the error code as new message.
	catch {	I import text $data docidx }
	set ::errorCode
    } -cleanup {
	I destroy
    } -result $expected
}

TestFilesProcess $mytestdir fail docidx emsg -> n label input data expected {
    test doctools-idx-import-plugin-docidx-24.$n "doctools::idx::import file /docidx, $label, error message" -setup {
	doctools::idx::import I
	foreach {n v} $mytestconfig { I config set $n $v }
	foreach p $mytestincludes   { I include add $p }
    } -body {
	I import file $input docidx
    } -cleanup {
	I destroy
    } -returnCodes error -result $expected
}

TestFilesProcess $mytestdir fail docidx ecode -> n label input data expected {
    test doctools-idx-import-plugin-docidx-25.$n "doctools::idx::import file /docidx, $label, error code" -setup {
	doctools::idx::import I
	foreach {n v} $mytestconfig { I config set $n $v }
	foreach p $mytestincludes   { I include add $p }
    } -body {
	# Catch and rethrow using the error code as new message.
	catch {	I import file $input docidx }
	set ::errorCode
    } -cleanup {
	I destroy
    } -result $expected
}

# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# text markup - This is not an importable format.

# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# json - Java Script Object Notation

# We are checking that the various forms of json markup, as can be
# generated by doctools::idx(::export(::json)) are valid input to the
# json parser.
#
# section {} holds the non-canonical input we have to accept and make
# canonical to higher layers.

foreach {k section} {
    0 {}
    1 -ultracompact
    2 -indented
    3 -indalign
} {
    TestFilesProcess $mytestdir ok json$section serial-print -> n label input data expected {
	test doctools-idx-import-plugin-json-26.$k.$n "doctools::idx::import text /json, $label$section, ok" -setup {
	    doctools::idx::import I
	} -body {
	    doctools::idx::structure print [I import text $data json]
	} -cleanup {
	I destroy
    } -result $expected
    }

    TestFilesProcess $mytestdir ok json$section serial-print -> n label input data expected {
	test doctools-idx-import-plugin-json-27.$k.$n "doctools::idx::import file /json, $label$section, ok" -setup {
	    doctools::idx::import I
	} -body {
	    doctools::idx::structure print [I import file $input json]
	} -cleanup {
	I destroy
    } -result $expected
    }
}

# -------------------------------------------------------------------------

# We test the error messages and codes thrown by the parser for a
# variety of failure possibilities.

TestFilesProcess $mytestdir fail json json-emsg -> n label input data expected {
    test doctools-idx-import-plugin-json-28.$n "doctools::idx::import text /json, $label, error message" -setup {
	doctools::idx::import I
    } -body {
	I import text $data json
    } -cleanup {
	I destroy
    } -returnCodes error -result $expected
}

# -------------------------------------------------------------------------
unset mytestdir n label input data expected
return