summaryrefslogtreecommitdiff
path: root/test/QT/qt3
diff options
context:
space:
mode:
Diffstat (limited to 'test/QT/qt3')
-rw-r--r--test/QT/qt3/CPPPATH-appended.py80
-rw-r--r--test/QT/qt3/CPPPATH.py70
-rw-r--r--test/QT/qt3/QTFLAGS.py219
-rw-r--r--test/QT/qt3/Tool.py156
-rw-r--r--test/QT/qt3/copied-env.py83
-rw-r--r--test/QT/qt3/empty-env.py78
-rw-r--r--test/QT/qt3/generated-ui.py135
-rw-r--r--test/QT/qt3/installed.py220
-rw-r--r--test/QT/qt3/manual.py148
-rw-r--r--test/QT/qt3/moc-from-cpp.py114
-rw-r--r--test/QT/qt3/moc-from-header.py109
-rw-r--r--test/QT/qt3/qt_warnings.py104
-rw-r--r--test/QT/qt3/reentrant.py74
-rw-r--r--test/QT/qt3/source-from-ui.py161
-rw-r--r--test/QT/qt3/up-to-date.py144
15 files changed, 1895 insertions, 0 deletions
diff --git a/test/QT/qt3/CPPPATH-appended.py b/test/QT/qt3/CPPPATH-appended.py
new file mode 100644
index 000000000..ee1808faf
--- /dev/null
+++ b/test/QT/qt3/CPPPATH-appended.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+#
+# MIT License
+#
+# Copyright The SCons Foundation
+#
+# 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.
+
+"""
+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(void) { 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='--warn=no-tool-qt-deprecated ' + 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/qt3/CPPPATH.py b/test/QT/qt3/CPPPATH.py
new file mode 100644
index 000000000..b56efad44
--- /dev/null
+++ b/test/QT/qt3/CPPPATH.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+#
+# MIT License
+#
+# Copyright The SCons Foundation
+#
+# 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.
+
+"""
+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(void) { 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='--warn=no-tool-qt-deprecated ' + 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/qt3/QTFLAGS.py b/test/QT/qt3/QTFLAGS.py
new file mode 100644
index 000000000..56536845f
--- /dev/null
+++ b/test/QT/qt3/QTFLAGS.py
@@ -0,0 +1,219 @@
+#!/usr/bin/env python
+#
+# MIT License
+#
+# Copyright The SCons Foundation
+#
+# 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.
+
+"""
+Testing the configuration mechanisms of the 'qt3' tool.
+"""
+
+import TestSCons
+
+_python_ = TestSCons._python_
+_exe = TestSCons._exe
+
+test = TestSCons.TestSCons()
+
+test.Qt_dummy_installation()
+test.subdir('work1', 'work2')
+
+test.run(
+ chdir=test.workpath('qt', 'lib'),
+ arguments=".",
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall,
+)
+
+QT3 = test.workpath('qt')
+QT3_LIB = 'myqt'
+QT3_MOC = '%s %s' % (_python_, test.workpath('qt', 'bin', 'mymoc.py'))
+QT3_UIC = '%s %s' % (_python_, test.workpath('qt', 'bin', 'myuic.py'))
+
+def createSConstruct(test, place, overrides):
+ test.write(place, """\
+env = Environment(
+ tools=['default','qt3'],
+ QT3DIR = r'%s',
+ QT3_LIB = r'%s',
+ QT3_MOC = r'%s',
+ QT3_UIC = r'%s',
+ %s # last because 'overrides' may add comma
+)
+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)
+""" % (QT3, QT3_LIB, QT3_MOC, QT3_UIC, overrides))
+
+
+createSConstruct(test, ['work1', 'SConstruct'],
+ """QT3_UICIMPLFLAGS='-x',
+ QT3_UICDECLFLAGS='-y',
+ QT3_MOCFROMHFLAGS='-z',
+ QT3_MOCFROMCXXFLAGS='-i -w',
+ QT3_UICDECLPREFIX='uic-',
+ QT3_UICDECLSUFFIX='.hpp',
+ QT3_UICIMPLPREFIX='',
+ QT3_UICIMPLSUFFIX='.cxx',
+ QT3_MOCHPREFIX='mmm',
+ QT3_MOCHSUFFIX='.cxx',
+ QT3_MOCCXXPREFIX='moc',
+ QT3_MOCCXXSUFFIX='.inl',
+ QT3_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(void) {
+ 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), mode='r').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=['qt3'],
+ QT3DIR=r'%(QT3DIR)s',
+ QT3_BINPATH='$QT3DIR/bin64',
+ QT3_LIBPATH='$QT3DIR/lib64',
+ QT3_CPPPATH='$QT3DIR/h64',
+)
+
+cpppath = env1.subst('$CPPPATH')
+if os.path.normpath(cpppath) != os.path.join(r'%(QT3DIR)s', 'h64'):
+ print(cpppath)
+ Exit(1)
+libpath = env1.subst('$LIBPATH')
+if os.path.normpath(libpath) != os.path.join(r'%(QT3DIR)s', 'lib64'):
+ print(libpath)
+ Exit(2)
+qt_moc = env1.subst('$QT3_MOC')
+if os.path.normpath(qt_moc) != os.path.join(r'%(QT3DIR)s', 'bin64', 'moc'):
+ print(qt_moc)
+ Exit(3)
+
+env2 = Environment(
+ tools=['default', 'qt3'], QT3DIR=None, QT3_LIB=None, QT3_CPPPATH=None, QT3_LIBPATH=None
+)
+
+env2.Program('main.cpp')
+""" % {'QT3DIR':QT3})
+
+test.write(['work2', 'main.cpp'], """
+int main(void) { 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/qt3/Tool.py b/test/QT/qt3/Tool.py
new file mode 100644
index 000000000..1b34ea2ab
--- /dev/null
+++ b/test/QT/qt3/Tool.py
@@ -0,0 +1,156 @@
+#!/usr/bin/env python
+#
+# MIT License
+#
+# Copyright The SCons Foundation
+#
+# 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.
+
+"""
+Verify that applying env.Tool('qt3') 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(QT3DIR = 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['QT3_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('qt3', ['$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/qt3/copied-env.py b/test/QT/qt3/copied-env.py
new file mode 100644
index 000000000..9bcb95b68
--- /dev/null
+++ b/test/QT/qt3/copied-env.py
@@ -0,0 +1,83 @@
+#!/usr/bin/env python
+#
+# MIT License
+#
+# Copyright The SCons Foundation
+#
+# 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.
+
+"""
+Test Qt with a copied construction environment.
+"""
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.Qt_dummy_installation()
+
+test.Qt_create_SConstruct('SConstruct', qt_tool='qt3')
+
+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/qt3/empty-env.py b/test/QT/qt3/empty-env.py
new file mode 100644
index 000000000..cd1434080
--- /dev/null
+++ b/test/QT/qt3/empty-env.py
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+#
+# MIT License
+#
+# Copyright The SCons Foundation
+#
+# 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.
+
+"""
+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(QT3DIR = r'%s',
+ QT3_LIB = r'%s',
+ QT3_MOC = r'%s',
+ QT3_UIC = r'%s',
+ tools=['qt3'])
+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(void) { 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/qt3/generated-ui.py b/test/QT/qt3/generated-ui.py
new file mode 100644
index 000000000..d43b21b00
--- /dev/null
+++ b/test/QT/qt3/generated-ui.py
@@ -0,0 +1,135 @@
+#!/usr/bin/env python
+#
+# MIT License
+#
+# Copyright The SCons Foundation
+#
+# 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.
+
+"""
+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','qt3'],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',0o755)])
+ 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(
+ 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/qt3/installed.py b/test/QT/qt3/installed.py
new file mode 100644
index 000000000..71ff98fb7
--- /dev/null
+++ b/test/QT/qt3/installed.py
@@ -0,0 +1,220 @@
+#!/usr/bin/env python
+#
+# MIT License
+#
+# Copyright The SCons Foundation
+#
+# 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.
+
+"""
+Look if qt3 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','qt3'],
+ 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("$QT3_LIB"), autoadd=0):
+ conf.env['QT3_LIB'] = 'qt-mt'
+ if not conf.CheckLib(env.subst("$QT3_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="--warn=no-tool-qt-deprecated bld/test_realqt" + TestSCons._exe)
+
+test.run(
+ program=test.workpath("bld", "test_realqt"),
+ arguments="--warn=no-tool-qt-deprecated",
+ 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(expect not in test.stderr())
+ if test.status != 1 and (test.status >> 8) != 1:
+ sys.stdout.write('test_realqt returned status %s\n' % test.status)
+ test.fail_test()
+
+QT3DIR = 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 qt3, using empty QT3DIR"
+expect2 = "scons: warning: Could not detect qt3, using moc executable as a hint"
+
+test.fail_test(expect1 not in test.stderr() and expect2 not in test.stderr())
+
+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/qt3/manual.py b/test/QT/qt3/manual.py
new file mode 100644
index 000000000..f467b5ae2
--- /dev/null
+++ b/test/QT/qt3/manual.py
@@ -0,0 +1,148 @@
+#!/usr/bin/env python
+#
+# MIT License
+#
+# Copyright The SCons Foundation
+#
+# 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.
+
+"""
+Test the manual QT3 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'))
+moc = env.Moc('bbb.cpp')
+env.Ignore( moc, moc )
+sources.extend(env.Uic('ui/ccc.ui')[1:])
+
+# manual target specification
+sources.append(env.Moc('moc-ddd.cpp', 'include/ddd.h',
+ QT3_MOCHPREFIX='')) # Watch out !
+moc = env.Moc('moc_eee.cpp', 'eee.cpp')
+env.Ignore( moc, moc )
+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'],
+ QT3_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(void) {
+ 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/qt3/moc-from-cpp.py b/test/QT/qt3/moc-from-cpp.py
new file mode 100644
index 000000000..bbab8cab8
--- /dev/null
+++ b/test/QT/qt3/moc-from-cpp.py
@@ -0,0 +1,114 @@
+#!/usr/bin/env python
+#
+# MIT License
+#
+# Copyright The SCons Foundation
+#
+# 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.
+
+"""
+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="--warn=no-tool-qt-deprecated " + lib_aaa,
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall,
+)
+
+test.up_to_date(options='-n --warn=no-tool-qt-deprecated', 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 --warn=no-tool-qt-deprecated', arguments=moc)
+
+test.run(options="--warn=no-tool-qt-deprecated -c", arguments=lib_aaa)
+
+test.run(
+ arguments="--warn=no-tool-qt-deprecated variant_dir=1 "
+ + test.workpath('build', lib_aaa),
+ stderr=TestSCons.noisy_ar,
+ match=TestSCons.match_re_dotall,
+)
+
+test.run(
+ arguments="--warn=no-tool-qt-deprecated variant_dir=1 chdir=1 "
+ + test.workpath('build', lib_aaa)
+)
+
+test.must_exist(test.workpath('build', moc))
+
+test.run(
+ arguments="--warn=no-tool-qt-deprecated 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/qt3/moc-from-header.py b/test/QT/qt3/moc-from-header.py
new file mode 100644
index 000000000..65a12e1ed
--- /dev/null
+++ b/test/QT/qt3/moc-from-header.py
@@ -0,0 +1,109 @@
+#!/usr/bin/env python
+#
+# MIT License
+#
+# Copyright The SCons Foundation
+#
+# 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.
+
+"""
+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(void) { aaa(); return 0; }
+""")
+
+test.write('aaa.h', r"""
+#include "my_qobject.h"
+void aaa(void) Q_OBJECT;
+""")
+
+test.run(arguments="--warn=no-tool-qt-deprecated")
+test.up_to_date(options='--warn=no-tool-qt-deprecated -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='--warn=no-tool-qt-deprecated -n', arguments=moc)
+
+test.run(
+ arguments="--warn=no-tool-qt-deprecated",
+ program=test.workpath(aaa_exe),
+ stdout='aaa.h\n',
+)
+
+test.run(arguments="--warn=no-tool-qt-deprecated variant_dir=1 " + build_aaa_exe)
+
+test.run(
+ arguments="--warn=no-tool-qt-deprecated variant_dir=1 chdir=1 " + build_aaa_exe
+)
+
+test.must_exist(test.workpath('build', moc))
+
+test.run(
+ arguments="--warn=no-tool-qt-deprecated 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/qt3/qt_warnings.py b/test/QT/qt3/qt_warnings.py
new file mode 100644
index 000000000..1cbf2b013
--- /dev/null
+++ b/test/QT/qt3/qt_warnings.py
@@ -0,0 +1,104 @@
+#!/usr/bin/env python
+#
+# MIT License
+#
+# Copyright The SCons Foundation
+#
+# 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.
+
+"""
+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 = r"""
+scons: warning: Could not detect qt3, using moc executable as a hint \(QT3DIR=%s\)
+File "%s", line \d+, in (\?|<module>)
+""" % (qtdir, re.escape(SConstruct_path))
+else:
+
+ expect = r"""
+scons: warning: Could not detect qt3, using empty QT3DIR
+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:
diff --git a/test/QT/qt3/reentrant.py b/test/QT/qt3/reentrant.py
new file mode 100644
index 000000000..be6d8a62f
--- /dev/null
+++ b/test/QT/qt3/reentrant.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+#
+# MIT License
+#
+# Copyright The SCons Foundation
+#
+# 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.
+
+"""
+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=['qt3'])
+env.Program('main', 'main.cpp', CPPDEFINES=['FOO'], LIBS=[])
+""")
+
+test.write('main.cpp', r"""
+#include "foo5.h"
+int main(void) { foo5(); return 0; }
+""")
+
+test.run(arguments="--warn=no-tool-qt-deprecated")
+
+test.run(
+ arguments='--warn=no-tool-qt-deprecated',
+ 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/qt3/source-from-ui.py b/test/QT/qt3/source-from-ui.py
new file mode 100644
index 000000000..1404f7532
--- /dev/null
+++ b/test/QT/qt3/source-from-ui.py
@@ -0,0 +1,161 @@
+#!/usr/bin/env python
+#
+# MIT License
+#
+# Copyright The SCons Foundation
+#
+# 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.
+
+"""
+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), mode='r')
+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/qt3/up-to-date.py b/test/QT/qt3/up-to-date.py
new file mode 100644
index 000000000..ec5123827
--- /dev/null
+++ b/test/QT/qt3/up-to-date.py
@@ -0,0 +1,144 @@
+#!/usr/bin/env python
+#
+# MIT License
+#
+# Copyright The SCons Foundation
+#
+# 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.
+#
+
+"""
+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','qt3'],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',0o755)])
+ 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='--warn=no-tool-qt-deprecated ' + 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: