diff options
Diffstat (limited to 'src/engine/SCons/SConfTests.py')
| -rw-r--r-- | src/engine/SCons/SConfTests.py | 34 | 
1 files changed, 22 insertions, 12 deletions
diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py index 36abc7e..678147c 100644 --- a/src/engine/SCons/SConfTests.py +++ b/src/engine/SCons/SConfTests.py @@ -1,5 +1,5 @@  # -# Copyright (c) 2001 - 2017 The SCons Foundation +# Copyright (c) 2001 - 2019 The SCons Foundation  #  # Permission is hereby granted, free of charge, to any person obtaining  # a copy of this software and associated documentation files (the @@ -21,7 +21,7 @@  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  # -__revision__ = "src/engine/SCons/SConfTests.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog" +__revision__ = "src/engine/SCons/SConfTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"  import SCons.compat @@ -33,8 +33,6 @@ from types import *  import unittest  import TestCmd -import TestUnit -  sys.stdout = io.StringIO() @@ -115,9 +113,9 @@ class SConfTestCase(unittest.TestCase):          def checks(self, sconf, TryFuncString):              TryFunc = self.SConf.SConfBase.__dict__[TryFuncString] -            res1 = TryFunc( sconf, "int main() { return 0; }\n", ".c" ) +            res1 = TryFunc( sconf, "int main(void) { return 0; }\n", ".c" )              res2 = TryFunc( sconf, -                            '#include "no_std_header.h"\nint main() {return 0; }\n', +                            '#include "no_std_header.h"\nint main(void) {return 0; }\n',                              '.c' )              return (res1,res2) @@ -196,7 +194,7 @@ class SConfTestCase(unittest.TestCase):                          pass                      def add_post_action(self, *actions):                          pass -                    def children(self): +                    def children(self, scan = 1):                          return []                      def get_state(self):                          return self.state @@ -254,7 +252,7 @@ class SConfTestCase(unittest.TestCase):          def checks(sconf):              prog = """  #include <stdio.h> -int main() { +int main(void) {    printf( "Hello" );    return 0;  } @@ -300,10 +298,17 @@ int main() {          """Test SConf.TryAction          """          def actionOK(target, source, env): -            open(str(target[0]), "w").write( "RUN OK\n" ) +            with open(str(target[0]), "w") as f: +                f.write("RUN OK\n")              return None          def actionFAIL(target, source, env):              return 1 +        def actionUnicode(target, source, env): +            with open(str(target[0]), "wb") as f: +                f.write('2\302\242\n') +            return None + +          self._resetSConfState()          sconf = self.SConf.SConf(self.scons_env,                                    conf_dir=self.test.workpath('config.tests'), @@ -313,6 +318,12 @@ int main() {              assert ret and output.encode('utf-8') == bytearray("RUN OK"+os.linesep,'utf-8'), (ret, output)              (ret, output) = sconf.TryAction(action=actionFAIL)              assert not ret and output == "", (ret, output) + +            if not TestCmd.IS_PY3: +                # GH Issue #3141 - unicode text and py2.7 crashes. +                (ret, output) = sconf.TryAction(action=actionUnicode) +                assert ret and output == u'2\xa2\n', (ret, output) +          finally:              sconf.Finish() @@ -755,7 +766,7 @@ int main() {              prog = """  #include <stdio.h> -int main() { +int main(void) {    printf( "Hello" );    return 0;  } @@ -779,8 +790,7 @@ int main() {  if __name__ == "__main__": -    suite = unittest.makeSuite(SConfTestCase, 'test_') -    TestUnit.run(suite) +    unittest.main()  # Local Variables:  # tab-width:4  | 
