added release.txt blurb. Fixed spelling typo in Defaults.xml
[scons.git] / test / update-release-info / update-release-info.py
blob2de4713b0cbc54cda4e088ff8ee210893bab58a2
1 #!/usr/bin/env python
3 # __COPYRIGHT__
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 """
24 Test bin/update-release-info.py. Also verify that the original files
25 have the appropriate triggers to cause the modifications.
26 """
28 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
30 import os
31 import time
33 import TestRuntest
35 # Needed to ensure we're using the correct year
36 this_year = time.localtime()[0]
38 TestSCons = 'testing/framework/TestSCons.py'.split('/')
39 README = 'README.rst'.split('/')
40 README_SF = 'README-SF.rst'.split('/')
42 ReleaseConfig = 'ReleaseConfig'.split('/')
43 CHANGES = 'CHANGES.txt'.split('/')
44 RELEASE = 'RELEASE.txt'.split('/')
45 Main = 'SCons/Script/Main.py'.split('/')
46 main_in = 'doc/user/main.in'.split('/')
47 main_xml = 'doc/user/main.xml'.split('/')
49 test = TestRuntest.TestRuntest(
50 program=os.path.join('bin', 'update-release-info.py'),
51 things_to_copy=['bin', 'template']
53 if not os.path.exists(test.program):
54 test.skip_test("update-release-info.py is not distributed in this package\n")
56 expected_stderr = """usage: update-release-info.py [-h] [--verbose] [--timestamp TIMESTAMP]
57 [{develop,release,post}]
58 update-release-info.py: error: argument mode: invalid choice: 'bad' (choose from 'develop', 'release', 'post')
59 """
60 test.run(arguments='bad', stderr=expected_stderr, status=2)
62 # Strings to go in ReleaseConfig
63 combo_strings = [
64 # Index 0: version tuple with bad release level
65 """version_tuple = (2, 0, 0, 'bad', 0)\n""",
66 # Index 1: Python version tuple
67 """unsupported_python_version = (2, 6)\n""",
68 # Index 2: Python version tuple
69 """deprecated_python_version = (2, 7)\n""",
70 # Index 3: alpha version tuple
71 """version_tuple = (2, 0, 0, 'a', 0)\n""",
72 # Index 4: final version tuple
73 """version_tuple = (2, 0, 0, 'final', 0)\n""",
74 # Index 5: bad release date
75 """release_date = (%d, 12)\n""" % this_year,
76 # Index 6: release date (hhhh, mm, dd)
77 """release_date = (%d, 12, 21)\n""" % this_year,
78 # Index 7: release date (hhhh, mm, dd, hh, mm, ss)
79 """release_date = (%d, 12, 21, 12, 21, 12)\n""" % this_year,
82 combo_error = \
83 """ERROR: Config file must contain at least version_tuple,
84 \tunsupported_python_version, and deprecated_python_version.\n"""
87 def combo_fail(*args, **kw):
88 kw.setdefault('status', 1)
89 combo_run(*args, **kw)
92 def combo_run(*args, **kw):
93 t = '\n'
94 for a in args:
95 t += combo_strings[a]
97 test.write(ReleaseConfig, t)
99 kw.setdefault('stdout', combo_error)
100 test.run(**kw)
103 combo_fail()
104 combo_fail(0)
105 combo_fail(1)
106 combo_fail(2)
107 combo_fail(0, 1)
108 combo_fail(0, 2)
109 combo_fail(1, 2)
110 combo_fail(0, 1, 2, stdout=
111 """ERROR: `bad' is not a valid release type in version tuple;
112 \tit must be one of a, b, rc, or final\n""")
114 # We won't need this entry again, so put in a default
115 combo_strings[0] = combo_strings[1] + combo_strings[2] + combo_strings[3]
117 combo_fail(0, 5, stdout=
118 """ERROR: Invalid release date (%d, 12)
119 """ % this_year)
122 def pave(path):
123 path = path[:-1]
124 if not path or os.path.isdir(os.path.join(*path)):
125 return
126 pave(path)
127 test.subdir(path)
130 def pave_write(file, contents):
131 pave(file)
132 test.write(file, contents)
135 pave_write(CHANGES, """
136 RELEASE It doesn't matter what goes here...
137 """)
139 pave_write(RELEASE, """
140 This file has a 3.2.1.beta.20121221 version string in it
141 """)
144 pave_write(README, """
145 These files are a part of 33.22.11:
146 scons-33.22.11.tar.gz
147 scons-33.22.11.zip
149 scons-33.22.11.b.20012122112.suffix
150 """)
152 pave_write(README_SF, """
153 These files are a part of 33.22.11:
154 scons-33.22.11.tar.gz
155 scons-33.22.11.zip
157 scons-33.22.11.b.20012122112.suffix
158 """)
160 pave_write(TestSCons, """
161 copyright_years = Some junk to be overwritten
162 default_version = More junk
163 python_version_unsupported = Yep, more junk
164 python_version_deprecated = And still more
165 """)
167 pave_write(Main, """
168 unsupported_python_version = Not done with junk
169 deprecated_python_version = It goes on forever
170 """)
172 pave_write(main_in, """
173 TODO
174 """)
176 pave_write(main_xml, """
177 TODO
178 """)
181 def updating_run(*args):
182 stdout = ''
183 for file in args:
184 stdout += 'Updating %s...\n' % os.path.join(*file)
185 combo_run(0, 7, stdout=stdout, arguments=['--timestamp=yyyymmdd'])
188 updating_run(ReleaseConfig, CHANGES, RELEASE, README, README_SF, TestSCons, Main)
190 test.must_match(CHANGES, """
191 RELEASE VERSION/DATE TO BE FILLED IN LATER
193 From John Doe:
195 - Whatever John Doe did.
198 RELEASE It doesn't matter what goes here...
199 """, mode='r')
201 test.must_exist(RELEASE)
202 # TODO Fix checking contents
203 # test.must_match(RELEASE, """
204 # This file has a 2.0.0.devyyyymmdd version string in it
205 # """, mode='r')
208 years = '2001 - %d' % (this_year + 1)
210 test.must_match(README, """
211 These files are a part of 33.22.11:
212 scons-2.1.0ayyyymmdd.tar.gz
213 scons-2.1.0ayyyymmdd.zip
215 scons-2.1.0ayyyymmdd.suffix
216 """, mode='r')
218 test.must_match(README_SF, """
219 These files are a part of 33.22.11:
220 scons-2.1.0ayyyymmdd.tar.gz
221 scons-2.1.0ayyyymmdd.zip
223 scons-2.1.0ayyyymmdd.suffix
224 """, mode='r')
226 # should get Python floors from TestSCons module.
227 test.must_match(TestSCons, """
228 copyright_years = '%s'
229 default_version = '2.1.0ayyyymmdd'
230 python_version_unsupported = (2, 6)
231 python_version_deprecated = (2, 7)
232 """ % years, mode='r')
234 # should get Python floors from TestSCons module.
235 test.must_match(Main, """
236 unsupported_python_version = (2, 6)
237 deprecated_python_version = (2, 7)
238 """, mode='r')
240 # TODO: Release option
241 # TODO: ==============
242 # TODO:
243 # TODO: Dates in beta/candidate flow
244 # TODO:
245 # TODO: Dates in final flow
246 # TODO:
247 # TODO: Post option
248 # TODO: ===========
249 # TODO:
250 # TODO: Dates in post flow
251 # TODO:
252 # TODO: Update minor or micro version
253 # TODO:
254 # TODO: ReleaseConfig - new version tuple
255 # TODO:
256 # TODO: CHANGES - new section
257 # TODO:
258 # TODO: RELEASE - new template
259 # TODO:
261 test.pass_test()
263 # Local Variables:
264 # tab-width:4
265 # indent-tabs-mode:nil
266 # End:
267 # vim: set expandtab tabstop=4 shiftwidth=4: