summaryrefslogtreecommitdiffstats
path: root/test/QT
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2015-09-21 17:03:12 (GMT)
committerWilliam Deegan <bill@baddogconsulting.com>2015-09-21 17:03:12 (GMT)
commit0941093e0e5a030faa49968457638a3a6aee7ad8 (patch)
tree6d33513c14eb6eac0531dd050de0ecca4c39bd79 /test/QT
downloadSCons-2.4.0.zip
SCons-2.4.0.tar.gz
SCons-2.4.0.tar.bz2
release 2.4.02.4.0
Diffstat (limited to 'test/QT')
-rw-r--r--test/QT/CPPPATH-appended.py81
-rw-r--r--test/QT/CPPPATH.py71
-rw-r--r--test/QT/QTFLAGS.py207
-rw-r--r--test/QT/Tool.py157
-rw-r--r--test/QT/copied-env.py83
-rw-r--r--test/QT/empty-env.py77
-rw-r--r--test/QT/generated-ui.py135
-rw-r--r--test/QT/installed.py218
-rw-r--r--test/QT/manual.py147
-rw-r--r--test/QT/moc-from-cpp.py105
-rw-r--r--test/QT/moc-from-header.py105
-rw-r--r--test/QT/reentrant.py73
-rw-r--r--test/QT/source-from-ui.py156
-rw-r--r--test/QT/up-to-date.py146
-rw-r--r--test/QT/warnings.py105
15 files changed, 1866 insertions, 0 deletions
diff --git a/test/QT/CPPPATH-appended.py b/test/QT/CPPPATH-appended.py
new file mode 100644
index 0000000..2780921
--- /dev/null
+++ b/test/QT/CPPPATH-appended.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test that an appended relative CPPPATH works with generated files.
+
+This is basically the same as CPPPATH.py, but the include path
+is env.Append-ed and everything goes into sub directory "sub".
+"""
+
+import os.path
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.subdir('sub', ['sub', 'local_include'])
+
+test.Qt_dummy_installation()
+
+aaa_exe = os.path.join('sub', 'aaa' + TestSCons._exe)
+
+test.Qt_create_SConstruct('SConstruct')
+
+test.write('SConscript', r"""
+SConscript('sub/SConscript')
+""")
+
+test.write(['sub', 'SConscript'], r"""
+Import("env")
+env.Append(CPPPATH=['./local_include'])
+env.Program(target = 'aaa', source = 'aaa.cpp')
+""")
+
+test.write(['sub', 'aaa.cpp'], r"""
+#include "aaa.h"
+int main() { aaa(); return 0; }
+""")
+
+test.write(['sub', 'aaa.h'], r"""
+#include "my_qobject.h"
+#include "local_include.h"
+void aaa(void) Q_OBJECT;
+""")
+
+test.write(['sub', 'local_include', 'local_include.h'], r"""
+/* empty; just needs to be found */
+""")
+
+test.run(arguments = aaa_exe)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/QT/CPPPATH.py b/test/QT/CPPPATH.py
new file mode 100644
index 0000000..4ea42bd
--- /dev/null
+++ b/test/QT/CPPPATH.py
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test that an overwritten CPPPATH works with generated files.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.subdir('local_include')
+
+test.Qt_dummy_installation()
+
+aaa_exe = 'aaa' + TestSCons._exe
+
+test.Qt_create_SConstruct('SConstruct')
+
+test.write('SConscript', """\
+Import("env")
+env.Program(target = 'aaa', source = 'aaa.cpp', CPPPATH=['$CPPPATH', './local_include'])
+""")
+
+test.write('aaa.cpp', r"""
+#include "aaa.h"
+int main() { aaa(); return 0; }
+""")
+
+test.write('aaa.h', r"""
+#include "my_qobject.h"
+#include "local_include.h"
+void aaa(void) Q_OBJECT;
+""")
+
+test.write(['local_include', 'local_include.h'], r"""
+/* empty; just needs to be found */
+""")
+
+test.run(arguments = aaa_exe)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/QT/QTFLAGS.py b/test/QT/QTFLAGS.py
new file mode 100644
index 0000000..008397a
--- /dev/null
+++ b/test/QT/QTFLAGS.py
@@ -0,0 +1,207 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Testing the configuration mechanisms of the 'qt' tool.
+"""
+
+import TestSCons
+
+_python_ = TestSCons._python_
+_exe = TestSCons._exe
+
+test = TestSCons.TestSCons()
+
+test.subdir( 'qt', ['qt', 'bin'], ['qt', 'include'], ['qt', 'lib'],
+ 'work1', 'work2')
+
+test.Qt_dummy_installation()
+
+test.run(chdir=test.workpath('qt','lib'), arguments = '.',
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall)
+
+QT = test.workpath('qt')
+QT_LIB = 'myqt'
+QT_MOC = '%s %s' % (_python_, test.workpath('qt','bin','mymoc.py'))
+QT_UIC = '%s %s' % (_python_, test.workpath('qt','bin','myuic.py'))
+
+def createSConstruct(test,place,overrides):
+ test.write(place, """
+env = Environment(QTDIR = r'%s',
+ QT_LIB = r'%s',
+ QT_MOC = r'%s',
+ QT_UIC = r'%s',
+ %s
+ tools=['default','qt'])
+if ARGUMENTS.get('variant_dir', 0):
+ if ARGUMENTS.get('chdir', 0):
+ SConscriptChdir(1)
+ else:
+ SConscriptChdir(0)
+ VariantDir('build', '.', duplicate=1)
+ sconscript = Dir('build').File('SConscript')
+else:
+ sconscript = File('SConscript')
+Export("env")
+SConscript( sconscript )
+""" % (QT, QT_LIB, QT_MOC, QT_UIC, overrides))
+
+
+createSConstruct(test, ['work1', 'SConstruct'],
+ """QT_UICIMPLFLAGS='-x',
+ QT_UICDECLFLAGS='-y',
+ QT_MOCFROMHFLAGS='-z',
+ QT_MOCFROMCXXFLAGS='-i -w',
+ QT_UICDECLPREFIX='uic-',
+ QT_UICDECLSUFFIX='.hpp',
+ QT_UICIMPLPREFIX='',
+ QT_UICIMPLSUFFIX='.cxx',
+ QT_MOCHPREFIX='mmm',
+ QT_MOCHSUFFIX='.cxx',
+ QT_MOCCXXPREFIX='moc',
+ QT_MOCCXXSUFFIX='.inl',
+ QT_UISUFFIX='.myui',""")
+test.write(['work1', 'SConscript'],"""
+Import("env")
+env.Program('mytest', ['mocFromH.cpp',
+ 'mocFromCpp.cpp',
+ 'an_ui_file.myui',
+ 'another_ui_file.myui',
+ 'main.cpp'])
+""")
+
+test.write(['work1', 'mocFromH.hpp'], """
+#include "my_qobject.h"
+void mocFromH() Q_OBJECT
+""")
+
+test.write(['work1', 'mocFromH.cpp'], """
+#include "mocFromH.hpp"
+""")
+
+test.write(['work1', 'mocFromCpp.cpp'], """
+#include "my_qobject.h"
+void mocFromCpp() Q_OBJECT
+#include "mocmocFromCpp.inl"
+""")
+
+test.write(['work1', 'an_ui_file.myui'], """
+void an_ui_file()
+""")
+
+test.write(['work1', 'another_ui_file.myui'], """
+void another_ui_file()
+""")
+
+test.write(['work1', 'another_ui_file.desc.hpp'], """
+/* just a dependency checker */
+""")
+
+test.write(['work1', 'main.cpp'], """
+#include "mocFromH.hpp"
+#include "uic-an_ui_file.hpp"
+#include "uic-another_ui_file.hpp"
+void mocFromCpp();
+
+int main() {
+ mocFromH();
+ mocFromCpp();
+ an_ui_file();
+ another_ui_file();
+}
+""")
+
+test.run(chdir = 'work1', arguments = "mytest" + _exe)
+
+test.must_exist(['work1', 'mmmmocFromH.cxx'],
+ ['work1', 'mocmocFromCpp.inl'],
+ ['work1', 'an_ui_file.cxx'],
+ ['work1', 'uic-an_ui_file.hpp'],
+ ['work1', 'mmman_ui_file.cxx'],
+ ['work1', 'another_ui_file.cxx'],
+ ['work1', 'uic-another_ui_file.hpp'],
+ ['work1', 'mmmanother_ui_file.cxx'])
+
+def _flagTest(test,fileToContentsStart):
+ for f,c in fileToContentsStart.items():
+ if test.read(test.workpath('work1', f)).find(c) != 0:
+ return 1
+ return 0
+
+test.fail_test(_flagTest(test, {'mmmmocFromH.cxx':'/* mymoc.py -z */',
+ 'mocmocFromCpp.inl':'/* mymoc.py -w */',
+ 'an_ui_file.cxx':'/* myuic.py -x */',
+ 'uic-an_ui_file.hpp':'/* myuic.py -y */',
+ 'mmman_ui_file.cxx':'/* mymoc.py -z */'}))
+
+test.write(['work2', 'SConstruct'], """
+import os.path
+env1 = Environment(tools=['qt'],
+ QTDIR = r'%(QTDIR)s',
+ QT_BINPATH='$QTDIR/bin64',
+ QT_LIBPATH='$QTDIR/lib64',
+ QT_CPPPATH='$QTDIR/h64')
+
+cpppath = env1.subst('$CPPPATH')
+if os.path.normpath(cpppath) != os.path.join(r'%(QTDIR)s', 'h64'):
+ print cpppath
+ Exit(1)
+libpath = env1.subst('$LIBPATH')
+if os.path.normpath(libpath) != os.path.join(r'%(QTDIR)s', 'lib64'):
+ print libpath
+ Exit(2)
+qt_moc = env1.subst('$QT_MOC')
+if os.path.normpath(qt_moc) != os.path.join(r'%(QTDIR)s', 'bin64', 'moc'):
+ print qt_moc
+ Exit(3)
+
+env2 = Environment(tools=['default', 'qt'],
+ QTDIR = None,
+ QT_LIB = None,
+ QT_CPPPATH = None,
+ QT_LIBPATH = None)
+
+env2.Program('main.cpp')
+""" % {'QTDIR':QT})
+
+test.write(['work2', 'main.cpp'], """
+int main() { return 0; }
+""")
+
+# Ignore stderr, because if Qt is not installed,
+# there may be a warning about an empty QTDIR on stderr.
+test.run(chdir='work2', stderr=None)
+
+test.must_exist(['work2', 'main' + _exe])
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/QT/Tool.py b/test/QT/Tool.py
new file mode 100644
index 0000000..63fb113
--- /dev/null
+++ b/test/QT/Tool.py
@@ -0,0 +1,157 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Verify that applying env.Tool('qt') after running Configure checks
+works properly. This was broken in 0.96.95.
+
+The configuration here is a moderately stripped-down version of the
+real-world configuration for lprof (lprof.sourceforge.net). It's probably
+not completely minimal, but we're leaving it as-is since it represents a
+good real-world sanity check on the interaction of some key subsystems.
+"""
+
+import os
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+if not os.environ.get('QTDIR', None):
+ x ="External environment variable $QTDIR not set; skipping test(s).\n"
+ test.skip_test(x)
+
+test.write('SConstruct', """
+import os
+
+def DoWithVariables(variables, prefix, what):
+ saved_variables = { }
+ for name in variables.keys():
+ saved_variables[ name ] = env[ name ][:]
+ env[ name ].append(variables[ name ])
+
+ result = what()
+
+ for name in saved_variables.keys():
+ env[ name ] = saved_variables[ name ]
+ env[ prefix+name ] = variables[ name ]
+
+ return result
+
+def CheckForQtAt(context, qtdir):
+ context.Message('Checking for Qt at %s... ' % qtdir)
+ libp = os.path.join(qtdir, 'lib')
+ cppp = os.path.join(qtdir, 'include')
+ result = AttemptLinkWithVariables(context,
+ { "LIBS": "qt-mt", "LIBPATH": libp , "CPPPATH": cppp },
+ '''
+#include <qapplication.h>
+int main(int argc, char **argv) {
+ QApplication qapp(argc, argv);
+ return 0;
+}
+''',".cpp","QT_")
+ context.Result(result)
+ return result
+
+def CheckForQt(context):
+ # list is currently POSIX centric - what happens with Windows?
+ potential_qt_dirs = [
+ "/usr/share/qt3", # Debian unstable
+ "/usr/share/qt",
+ "/usr",
+ "/usr/local",
+ "/usr/lib/qt3", # Suse
+ "/usr/lib/qt",
+ "/usr/qt/3", # Gentoo
+ "/usr/pkg/qt3" # pkgsrc (NetBSD)
+ ]
+
+ if 'QTDIR' in os.environ:
+ potential_qt_dirs.insert(0, os.environ[ 'QTDIR' ])
+
+ if env[ 'qt_directory' ] != "/":
+ uic_path = os.path.join(env['qt_directory'], 'bin', 'uic')
+ if os.path.isfile(uic_path):
+ potential_qt_dirs.insert(0, env[ 'qt_directory' ])
+ else:
+ print "QT not found. Invalid qt_directory value - failed to find uic."
+ return 0
+
+ for i in potential_qt_dirs:
+ context.env.Replace(QTDIR = i)
+ if CheckForQtAt(context, i):
+ # additional checks to validate QT installation
+ if not os.path.isfile(os.path.join(i, 'bin', 'uic')):
+ print "QT - failed to find uic."
+ return 0
+ if not os.path.isfile(os.path.join(i, 'bin', 'moc')):
+ print "QT - failed to find moc."
+ return 0
+ if not os.path.exists(os.path.join(i, 'lib')):
+ print "QT - failed to find QT lib path."
+ return 0
+ if not os.path.exists(os.path.join(i, 'include')):
+ print "QT - failed to find QT include path."
+ return 0
+ return 1
+ else:
+ if i==env['qt_directory']:
+ print "QT directory not valid. Failed QT test build."
+ return 0
+ return 0
+
+def AttemptLinkWithVariables(context, variables, code, extension, prefix):
+ return DoWithVariables(variables, prefix,
+ lambda: context.TryLink(code, extension))
+
+env = Environment(CPPPATH=['.'], LIBPATH=['.'], LIBS=[])
+
+opts = Variables('lprof.conf')
+opts.Add(PathVariable("qt_directory", "Path to Qt directory", "/"))
+opts.Update(env)
+
+env['QT_LIB'] = 'qt-mt'
+config = env.Configure(custom_tests = {
+ 'CheckForQt' : CheckForQt,
+})
+
+if not config.CheckForQt():
+ print "Failed to find valid QT environment."
+ Exit(1)
+
+env.Tool('qt', ['$TOOL_PATH'])
+""")
+
+test.run(arguments = '.')
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/QT/copied-env.py b/test/QT/copied-env.py
new file mode 100644
index 0000000..efa91be
--- /dev/null
+++ b/test/QT/copied-env.py
@@ -0,0 +1,83 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test Qt with a copied construction environment.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.Qt_dummy_installation()
+
+test.Qt_create_SConstruct('SConstruct')
+
+test.write('SConscript', """\
+Import("env")
+env.Append(CPPDEFINES = ['FOOBAZ'])
+
+copy = env.Clone()
+copy.Append(CPPDEFINES = ['MYLIB_IMPL'])
+
+copy.SharedLibrary(
+ target = 'MyLib',
+ source = ['MyFile.cpp','MyForm.ui']
+)
+""")
+
+test.write('MyFile.h', r"""
+void aaa(void);
+""")
+
+test.write('MyFile.cpp', r"""
+#include "MyFile.h"
+void useit() {
+ aaa();
+}
+""")
+
+test.write('MyForm.ui', r"""
+void aaa(void)
+""")
+
+test.run()
+
+moc_MyForm = [x for x in test.stdout().split('\n') if x.find('moc_MyForm') != -1]
+
+MYLIB_IMPL = [x for x in moc_MyForm if x.find('MYLIB_IMPL') != -1]
+
+if not MYLIB_IMPL:
+ print "Did not find MYLIB_IMPL on moc_MyForm compilation line:"
+ print test.stdout()
+ test.fail_test()
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/QT/empty-env.py b/test/QT/empty-env.py
new file mode 100644
index 0000000..77547e7
--- /dev/null
+++ b/test/QT/empty-env.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test Qt creation from a copied empty environment.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.Qt_dummy_installation('qt')
+
+test.write('SConstruct', """\
+orig = Environment()
+env = orig.Clone(QTDIR = r'%s',
+ QT_LIB = r'%s',
+ QT_MOC = r'%s',
+ QT_UIC = r'%s',
+ tools=['qt'])
+env.Program('main', 'main.cpp', CPPDEFINES=['FOO'], LIBS=[])
+""" % (test.QT, test.QT_LIB, test.QT_MOC, test.QT_UIC))
+
+test.write('main.cpp', r"""
+#include "foo6.h"
+int main() { foo6(); return 0; }
+""")
+
+test.write(['qt', 'include', 'foo6.h'], """\
+#include <stdio.h>
+void
+foo6(void)
+{
+#ifdef FOO
+ printf("qt/include/foo6.h\\n");
+#endif
+}
+""")
+
+# we can receive warnings about a non detected qt (empty QTDIR)
+# these are not critical, but may be annoying.
+test.run(stderr=None)
+
+test.run(program = test.workpath('main' + TestSCons._exe),
+ stderr = None,
+ stdout = 'qt/include/foo6.h\n')
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/QT/generated-ui.py b/test/QT/generated-ui.py
new file mode 100644
index 0000000..e4632b1
--- /dev/null
+++ b/test/QT/generated-ui.py
@@ -0,0 +1,135 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test that the UI scanning logic correctly picks up scansG
+"""
+
+import os
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+if not os.environ.get('QTDIR', None):
+ x ="External environment variable $QTDIR not set; skipping test(s).\n"
+ test.skip_test(x)
+
+test.subdir(['layer'],
+ ['layer', 'aclock'],
+ ['layer', 'aclock', 'qt_bug'])
+
+test.write(['SConstruct'], """\
+import os
+aa=os.getcwd()
+
+env=Environment(tools=['default','expheaders','qt'],toolpath=[aa])
+if 'HOME' in os.environ:
+ env['ENV']['HOME'] = os.environ['HOME']
+env["EXP_HEADER_ABS"]=os.path.join(os.getcwd(),'include')
+if not os.access(env["EXP_HEADER_ABS"],os.F_OK):
+ os.mkdir (env["EXP_HEADER_ABS"])
+Export('env')
+env.SConscript('layer/aclock/qt_bug/SConscript')
+""")
+
+test.write(['expheaders.py'], """\
+import SCons.Defaults
+def ExpHeaderScanner(node, env, path):
+ return []
+def generate(env):
+ HeaderAction=SCons.Action.Action([SCons.Defaults.Copy('$TARGET','$SOURCE'),SCons.Defaults.Chmod('$TARGET',0755)])
+ HeaderBuilder= SCons.Builder.Builder(action=HeaderAction)
+ env['BUILDERS']['ExportHeaders'] = HeaderBuilder
+def exists(env):
+ return 0
+""")
+
+test.write(['layer', 'aclock', 'qt_bug', 'SConscript'], """\
+import os
+
+Import ("env")
+#src=os.path.join(env.Dir('.').srcnode().abspath, 'testfile.h')
+env.ExportHeaders(os.path.join(env["EXP_HEADER_ABS"],'main.h'), 'main.h')
+env.ExportHeaders(os.path.join(env["EXP_HEADER_ABS"],'migraform.h'), 'migraform.h')
+env.Append(CPPPATH=env["EXP_HEADER_ABS"])
+env.StaticLibrary('all',['main.ui','migraform.ui'])
+""")
+
+test.write(['layer', 'aclock', 'qt_bug', 'main.ui'], """\
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>Main</class>
+<widget class="QWizard">
+ <property name="name">
+ <cstring>Main</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>600</width>
+ <height>385</height>
+ </rect>
+ </property>
+</widget>
+<includes>
+ <include location="local" impldecl="in implementation">migraform.h</include>
+</includes>
+</UI>
+""")
+
+test.write(['layer', 'aclock', 'qt_bug', 'migraform.ui'], """\
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>MigrateForm</class>
+<widget class="QWizard">
+ <property name="name">
+ <cstring>MigrateForm</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>%s</width>
+ <height>385</height>
+ </rect>
+ </property>
+</widget>
+</UI>
+""")
+
+test.run(arguments = '.',
+ stderr = TestSCons.noisy_ar,
+ match = TestSCons.match_re_dotall)
+
+test.up_to_date(arguments = '.')
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/QT/installed.py b/test/QT/installed.py
new file mode 100644
index 0000000..2661377
--- /dev/null
+++ b/test/QT/installed.py
@@ -0,0 +1,218 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Look if qt is installed, and try out all builders.
+"""
+
+import os
+import sys
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+if not os.environ.get('QTDIR', None):
+ x ="External environment variable $QTDIR not set; skipping test(s).\n"
+ test.skip_test(x)
+
+test.Qt_dummy_installation()
+
+QTDIR=os.environ['QTDIR']
+
+
+test.write('SConstruct', """\
+import os
+dummy_env = Environment()
+ENV = dummy_env['ENV']
+try:
+ PATH=ARGUMENTS['PATH']
+ if 'PATH' in ENV:
+ ENV_PATH = PATH + os.pathsep + ENV['PATH']
+ else:
+ Exit(0) # this is certainly a weird system :-)
+except KeyError:
+ ENV_PATH=ENV.get('PATH', '')
+
+env = Environment(tools=['default','qt'],
+ ENV={'PATH':ENV_PATH,
+ 'PATHEXT':os.environ.get('PATHEXT'),
+ 'HOME':os.getcwd(),
+ 'SystemRoot':ENV.get('SystemRoot')},
+ # moc / uic want to write stuff in ~/.qt
+ CXXFILESUFFIX=".cpp")
+
+conf = env.Configure()
+if not conf.CheckLib(env.subst("$QT_LIB"), autoadd=0):
+ conf.env['QT_LIB'] = 'qt-mt'
+ if not conf.CheckLib(env.subst("$QT_LIB"), autoadd=0):
+ Exit(0)
+env = conf.Finish()
+VariantDir('bld', '.')
+env.Program('bld/test_realqt', ['bld/mocFromCpp.cpp',
+ 'bld/mocFromH.cpp',
+ 'bld/anUiFile.ui',
+ 'bld/main.cpp'])
+""")
+
+test.write('mocFromCpp.h', """\
+void mocFromCpp();
+""")
+
+test.write('mocFromCpp.cpp', """\
+#include <qobject.h>
+#include "mocFromCpp.h"
+class MyClass1 : public QObject {
+ Q_OBJECT
+ public:
+ MyClass1() : QObject() {};
+ public slots:
+ void myslot() {};
+};
+void mocFromCpp() {
+ MyClass1 myclass;
+}
+#include "mocFromCpp.moc"
+""")
+
+test.write('mocFromH.h', """\
+#include <qobject.h>
+class MyClass2 : public QObject {
+ Q_OBJECT;
+ public:
+ MyClass2();
+ public slots:
+ void myslot();
+};
+void mocFromH();
+""")
+
+test.write('mocFromH.cpp', """\
+#include "mocFromH.h"
+
+MyClass2::MyClass2() : QObject() {}
+void MyClass2::myslot() {}
+void mocFromH() {
+ MyClass2 myclass;
+}
+""")
+
+test.write('anUiFile.ui', """\
+<!DOCTYPE UI><UI>
+<class>MyWidget</class>
+<widget>
+ <class>QWidget</class>
+ <property name="name">
+ <cstring>MyWidget</cstring>
+ </property>
+ <property name="caption">
+ <string>MyWidget</string>
+ </property>
+</widget>
+<includes>
+ <include location="local" impldecl="in implementation">anUiFile.ui.h</include>
+</includes>
+<slots>
+ <slot>testSlot()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
+""")
+
+test.write('anUiFile.ui.h', r"""
+#include <stdio.h>
+#if QT_VERSION >= 0x030100
+void MyWidget::testSlot()
+{
+ printf("Hello World\n");
+}
+#endif
+""")
+
+test.write('main.cpp', r"""
+#include <qapp.h>
+#include "mocFromCpp.h"
+#include "mocFromH.h"
+#include "anUiFile.h"
+#include <stdio.h>
+
+int main(int argc, char **argv) {
+ QApplication app(argc, argv);
+ mocFromCpp();
+ mocFromH();
+ MyWidget mywidget;
+#if QT_VERSION >= 0x030100
+ mywidget.testSlot();
+#else
+ printf("Hello World\n");
+#endif
+ return 0;
+}
+""")
+
+test.run(arguments="bld/test_realqt" + TestSCons._exe)
+
+
+test.run(program=test.workpath("bld", "test_realqt"),
+ stdout=None,
+ status=None,
+ stderr=None)
+
+if test.stdout() != "Hello World\n" or test.stderr() != '' or test.status:
+ sys.stdout.write(test.stdout())
+ sys.stderr.write(test.stderr())
+ # The test might be run on a system that doesn't have an X server
+ # running, or may be run by an ID that can't connect to the server.
+ # If so, then print whatever it showed us (which is in and of itself
+ # an indication that it built correctly) but don't fail the test.
+ expect = 'cannot connect to X server'
+ test.fail_test(test.stdout())
+ test.fail_test(test.stderr().find(expect) == -1)
+ if test.status != 1 and (test.status>>8) != 1:
+ sys.stdout.write('test_realqt returned status %s\n' % test.status)
+ test.fail_test()
+
+QTDIR = os.environ['QTDIR']
+PATH = os.environ['PATH']
+os.environ['QTDIR']=''
+os.environ['PATH']='.'
+
+test.run(stderr=None, arguments="-c bld/test_realqt" + TestSCons._exe)
+
+expect1 = "scons: warning: Could not detect qt, using empty QTDIR"
+expect2 = "scons: warning: Could not detect qt, using moc executable as a hint"
+
+test.fail_test(test.stderr().find(expect1) == -1 and
+ test.stderr().find(expect2) == -1)
+
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/QT/manual.py b/test/QT/manual.py
new file mode 100644
index 0000000..ff38f32
--- /dev/null
+++ b/test/QT/manual.py
@@ -0,0 +1,147 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test the manual QT builder calls.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.subdir('include', 'ui')
+
+test.Qt_dummy_installation()
+
+aaa_exe = 'aaa' + TestSCons._exe
+
+test.Qt_create_SConstruct('SConstruct')
+
+test.write('SConscript', r"""
+Import("env")
+sources = ['aaa.cpp', 'bbb.cpp', 'ddd.cpp', 'eee.cpp', 'main.cpp']
+
+# normal invocation
+sources.append(env.Moc('include/aaa.h'))
+env.Moc('bbb.cpp')
+sources.extend(env.Uic('ui/ccc.ui')[1:])
+
+# manual target specification
+sources.append(env.Moc('moc-ddd.cpp', 'include/ddd.h',
+ QT_MOCHPREFIX='')) # Watch out !
+env.Moc('moc_eee.cpp', 'eee.cpp')
+sources.extend(env.Uic(['include/uic_fff.hpp', 'fff.cpp', 'fff.moc.cpp'],
+ 'ui/fff.ui')[1:])
+
+print list(map(str,sources))
+env.Program(target='aaa',
+ source=sources,
+ CPPPATH=['$CPPPATH', './include'],
+ QT_AUTOSCAN=0)
+""")
+
+test.write('aaa.cpp', r"""
+#include "aaa.h"
+""")
+
+test.write(['include', 'aaa.h'], r"""
+#include "my_qobject.h"
+void aaa(void) Q_OBJECT;
+""")
+
+test.write('bbb.h', r"""
+void bbb(void);
+""")
+
+test.write('bbb.cpp', r"""
+#include "my_qobject.h"
+void bbb(void) Q_OBJECT
+#include "bbb.moc"
+""")
+
+test.write(['ui', 'ccc.ui'], r"""
+void ccc(void)
+""")
+
+test.write('ddd.cpp', r"""
+#include "ddd.h"
+""")
+
+test.write(['include', 'ddd.h'], r"""
+#include "my_qobject.h"
+void ddd(void) Q_OBJECT;
+""")
+
+test.write('eee.h', r"""
+void eee(void);
+""")
+
+test.write('eee.cpp', r"""
+#include "my_qobject.h"
+void eee(void) Q_OBJECT
+#include "moc_eee.cpp"
+""")
+
+test.write(['ui', 'fff.ui'], r"""
+void fff(void)
+""")
+
+test.write('main.cpp', r"""
+#include "aaa.h"
+#include "bbb.h"
+#include "ui/ccc.h"
+#include "ddd.h"
+#include "eee.h"
+#include "uic_fff.hpp"
+
+int main() {
+ aaa(); bbb(); ccc(); ddd(); eee(); fff(); return 0;
+}
+""")
+
+test.run(arguments = aaa_exe)
+
+# normal invocation
+test.must_exist(test.workpath('include', 'moc_aaa.cc'))
+test.must_exist(test.workpath('bbb.moc'))
+test.must_exist(test.workpath('ui', 'ccc.h'))
+test.must_exist(test.workpath('ui', 'uic_ccc.cc'))
+test.must_exist(test.workpath('ui', 'moc_ccc.cc'))
+
+# manual target spec.
+test.must_exist(test.workpath('moc-ddd.cpp'))
+test.must_exist(test.workpath('moc_eee.cpp'))
+test.must_exist(test.workpath('include', 'uic_fff.hpp'))
+test.must_exist(test.workpath('fff.cpp'))
+test.must_exist(test.workpath('fff.moc.cpp'))
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/QT/moc-from-cpp.py b/test/QT/moc-from-cpp.py
new file mode 100644
index 0000000..1bd7b10
--- /dev/null
+++ b/test/QT/moc-from-cpp.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Create a moc file from a cpp file.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.Qt_dummy_installation()
+
+##############################################################################
+
+lib_aaa = TestSCons.lib_ + 'aaa' + TestSCons._lib
+moc = 'aaa.moc'
+
+test.Qt_create_SConstruct('SConstruct')
+
+test.write('SConscript', """
+Import("env dup")
+if dup == 0: env.Append(CPPPATH=['.'])
+env.StaticLibrary(target = '%s', source = ['aaa.cpp','useit.cpp'])
+""" % lib_aaa)
+
+test.write('aaa.h', r"""
+void aaa(void);
+""")
+
+test.write('aaa.cpp', r"""
+#include "my_qobject.h"
+void aaa(void) Q_OBJECT
+#include "%s"
+""" % moc)
+
+test.write('useit.cpp', r"""
+#include "aaa.h"
+void useit() {
+ aaa();
+}
+""")
+
+test.run(arguments=lib_aaa,
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall)
+
+test.up_to_date(options = '-n', arguments = lib_aaa)
+
+test.write('aaa.cpp', r"""
+#include "my_qobject.h"
+/* a change */
+void aaa(void) Q_OBJECT
+#include "%s"
+""" % moc)
+
+test.not_up_to_date(options = '-n', arguments = moc)
+
+test.run(options = '-c', arguments = lib_aaa)
+
+test.run(arguments = "variant_dir=1 " + test.workpath('build', lib_aaa),
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall)
+
+test.run(arguments = "variant_dir=1 chdir=1 " + test.workpath('build', lib_aaa))
+
+test.must_exist(test.workpath('build', moc))
+
+test.run(arguments = "variant_dir=1 dup=0 " +
+ test.workpath('build_dup0', lib_aaa),
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall)
+
+test.must_exist(test.workpath('build_dup0', moc))
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/QT/moc-from-header.py b/test/QT/moc-from-header.py
new file mode 100644
index 0000000..41b1b3d
--- /dev/null
+++ b/test/QT/moc-from-header.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Create a moc file from a header file.
+"""
+
+import os
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('SConstruct', """
+env = Environment()
+""")
+
+test.Qt_dummy_installation()
+
+# We'll run some test programs later that need to find our dummy
+# Qt library.
+os.environ['LD_LIBRARY_PATH'] = test.QT_LIB_DIR
+
+##############################################################################
+
+aaa_exe = 'aaa' + TestSCons._exe
+build_aaa_exe = test.workpath('build', aaa_exe)
+moc = 'moc_aaa.cc'
+
+test.Qt_create_SConstruct('SConstruct')
+
+test.write('SConscript', """\
+Import("env")
+env.Program(target = 'aaa', source = 'aaa.cpp')
+if env['PLATFORM'] == 'darwin':
+ env.Install('.', 'qt/lib/libmyqt.dylib')
+""")
+
+test.write('aaa.cpp', r"""
+#include "aaa.h"
+int main() { aaa(); return 0; }
+""")
+
+test.write('aaa.h', r"""
+#include "my_qobject.h"
+void aaa(void) Q_OBJECT;
+""")
+
+test.run()
+
+test.up_to_date(options = '-n', arguments=aaa_exe)
+
+test.up_to_date(options = '-n', arguments = aaa_exe)
+
+test.write('aaa.h', r"""
+/* a change */
+#include "my_qobject.h"
+void aaa(void) Q_OBJECT;
+""")
+
+test.not_up_to_date(options='-n', arguments = moc)
+
+test.run(program = test.workpath(aaa_exe), stdout = 'aaa.h\n')
+
+test.run(arguments = "variant_dir=1 " + build_aaa_exe)
+
+test.run(arguments = "variant_dir=1 chdir=1 " + build_aaa_exe)
+
+test.must_exist(test.workpath('build', moc))
+
+test.run(arguments = "variant_dir=1 chdir=1 dup=0 " +
+ test.workpath('build_dup0', aaa_exe) )
+
+test.must_exist(['build_dup0', moc])
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/QT/reentrant.py b/test/QT/reentrant.py
new file mode 100644
index 0000000..be464b9
--- /dev/null
+++ b/test/QT/reentrant.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test creation from a copied environment that already has QT variables.
+This makes sure the tool initialization is re-entrant.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.Qt_dummy_installation('qt')
+
+test.write(['qt', 'include', 'foo5.h'], """\
+#include <stdio.h>
+void
+foo5(void)
+{
+#ifdef FOO
+ printf("qt/include/foo5.h\\n");
+#endif
+}
+""")
+
+test.Qt_create_SConstruct('SConstruct')
+
+test.write('SConscript', """\
+Import("env")
+env = env.Clone(tools=['qt'])
+env.Program('main', 'main.cpp', CPPDEFINES=['FOO'], LIBS=[])
+""")
+
+test.write('main.cpp', r"""
+#include "foo5.h"
+int main() { foo5(); return 0; }
+""")
+
+test.run()
+
+test.run(program = test.workpath('main' + TestSCons._exe),
+ stdout = 'qt/include/foo5.h\n')
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/QT/source-from-ui.py b/test/QT/source-from-ui.py
new file mode 100644
index 0000000..b8be72e
--- /dev/null
+++ b/test/QT/source-from-ui.py
@@ -0,0 +1,156 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Create .cpp, .h, moc_....cpp from a .ui file.
+"""
+
+import os.path
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.Qt_dummy_installation()
+
+##############################################################################
+
+aaa_dll = TestSCons.dll_ + 'aaa' + TestSCons._dll
+moc = 'moc_aaa.cc'
+cpp = 'uic_aaa.cc'
+obj = TestSCons.shobj_ + os.path.splitext(cpp)[0] + TestSCons._shobj
+h = 'aaa.h'
+
+test.Qt_create_SConstruct('SConstruct')
+
+test.write('SConscript', """\
+Import("env dup")
+if dup == 0: env.Append(CPPPATH=['#', '.'])
+env.SharedLibrary(target = 'aaa', source = ['aaa.ui', 'useit.cpp'])
+""")
+
+test.write('aaa.ui', r"""
+#if defined (_WIN32) || defined(__CYGWIN__)
+#define DLLEXPORT __declspec(dllexport)
+#else
+#define DLLEXPORT
+#endif
+DLLEXPORT void aaa(void)
+""")
+
+test.write('useit.cpp', r"""
+#include "aaa.h"
+void useit() {
+ aaa();
+}
+""")
+
+test.run(arguments = aaa_dll)
+
+test.up_to_date(options='-n', arguments = aaa_dll)
+
+test.write('aaa.ui', r"""
+/* a change */
+#if defined (_WIN32) || defined(__CYGWIN__)
+#define DLLEXPORT __declspec(dllexport)
+#else
+#define DLLEXPORT
+#endif
+DLLEXPORT void aaa(void)
+""")
+
+test.not_up_to_date(options = '-n', arguments = moc)
+test.not_up_to_date(options = '-n', arguments = cpp)
+test.not_up_to_date(options = '-n', arguments = h)
+
+test.run(arguments = aaa_dll)
+
+test.write('aaa.ui', r"""
+void aaa(void)
+//<include>aaa.ui.h</include>
+""")
+
+# test that non-existant ui.h files are ignored (as uic does)
+test.run(arguments = aaa_dll)
+
+test.write('aaa.ui.h', r"""
+/* test dependency to .ui.h */
+""")
+
+test.run(arguments = aaa_dll)
+
+test.write('aaa.ui.h', r"""
+/* changed */
+""")
+
+test.not_up_to_date(options = '-n', arguments = obj)
+test.not_up_to_date(options = '-n', arguments = cpp)
+test.not_up_to_date(options = '-n', arguments = h)
+test.not_up_to_date(options = '-n', arguments = moc)
+
+# clean up
+test.run(arguments = '-c ' + aaa_dll)
+
+test.run(arguments = "variant_dir=1 " +
+ test.workpath('build', aaa_dll) )
+
+test.must_exist(test.workpath('build', moc))
+test.must_exist(test.workpath('build', cpp))
+test.must_exist(test.workpath('build', h))
+test.must_not_exist(test.workpath(moc))
+test.must_not_exist(test.workpath(cpp))
+test.must_not_exist(test.workpath(h))
+
+cppContents = test.read(test.workpath('build', cpp))
+test.fail_test(cppContents.find('#include "aaa.ui.h"') == -1)
+
+test.run(arguments = "variant_dir=1 chdir=1 " +
+ test.workpath('build', aaa_dll) )
+
+test.must_exist(test.workpath('build', moc))
+test.must_exist(test.workpath('build', cpp))
+test.must_exist(test.workpath('build', h))
+test.must_not_exist(test.workpath(moc))
+test.must_not_exist(test.workpath(cpp))
+test.must_not_exist(test.workpath(h))
+
+test.run(arguments = "variant_dir=1 chdir=1 dup=0 " +
+ test.workpath('build_dup0', aaa_dll) )
+
+test.must_exist(test.workpath('build_dup0',moc))
+test.must_exist(test.workpath('build_dup0',cpp))
+test.must_exist(test.workpath('build_dup0',h))
+test.must_not_exist(test.workpath(moc))
+test.must_not_exist(test.workpath(cpp))
+test.must_not_exist(test.workpath(h))
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/QT/up-to-date.py b/test/QT/up-to-date.py
new file mode 100644
index 0000000..21c758e
--- /dev/null
+++ b/test/QT/up-to-date.py
@@ -0,0 +1,146 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Validate that a stripped-down real-world Qt configuation (thanks
+to Leanid Nazdrynau) with a generated .h file is correctly
+up-to-date after a build.
+
+(This catches a bug that was introduced during a signature refactoring
+ca. September 2005.)
+"""
+
+import os
+
+import TestSCons
+
+_obj = TestSCons._obj
+
+test = TestSCons.TestSCons()
+
+if not os.environ.get('QTDIR', None):
+ x ="External environment variable $QTDIR not set; skipping test(s).\n"
+ test.skip_test(x)
+
+test.subdir('layer',
+ ['layer', 'aclock'],
+ ['layer', 'aclock', 'qt_bug'])
+
+test.write('SConstruct', """\
+import os
+aa=os.getcwd()
+
+env=Environment(tools=['default','expheaders','qt'],toolpath=[aa])
+env["EXP_HEADER_ABS"]=os.path.join(os.getcwd(),'include')
+if not os.access(env["EXP_HEADER_ABS"],os.F_OK):
+ os.mkdir (env["EXP_HEADER_ABS"])
+Export('env')
+env.SConscript('layer/aclock/qt_bug/SConscript')
+""")
+
+test.write('expheaders.py', """\
+import SCons.Defaults
+def ExpHeaderScanner(node, env, path):
+ return []
+def generate(env):
+ HeaderAction=SCons.Action.Action([SCons.Defaults.Copy('$TARGET','$SOURCE'),SCons.Defaults.Chmod('$TARGET',0755)])
+ HeaderBuilder= SCons.Builder.Builder(action=HeaderAction)
+ env['BUILDERS']['ExportHeaders'] = HeaderBuilder
+def exists(env):
+ return 0
+""")
+
+test.write(['layer', 'aclock', 'qt_bug', 'SConscript'], """\
+import os
+
+Import ("env")
+env.ExportHeaders(os.path.join(env["EXP_HEADER_ABS"],'main.h'), 'main.h')
+env.ExportHeaders(os.path.join(env["EXP_HEADER_ABS"],'migraform.h'), 'migraform.h')
+env.Append(CPPPATH=env["EXP_HEADER_ABS"])
+env.StaticLibrary('all',['main.ui','migraform.ui','my.cc'])
+""")
+
+test.write(['layer', 'aclock', 'qt_bug', 'main.ui'], """\
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>Main</class>
+<widget class="QWizard">
+ <property name="name">
+ <cstring>Main</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>600</width>
+ <height>385</height>
+ </rect>
+ </property>
+</widget>
+<includes>
+ <include location="local" impldecl="in implementation">migraform.h</include>
+</includes>
+</UI>
+""")
+
+test.write(['layer', 'aclock', 'qt_bug', 'migraform.ui'], """\
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>MigrateForm</class>
+<widget class="QWizard">
+ <property name="name">
+ <cstring>MigrateForm</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>600</width>
+ <height>385</height>
+ </rect>
+ </property>
+</widget>
+</UI>
+""")
+
+test.write(['layer', 'aclock', 'qt_bug', 'my.cc'], """\
+#include <main.h>
+""")
+
+my_obj = 'layer/aclock/qt_bug/my'+_obj
+
+test.run(arguments = my_obj, stderr=None)
+
+expect = my_obj.replace( '/', os.sep )
+test.up_to_date(options = '--debug=explain',
+ arguments = (expect),
+ stderr=None)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/QT/warnings.py b/test/QT/warnings.py
new file mode 100644
index 0000000..a861b24
--- /dev/null
+++ b/test/QT/warnings.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test the Qt tool warnings.
+"""
+
+import os
+import re
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+SConstruct_path = test.workpath('SConstruct')
+
+test.Qt_dummy_installation()
+
+test.Qt_create_SConstruct(SConstruct_path)
+
+test.write('aaa.cpp', r"""
+#include "my_qobject.h"
+void aaa(void) Q_OBJECT
+""")
+
+test.write('SConscript', r"""
+Import("env")
+import os
+env.StaticLibrary('aaa.cpp')
+""")
+
+test.run(stderr=None)
+
+match12 = r"""
+scons: warning: Generated moc file 'aaa.moc' is not included by 'aaa.cpp'
+""" + TestSCons.file_expr
+
+if not re.search(match12, test.stderr()):
+ print "Did not find expected regular expression in stderr:"
+ print test.stderr()
+ test.fail_test()
+
+os.environ['QTDIR'] = test.QT
+
+test.run(arguments='-n noqtdir=1')
+
+# We'd like to eliminate $QTDIR from the environment as follows:
+# del os.environ['QTDIR']
+# But unfortunately, in at least some versions of Python, the Environment
+# class doesn't implement a __delitem__() method to make the library
+# call to actually remove the deleted variable from the *external*
+# environment, so it only gets removed from the Python dictionary.
+# Consequently, we need to just wipe out its value as follows>
+os.environ['QTDIR'] = ''
+test.run(stderr=None, arguments='-n noqtdir=1')
+
+moc = test.where_is('moc')
+if moc:
+ import os.path
+ qtdir = os.path.dirname(os.path.dirname(moc))
+ qtdir = qtdir.replace('\\', '\\\\' )
+
+ expect = """
+scons: warning: Could not detect qt, using moc executable as a hint \(QTDIR=%s\)
+File "%s", line \d+, in (\?|<module>)
+""" % (qtdir, re.escape(SConstruct_path))
+else:
+
+ expect = r"""
+scons: warning: Could not detect qt, using empty QTDIR
+File "%s", line \d+, in (\?|<module>)
+""" % re.escape(SConstruct_path)
+
+test.fail_test(not test.match_re(test.stderr(), expect))
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: