diff options
author | Adam Gross <grossag@vmware.com> | 2020-11-12 13:47:47 (GMT) |
---|---|---|
committer | Adam Gross <grossag@vmware.com> | 2020-11-12 13:47:47 (GMT) |
commit | a28a7fed0cd8006756e0984478709aea5f9653a9 (patch) | |
tree | 0fe9f7da19d375c90494b66c77831876811048af /test/option | |
parent | e90c3fc562412a8ee18e14458c2322874aafee6c (diff) | |
download | SCons-a28a7fed0cd8006756e0984478709aea5f9653a9.zip SCons-a28a7fed0cd8006756e0984478709aea5f9653a9.tar.gz SCons-a28a7fed0cd8006756e0984478709aea5f9653a9.tar.bz2 |
Change the default sconsign DB file name if the hash is overridden
This was requested in the code review. The sconsign database file name is still
.sconsign.dblite if the hash format is not overridden, but if it is, the name
will be something like .sconsign_sha256.dblite.
Diffstat (limited to 'test/option')
-rw-r--r-- | test/option/hash-format.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/test/option/hash-format.py b/test/option/hash-format.py index ca0ec63..94888e6 100644 --- a/test/option/hash-format.py +++ b/test/option/hash-format.py @@ -24,6 +24,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import os import TestSCons test = TestSCons.TestSCons() @@ -31,8 +32,27 @@ test = TestSCons.TestSCons() test.dir_fixture('hash-format') # Test passing the hash format by command-line. -for algorithm in ['md5', 'sha1', 'sha256']: - test.run('--hash-format=%s .' % algorithm) +for algorithm in ['md5', 'sha1', 'sha256', None]: + if algorithm is not None: + expected_dblite = test.workpath('.sconsign_%s.dblite' % algorithm) + test.run('--hash-format=%s .' % 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 + # being used. So this test of algorithm==None effectively validates + # that the sconsign db includes the algorithm name if that function is + # used instead of --hash-format. This is useful because consumers are + # expected to call that function if they want to opt into stronger + # hashes. + expected_dblite = test.workpath('.sconsign_sha256.dblite') + test.run('.') + + assert os.path.isfile(expected_dblite), \ + "%s does not exist when running algorithm %s" % (expected_dblite, + algorithm) + + test.run('-C .') + os.unlink(expected_dblite) # In this case, the SConstruct file will use SetOption to override the hash # format. |