diff options
author | Daniel Moody <daniel.moody@mongodb.com> | 2021-03-01 18:50:25 (GMT) |
---|---|---|
committer | Daniel Moody <daniel.moody@mongodb.com> | 2021-04-01 16:50:41 (GMT) |
commit | d6efcab9e4669b8818e6db3f17b76515fc7bf171 (patch) | |
tree | 70a8ba78a365e5cd51ddae02daf99823ee720b62 /test/CacheDir | |
parent | 1fc91c5e7531daf60a93359f1d6d09b33a3d6c32 (diff) | |
download | SCons-d6efcab9e4669b8818e6db3f17b76515fc7bf171.zip SCons-d6efcab9e4669b8818e6db3f17b76515fc7bf171.tar.gz SCons-d6efcab9e4669b8818e6db3f17b76515fc7bf171.tar.bz2 |
Added reinstantiatng custom cachedir
Diffstat (limited to 'test/CacheDir')
-rw-r--r-- | test/CacheDir/CACHEDIR_CLASS.py | 23 | ||||
-rw-r--r-- | test/CacheDir/CACHEDIR_CLASS_fixture/SConstruct | 12 | ||||
-rw-r--r-- | test/CacheDir/CACHEDIR_CLASS_fixture/file.in (renamed from test/CacheDir/custom_cachedir/file.in) | 0 | ||||
-rw-r--r-- | test/CacheDir/CustomCacheDir.py | 18 | ||||
-rw-r--r-- | test/CacheDir/DoubleCachedirClass.py | 47 | ||||
-rw-r--r-- | test/CacheDir/InvalidCustomCacheDir.py | 15 | ||||
-rw-r--r-- | test/CacheDir/custom_cachedir/SConstruct | 5 | ||||
-rw-r--r-- | test/CacheDir/custom_cachedir_fixture/SConstruct | 11 | ||||
-rw-r--r-- | test/CacheDir/custom_cachedir_fixture/file.in | 1 | ||||
-rw-r--r-- | test/CacheDir/double_cachedir_fixture/SConstruct | 30 | ||||
-rw-r--r-- | test/CacheDir/double_cachedir_fixture/file.in | 1 | ||||
-rw-r--r-- | test/CacheDir/invalid_custom_cachedir_fixture/SConstruct | 6 | ||||
-rw-r--r-- | test/CacheDir/invalid_custom_cachedir_fixture/file.in | 1 |
13 files changed, 125 insertions, 45 deletions
diff --git a/test/CacheDir/CACHEDIR_CLASS.py b/test/CacheDir/CACHEDIR_CLASS.py index ef34605..f0d6c48 100644 --- a/test/CacheDir/CACHEDIR_CLASS.py +++ b/test/CacheDir/CACHEDIR_CLASS.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -23,29 +25,14 @@ # """ -Test that a custom cache dir can be passed to scons. +Test testing the CACHEDIR_CLASS construction variable. """ import TestSCons test = TestSCons.TestSCons() -test.write(['SConstruct'], """\ -import SCons -class CustomCacheDir(SCons.CacheDir.CacheDir): - - @classmethod - def copy_to_cache(cls, env, src, dst): - print("MY_CUSTOM_CACHEDIR_CLASS") - super().copy_to_cache(env, src, dst) - -env = Environment(tools=[]) -env['CACHEDIR_CLASS'] = CustomCacheDir -env.CacheDir('cache') -env.Command('file.out', 'file.in', Copy('$TARGET', '$SOURCE')) -""") - -test.write('file.in', "file.in\n") +test.dir_fixture('CACHEDIR_CLASS_fixture') test.run() diff --git a/test/CacheDir/CACHEDIR_CLASS_fixture/SConstruct b/test/CacheDir/CACHEDIR_CLASS_fixture/SConstruct new file mode 100644 index 0000000..6ec40c6 --- /dev/null +++ b/test/CacheDir/CACHEDIR_CLASS_fixture/SConstruct @@ -0,0 +1,12 @@ +import SCons +class CustomCacheDir(SCons.CacheDir.CacheDir): + + @classmethod + def copy_to_cache(cls, env, src, dst): + print("MY_CUSTOM_CACHEDIR_CLASS") + super().copy_to_cache(env, src, dst) + +env = Environment(tools=[]) +env['CACHEDIR_CLASS'] = CustomCacheDir +env.CacheDir('cache') +env.Command('file.out', 'file.in', Copy('$TARGET', '$SOURCE'))
\ No newline at end of file diff --git a/test/CacheDir/custom_cachedir/file.in b/test/CacheDir/CACHEDIR_CLASS_fixture/file.in index 1912927..1912927 100644 --- a/test/CacheDir/custom_cachedir/file.in +++ b/test/CacheDir/CACHEDIR_CLASS_fixture/file.in diff --git a/test/CacheDir/CustomCacheDir.py b/test/CacheDir/CustomCacheDir.py index 2846b28..1dac9a3 100644 --- a/test/CacheDir/CustomCacheDir.py +++ b/test/CacheDir/CustomCacheDir.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -23,24 +25,14 @@ # """ -Test that a custom cache dir can be passed to scons. +Test that a custom cache dir can be passed to SCons. """ import TestSCons test = TestSCons.TestSCons() -test.dir_fixture('custom_cachedir') - -test.write(['CustomCacheDirModule.py'], """\ -import SCons -class CustomCacheDir(SCons.CacheDir.CacheDir): - - @classmethod - def copy_to_cache(cls, env, src, dst): - print("MY_CUSTOM_CACHEDIR_CLASS") - super().copy_to_cache(env, src, dst) -""") +test.dir_fixture('custom_cachedir_fixture') test.run() diff --git a/test/CacheDir/DoubleCachedirClass.py b/test/CacheDir/DoubleCachedirClass.py new file mode 100644 index 0000000..3d06f7f --- /dev/null +++ b/test/CacheDir/DoubleCachedirClass.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +""" +Test that a custom cache dir can be passed to SCons. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.dir_fixture('double_cachedir_fixture') + +test.run() + +test.must_contain_all_lines(test.stdout(), ["MY_CUSTOM_CACHEDIR_CLASS2"]) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CacheDir/InvalidCustomCacheDir.py b/test/CacheDir/InvalidCustomCacheDir.py index 604ee56..cc32b48 100644 --- a/test/CacheDir/InvalidCustomCacheDir.py +++ b/test/CacheDir/InvalidCustomCacheDir.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -23,23 +25,18 @@ # """ -Test that a custom cache dir can be passed to scons. +Test to make sure invalid custom cachedir cause error. """ import TestSCons test = TestSCons.TestSCons() -test.dir_fixture('custom_cachedir') - -test.write(['CustomCacheDirModule.py'], """\ -class CustomCacheDir: - pass -""") +test.dir_fixture('invalid_custom_cachedir_fixture') test.run(status = 2, stderr = None) -test.must_contain_all_lines(test.stderr(), ["Custom CACHEDIR_CLASS <class 'CustomCacheDirModule.CustomCacheDir'> not derived from CacheDir"]) +test.must_contain_all_lines(test.stderr(), ["Custom CACHEDIR_CLASS <class 'SCons.Script.CustomCacheDir'> not derived from CacheDir"]) test.pass_test() diff --git a/test/CacheDir/custom_cachedir/SConstruct b/test/CacheDir/custom_cachedir/SConstruct deleted file mode 100644 index 0b24564..0000000 --- a/test/CacheDir/custom_cachedir/SConstruct +++ /dev/null @@ -1,5 +0,0 @@ -from CustomCacheDirModule import CustomCacheDir - -env = Environment(tools=[]) -env.CacheDir('cache', CustomCacheDir) -env.Command('file.out', 'file.in', Copy('$TARGET', '$SOURCE'))
\ No newline at end of file diff --git a/test/CacheDir/custom_cachedir_fixture/SConstruct b/test/CacheDir/custom_cachedir_fixture/SConstruct new file mode 100644 index 0000000..6389999 --- /dev/null +++ b/test/CacheDir/custom_cachedir_fixture/SConstruct @@ -0,0 +1,11 @@ +import SCons +class CustomCacheDir(SCons.CacheDir.CacheDir): + + @classmethod + def copy_to_cache(cls, env, src, dst): + print("MY_CUSTOM_CACHEDIR_CLASS") + super().copy_to_cache(env, src, dst) + +env = Environment(tools=[]) +env.CacheDir('cache', CustomCacheDir) +env.Command('file.out', 'file.in', Copy('$TARGET', '$SOURCE'))
\ No newline at end of file diff --git a/test/CacheDir/custom_cachedir_fixture/file.in b/test/CacheDir/custom_cachedir_fixture/file.in new file mode 100644 index 0000000..1912927 --- /dev/null +++ b/test/CacheDir/custom_cachedir_fixture/file.in @@ -0,0 +1 @@ +file.in diff --git a/test/CacheDir/double_cachedir_fixture/SConstruct b/test/CacheDir/double_cachedir_fixture/SConstruct new file mode 100644 index 0000000..1ec442b --- /dev/null +++ b/test/CacheDir/double_cachedir_fixture/SConstruct @@ -0,0 +1,30 @@ +import SCons +class CustomCacheDir1(SCons.CacheDir.CacheDir): + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + print("INSTANCIATED %s" % str(type(self))) + + @classmethod + def copy_to_cache(cls, env, src, dst): + print("MY_CUSTOM_CACHEDIR_CLASS1") + super().copy_to_cache(env, src, dst) + +class CustomCacheDir2(SCons.CacheDir.CacheDir): + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + print("INSTANCIATED %s" % str(type(self))) + + @classmethod + def copy_to_cache(cls, env, src, dst): + print("MY_CUSTOM_CACHEDIR_CLASS2") + super().copy_to_cache(env, src, dst) + +env = Environment(tools=[]) +env.CacheDir('cache1', CustomCacheDir1) +env.Command('file.out', 'file.in', Copy('$TARGET', '$SOURCE')) +env.CacheDir('cache2', CustomCacheDir2) + + + diff --git a/test/CacheDir/double_cachedir_fixture/file.in b/test/CacheDir/double_cachedir_fixture/file.in new file mode 100644 index 0000000..1912927 --- /dev/null +++ b/test/CacheDir/double_cachedir_fixture/file.in @@ -0,0 +1 @@ +file.in diff --git a/test/CacheDir/invalid_custom_cachedir_fixture/SConstruct b/test/CacheDir/invalid_custom_cachedir_fixture/SConstruct new file mode 100644 index 0000000..ad467e0 --- /dev/null +++ b/test/CacheDir/invalid_custom_cachedir_fixture/SConstruct @@ -0,0 +1,6 @@ +class CustomCacheDir: + pass + +env = Environment(tools=[]) +env.CacheDir('cache', CustomCacheDir) +env.Command('file.out', 'file.in', Copy('$TARGET', '$SOURCE'))
\ No newline at end of file diff --git a/test/CacheDir/invalid_custom_cachedir_fixture/file.in b/test/CacheDir/invalid_custom_cachedir_fixture/file.in new file mode 100644 index 0000000..1912927 --- /dev/null +++ b/test/CacheDir/invalid_custom_cachedir_fixture/file.in @@ -0,0 +1 @@ +file.in |