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.
24 Test bin/update-release-info.py. Also verify that the original files
25 have the appropriate triggers to cause the modifications.
28 __revision__
= "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
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')
60 test
.run(arguments
='bad', stderr
=expected_stderr
, status
=2)
62 # Strings to go in ReleaseConfig
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
,
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
):
97 test
.write(ReleaseConfig
, t
)
99 kw
.setdefault('stdout', combo_error
)
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)
124 if not path
or os
.path
.isdir(os
.path
.join(*path
)):
130 def pave_write(file, contents
):
132 test
.write(file, contents
)
135 pave_write(CHANGES
, """
136 RELEASE It doesn't matter what goes here...
139 pave_write(RELEASE
, """
140 This file has a 3.2.1.beta.20121221 version string in it
144 pave_write(README
, """
145 These files are a part of 33.22.11:
146 scons-33.22.11.tar.gz
149 scons-33.22.11.b.20012122112.suffix
152 pave_write(README_SF
, """
153 These files are a part of 33.22.11:
154 scons-33.22.11.tar.gz
157 scons-33.22.11.b.20012122112.suffix
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
168 unsupported_python_version = Not done with junk
169 deprecated_python_version = It goes on forever
172 pave_write(main_in
, """
176 pave_write(main_xml
, """
181 def updating_run(*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
195 - Whatever John Doe did.
198 RELEASE It doesn't matter what goes here...
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
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
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
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)
240 # TODO: Release option
241 # TODO: ==============
243 # TODO: Dates in beta/candidate flow
245 # TODO: Dates in final flow
250 # TODO: Dates in post flow
252 # TODO: Update minor or micro version
254 # TODO: ReleaseConfig - new version tuple
256 # TODO: CHANGES - new section
258 # TODO: RELEASE - new template
265 # indent-tabs-mode:nil
267 # vim: set expandtab tabstop=4 shiftwidth=4: