[ci skip] update generated files
[scons.git] / test / QT / qt3 / up-to-date.py
blobec51238279f02b5a3f0ea9a4d4813075d9be2df0
1 #!/usr/bin/env python
3 # MIT License
5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 """
28 Validate that a stripped-down real-world Qt configuation (thanks
29 to Leanid Nazdrynau) with a generated .h file is correctly
30 up-to-date after a build.
32 (This catches a bug that was introduced during a signature refactoring
33 ca. September 2005.)
34 """
36 import os
38 import TestSCons
40 _obj = TestSCons._obj
42 test = TestSCons.TestSCons()
44 if not os.environ.get('QTDIR', None):
45 x ="External environment variable $QTDIR not set; skipping test(s).\n"
46 test.skip_test(x)
48 test.subdir('layer',
49 ['layer', 'aclock'],
50 ['layer', 'aclock', 'qt_bug'])
52 test.write('SConstruct', """\
53 import os
54 aa=os.getcwd()
56 env=Environment(tools=['default','expheaders','qt3'],toolpath=[aa])
57 env["EXP_HEADER_ABS"]=os.path.join(os.getcwd(),'include')
58 if not os.access(env["EXP_HEADER_ABS"],os.F_OK):
59 os.mkdir (env["EXP_HEADER_ABS"])
60 Export('env')
61 env.SConscript('layer/aclock/qt_bug/SConscript')
62 """)
64 test.write('expheaders.py', """\
65 import SCons.Defaults
66 def ExpHeaderScanner(node, env, path):
67 return []
68 def generate(env):
69 HeaderAction=SCons.Action.Action([SCons.Defaults.Copy('$TARGET','$SOURCE'),SCons.Defaults.Chmod('$TARGET',0o755)])
70 HeaderBuilder= SCons.Builder.Builder(action=HeaderAction)
71 env['BUILDERS']['ExportHeaders'] = HeaderBuilder
72 def exists(env):
73 return 0
74 """)
76 test.write(['layer', 'aclock', 'qt_bug', 'SConscript'], """\
77 import os
79 Import ("env")
80 env.ExportHeaders(os.path.join(env["EXP_HEADER_ABS"],'main.h'), 'main.h')
81 env.ExportHeaders(os.path.join(env["EXP_HEADER_ABS"],'migraform.h'), 'migraform.h')
82 env.Append(CPPPATH=env["EXP_HEADER_ABS"])
83 env.StaticLibrary('all',['main.ui','migraform.ui','my.cc'])
84 """)
86 test.write(['layer', 'aclock', 'qt_bug', 'main.ui'], """\
87 <!DOCTYPE UI><UI version="3.3" stdsetdef="1">
88 <class>Main</class>
89 <widget class="QWizard">
90 <property name="name">
91 <cstring>Main</cstring>
92 </property>
93 <property name="geometry">
94 <rect>
95 <x>0</x>
96 <y>0</y>
97 <width>600</width>
98 <height>385</height>
99 </rect>
100 </property>
101 </widget>
102 <includes>
103 <include location="local" impldecl="in implementation">migraform.h</include>
104 </includes>
105 </UI>
106 """)
108 test.write(['layer', 'aclock', 'qt_bug', 'migraform.ui'], """\
109 <!DOCTYPE UI><UI version="3.3" stdsetdef="1">
110 <class>MigrateForm</class>
111 <widget class="QWizard">
112 <property name="name">
113 <cstring>MigrateForm</cstring>
114 </property>
115 <property name="geometry">
116 <rect>
117 <x>0</x>
118 <y>0</y>
119 <width>600</width>
120 <height>385</height>
121 </rect>
122 </property>
123 </widget>
124 </UI>
125 """)
127 test.write(['layer', 'aclock', 'qt_bug', 'my.cc'], """\
128 #include <main.h>
129 """)
131 my_obj = 'layer/aclock/qt_bug/my' + _obj
133 test.run(arguments='--warn=no-tool-qt-deprecated ' + my_obj, stderr=None)
135 expect = my_obj.replace('/', os.sep)
136 test.up_to_date(options='--debug=explain', arguments=expect, stderr=None)
138 test.pass_test()
140 # Local Variables:
141 # tab-width:4
142 # indent-tabs-mode:nil
143 # End:
144 # vim: set expandtab tabstop=4 shiftwidth=4: