5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28 Look if qt is installed, and try out all builders.
36 test = TestSCons.TestSCons()
38 if not os.environ.get('QTDIR', None):
39 x ="External environment variable $QTDIR not set; skipping test(s).\n"
42 test.Qt_dummy_installation()
44 QTDIR=os.environ['QTDIR']
47 test.write('SConstruct', """\
49 dummy_env = Environment()
50 ENV = dummy_env['ENV']
52 PATH=ARGUMENTS['PATH']
54 ENV_PATH = PATH + os.pathsep + ENV['PATH']
56 Exit(0) # this is certainly a weird system :-)
58 ENV_PATH=ENV.get('PATH', '')
60 env = Environment(tools=['default','qt'],
62 'PATHEXT':os.environ.get('PATHEXT'),
64 'SystemRoot':ENV.get('SystemRoot')},
65 # moc / uic want to write stuff in ~/.qt
68 conf = env.Configure()
69 if not conf.CheckLib(env.subst("$QT_LIB"), autoadd=0):
70 conf.env['QT_LIB'] = 'qt-mt'
71 if not conf.CheckLib(env.subst("$QT_LIB"), autoadd=0):
74 VariantDir('bld', '.')
75 env.Program('bld/test_realqt', ['bld/mocFromCpp.cpp',
81 test.write('mocFromCpp.h', """\
85 test.write('mocFromCpp.cpp', """\
87 #include "mocFromCpp.h"
88 class MyClass1 : public QObject {
91 MyClass1() : QObject() {};
98 #include "mocFromCpp.moc"
101 test.write('mocFromH.h', """\
103 class MyClass2 : public QObject {
113 test.write('mocFromH.cpp', """\
114 #include "mocFromH.h"
116 MyClass2::MyClass2() : QObject() {}
117 void MyClass2::myslot() {}
123 test.write('anUiFile.ui', """\
125 <class>MyWidget</class>
127 <class>QWidget</class>
128 <property name="name">
129 <cstring>MyWidget</cstring>
131 <property name="caption">
132 <string>MyWidget</string>
136 <include location="local" impldecl="in implementation">anUiFile.ui.h</include>
139 <slot>testSlot()</slot>
141 <layoutdefaults spacing="6" margin="11"/>
145 test.write('anUiFile.ui.h', r"""
147 #if QT_VERSION >= 0x030100
148 void MyWidget::testSlot()
150 printf("Hello World\n");
155 test.write('main.cpp', r"""
157 #include "mocFromCpp.h"
158 #include "mocFromH.h"
159 #include "anUiFile.h"
162 int main(int argc, char **argv) {
163 QApplication app(argc, argv);
167 #if QT_VERSION >= 0x030100
170 printf("Hello World\n");
176 test.run(arguments="bld/test_realqt" + TestSCons._exe)
179 test.run(program=test.workpath("bld", "test_realqt"),
184 if test.stdout() != "Hello World\n" or test.stderr() != '' or test.status:
185 sys.stdout.write(test.stdout())
186 sys.stderr.write(test.stderr())
187 # The test might be run on a system that doesn't have an X server
188 # running, or may be run by an ID that can't connect to the server.
189 # If so, then print whatever it showed us (which is in and of itself
190 # an indication that it built correctly) but don't fail the test.
191 expect = 'cannot connect to X server'
192 test.fail_test(test.stdout())
193 test.fail_test(test.stderr().find(expect) == -1)
194 if test.status != 1 and (test.status>>8) != 1:
195 sys.stdout.write('test_realqt returned status %s\n' % test.status)
198 QTDIR = os.environ['QTDIR']
199 PATH = os.environ['PATH']
200 os.environ['QTDIR']=''
201 os.environ['PATH']='.'
203 test.run(stderr=None, arguments="-c bld/test_realqt" + TestSCons._exe)
205 expect1 = "scons: warning: Could not detect qt, using empty QTDIR"
206 expect2 = "scons: warning: Could not detect qt, using moc executable as a hint"
208 test.fail_test(test.stderr().find(expect1) == -1 and
209 test.stderr().find(expect2) == -1)
216 # indent-tabs-mode:nil
218 # vim: set expandtab tabstop=4 shiftwidth=4: