5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 Look if qt3 is installed, and try out all builders.
35 test
= TestSCons
.TestSCons()
37 if not os
.environ
.get('QTDIR', None):
38 x
="External environment variable $QTDIR not set; skipping test(s).\n"
41 test
.Qt_dummy_installation()
43 QTDIR
=os
.environ
['QTDIR']
46 test
.write('SConstruct', """\
48 dummy_env = Environment()
49 ENV = dummy_env['ENV']
51 PATH=ARGUMENTS['PATH']
53 ENV_PATH = PATH + os.pathsep + ENV['PATH']
55 Exit(0) # this is certainly a weird system :-)
57 ENV_PATH=ENV.get('PATH', '')
59 env = Environment(tools=['default','qt3'],
61 'PATHEXT':os.environ.get('PATHEXT'),
63 'SystemRoot':ENV.get('SystemRoot')},
64 # moc / uic want to write stuff in ~/.qt
67 conf = env.Configure()
68 if not conf.CheckLib(env.subst("$QT3_LIB"), autoadd=0):
69 conf.env['QT3_LIB'] = 'qt-mt'
70 if not conf.CheckLib(env.subst("$QT3_LIB"), autoadd=0):
73 VariantDir('bld', '.')
74 env.Program('bld/test_realqt', ['bld/mocFromCpp.cpp',
80 test
.write('mocFromCpp.h', """\
84 test
.write('mocFromCpp.cpp', """\
86 #include "mocFromCpp.h"
87 class MyClass1 : public QObject {
90 MyClass1() : QObject() {};
97 #include "mocFromCpp.moc"
100 test
.write('mocFromH.h', """\
102 class MyClass2 : public QObject {
112 test
.write('mocFromH.cpp', """\
113 #include "mocFromH.h"
115 MyClass2::MyClass2() : QObject() {}
116 void MyClass2::myslot() {}
122 test
.write('anUiFile.ui', """\
124 <class>MyWidget</class>
126 <class>QWidget</class>
127 <property name="name">
128 <cstring>MyWidget</cstring>
130 <property name="caption">
131 <string>MyWidget</string>
135 <include location="local" impldecl="in implementation">anUiFile.ui.h</include>
138 <slot>testSlot()</slot>
140 <layoutdefaults spacing="6" margin="11"/>
144 test
.write('anUiFile.ui.h', r
"""
146 #if QT_VERSION >= 0x030100
147 void MyWidget::testSlot()
149 printf("Hello World\n");
154 test
.write('main.cpp', r
"""
156 #include "mocFromCpp.h"
157 #include "mocFromH.h"
158 #include "anUiFile.h"
161 int main(int argc, char **argv) {
162 QApplication app(argc, argv);
166 #if QT_VERSION >= 0x030100
169 printf("Hello World\n");
175 test
.run(arguments
="--warn=no-tool-qt-deprecated bld/test_realqt" + TestSCons
._exe
)
178 program
=test
.workpath("bld", "test_realqt"),
179 arguments
="--warn=no-tool-qt-deprecated",
185 if test
.stdout() != "Hello World\n" or test
.stderr() != '' or test
.status
:
186 sys
.stdout
.write(test
.stdout())
187 sys
.stderr
.write(test
.stderr())
188 # The test might be run on a system that doesn't have an X server
189 # running, or may be run by an ID that can't connect to the server.
190 # If so, then print whatever it showed us (which is in and of itself
191 # an indication that it built correctly) but don't fail the test.
192 expect
= 'cannot connect to X server'
193 test
.fail_test(test
.stdout())
194 test
.fail_test(expect
not in test
.stderr())
195 if test
.status
!= 1 and (test
.status
>> 8) != 1:
196 sys
.stdout
.write('test_realqt returned status %s\n' % test
.status
)
199 QT3DIR
= os
.environ
['QTDIR']
200 PATH
= os
.environ
['PATH']
201 os
.environ
['QTDIR'] = ''
202 os
.environ
['PATH'] = '.'
206 arguments
="-c bld/test_realqt" + TestSCons
._exe
,
209 expect1
= "scons: warning: Could not detect qt3, using empty QT3DIR"
210 expect2
= "scons: warning: Could not detect qt3, using moc executable as a hint"
212 test
.fail_test(expect1
not in test
.stderr() and expect2
not in test
.stderr())
218 # indent-tabs-mode:nil
220 # vim: set expandtab tabstop=4 shiftwidth=4: