diff options
author | Adam Gross <grossag@vmware.com> | 2020-12-15 13:58:33 (GMT) |
---|---|---|
committer | Adam Gross <grossag@vmware.com> | 2020-12-15 13:58:33 (GMT) |
commit | 7dde534c55a58c4b49f5a1dc843ab19866ed426a (patch) | |
tree | 356811b1b8d30e6ed545b0851b65f058b6afce40 /test/option | |
parent | 6ee0fc53dbe8a59085d4228891e5542c3f1187bb (diff) | |
download | SCons-7dde534c55a58c4b49f5a1dc843ab19866ed426a.zip SCons-7dde534c55a58c4b49f5a1dc843ab19866ed426a.tar.gz SCons-7dde534c55a58c4b49f5a1dc843ab19866ed426a.tar.bz2 |
More improvements
1. Fix failure finding UserError.
2. Fix bad string formatting.
3. Add test case covering passing an invalid hash format.
4. Remove blake2b, as I haven't tested it. We can add it some day if people want it.
Diffstat (limited to 'test/option')
-rw-r--r-- | test/option/hash-format.py | 27 | ||||
-rw-r--r-- | test/option/hash-format/SConstruct | 2 |
2 files changed, 22 insertions, 7 deletions
diff --git a/test/option/hash-format.py b/test/option/hash-format.py index 43e5ad7..9fa10ee 100644 --- a/test/option/hash-format.py +++ b/test/option/hash-format.py @@ -29,19 +29,26 @@ import os import TestSCons # Test passing the hash format by command-line. -for algorithm in ['md5', 'sha1', 'sha256', 'blake2b', None]: +INVALID_ALGORITHM = 'testfailure' +for algorithm in ['md5', 'sha1', 'sha256', INVALID_ALGORITHM, None]: test = TestSCons.TestSCons() test.dir_fixture('hash-format') - if algorithm is not None: + if algorithm == INVALID_ALGORITHM: + # Expect failure due to an unsupported/invalid algorithm. + test.run('--hash-format=%s .' % algorithm, stderr=r""" +scons: \*\*\* Hash format "{}" is not supported by SCons. Only the following hash formats are supported: md5, sha1, sha256 +File "[^"]+", line \d+, in \S+ +""".format(algorithm), status=2, match=TestSCons.match_re) + continue + elif algorithm is not None: # Skip any algorithm that the Python interpreter doesn't have. if hasattr(hashlib, algorithm): expected_dblite = test.workpath('.sconsign_%s.dblite' % algorithm) test.run('--hash-format=%s .' % algorithm) else: - test.skip_test('Skipping test with --hash-format=%s because that ' - 'algorithm is not available.' % algorithm) - continue + print('Skipping test with --hash-format=%s because that ' + 'algorithm is not available.' % algorithm) else: # The SConsign file in the hash-format folder has logic to call # SCons.Util.set_hash_format('sha256') if the default algorithm is @@ -56,7 +63,15 @@ for algorithm in ['md5', 'sha1', 'sha256', 'blake2b', None]: assert os.path.isfile(expected_dblite), \ "%s does not exist when running algorithm %s" % (expected_dblite, algorithm) - test.pass_test() + + test.run('-C .') + os.unlink(expected_dblite) + +# In this case, the SConstruct file will use SetOption to override the hash +# format. +test.run() + +test.pass_test() # Local Variables: # tab-width:4 diff --git a/test/option/hash-format/SConstruct b/test/option/hash-format/SConstruct index 8d600d7..de76e1b 100644 --- a/test/option/hash-format/SConstruct +++ b/test/option/hash-format/SConstruct @@ -21,7 +21,7 @@ def VerifyCsig(): assert csig == 'efe5c6daa743540e9561934e3e18628b336013f7', csig elif hash_format == 'sha256': assert csig == 'a28bb79aa5ca8a5eb2dc5910a103d1a6312e79d73ed8054787cee78cc532a6aa', csig - else: + elif hash_format != 'testfailure': raise Exception('Hash format %s is not supported in ' 'test/option/hash-format/SConstruct' % hash_format) atexit.register(VerifyCsig) |