1
2
3
4
5
6
7
8
9
10
11
12
13
14 """Support for compiler test databases.
15
16 This module contains the 'CompilerTable' resource class which can be
17 used by compiler test databases to determine which compiler to test
18 based on context variables provided by the user."""
19
20
21
22
23
24 import compiler
25 import qm
26 from qm.test.database import get_database
27 from qm.test.resource import Resource
28 from local_host import LocalHost
29
30
31
32
33
35 """A map from programming languages to 'Compiler's.
36
37 The 'CompilerTable' resource uses the context to determine which
38 compilers the user wants to test. Test databases containing
39 compiler tests should arrange for the tests they compain to depend
40 on a 'CompilerTable' resource.
41
42 The first context variable which is examined is
43 'CompilerTable.languages'. The value should be a
44 whitespace-separated list of programming language names. (See
45 below for standardized names for some languages.)
46
47 Then, for each language 'l' in the list of languages, the
48 following context variables are examined:
49
50 - 'CompilerTable.l_kind'
51
52 The kind of compiler (e.g., "GCC" or "EDG") used to compile
53 programs of language 'l'. The 'kind' must name a class derived
54 from 'Compiler'.
55
56 - 'CompilerTable.l_path'
57
58 The path to the compiler for language 'l'. This path may be
59 either absolute or relative.
60
61 - 'CompilerTable.l_options'
62
63 A whitespace-separated list of command-line options to provide
64 to the compiler for language 'l'. These options are passed to
65 the constructor for the 'Compiler' object; generally, all tests
66 are run with these options, followed by any test-specific
67 options. For example, if the user wants to test the compiler
68 when run with '-O2', the user would put '-O2' in the 'l_options'
69 context variable.
70
71 The 'CompilerTable' resource provides the following context
72 variables to all tests that depend upon the resource:
73
74 - 'CompilerTable.compilers'
75
76 The 'compilers' variable is a map from language names to
77 instances of 'Compiler'. Test classes should obtain the
78 'Compiler' to use when compiling source files by using this
79 map.
80
81 - 'CompilerTable.target'
82
83 An instance of 'Host' that can be used to run compiler
84 programs."""
85
86 LANG_C = "c"
87 """The name of the C programming language."""
88
89 LANG_CPLUSPLUS = "cplusplus"
90 """The name of the C++ programming language."""
91
92 - def SetUp(self, context, result):
140