summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2021-10-03 18:33:17 (GMT)
committerMats Wichmann <mats@linux.com>2021-10-03 18:33:17 (GMT)
commit875b8f9103f0b829bea15bde63a51654d368b70e (patch)
tree21f560ed6bb7620b87dbbdaaeba95a56865dd1f2
parentf5bc0d7bd46b318f3d51e515f5677e047c2ed6f7 (diff)
downloadSCons-875b8f9103f0b829bea15bde63a51654d368b70e.zip
SCons-875b8f9103f0b829bea15bde63a51654d368b70e.tar.gz
SCons-875b8f9103f0b829bea15bde63a51654d368b70e.tar.bz2
Add a testcase for gcc -version returning non-utf8
Signed-off-by: Mats Wichmann <mats@linux.com>
-rw-r--r--test/CC/gcc-non-utf8-fixture/.exclude_tests2
-rw-r--r--test/CC/gcc-non-utf8-fixture/data10
-rw-r--r--test/CC/gcc-non-utf8-fixture/gcc-non-utf8.py8
-rw-r--r--test/CC/gcc-version.py65
4 files changed, 85 insertions, 0 deletions
diff --git a/test/CC/gcc-non-utf8-fixture/.exclude_tests b/test/CC/gcc-non-utf8-fixture/.exclude_tests
new file mode 100644
index 0000000..f0608bf
--- /dev/null
+++ b/test/CC/gcc-non-utf8-fixture/.exclude_tests
@@ -0,0 +1,2 @@
+data
+gcc-non-utf8.py
diff --git a/test/CC/gcc-non-utf8-fixture/data b/test/CC/gcc-non-utf8-fixture/data
new file mode 100644
index 0000000..740064b
--- /dev/null
+++ b/test/CC/gcc-non-utf8-fixture/data
@@ -0,0 +1,10 @@
+gcc (tdm-1) 9.2.0
+Copyright (C) 2019 Free Software Foundation, Inc.
+Ýòî ñâîáîäíî ðàñïðîñòðàíÿåìîå ïðîãðàììíîå îáåñïå÷åíèå. Óñëîâèÿ êîïèðîâàíèÿ
+ïðèâåäåíû â èñõîäíûõ òåêñòàõ.
+
+ Áåç ãàðàíòèè êàêèõ-ëèáî êà÷åñòâ, âêëþ÷àÿ
+êîììåð÷åñêóþ öåííîñòü è ïðèìåíèìîñòü äëÿ êàêèõ-ëèáî öåëåé.
+
+
+
diff --git a/test/CC/gcc-non-utf8-fixture/gcc-non-utf8.py b/test/CC/gcc-non-utf8-fixture/gcc-non-utf8.py
new file mode 100644
index 0000000..daa5fe2
--- /dev/null
+++ b/test/CC/gcc-non-utf8-fixture/gcc-non-utf8.py
@@ -0,0 +1,8 @@
+import sys
+
+print(f"In {sys.argv[0]}")
+
+if __name__ == '__main__':
+ if '--version' in sys.argv:
+ with open("data", "rb") as f:
+ sys.stdout.buffer.write(f.read())
diff --git a/test/CC/gcc-version.py b/test/CC/gcc-version.py
new file mode 100644
index 0000000..13defec
--- /dev/null
+++ b/test/CC/gcc-version.py
@@ -0,0 +1,65 @@
+#!/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 if gcc returns non-UTF8 text, the version check doesn't fall over.
+"""
+
+import sys
+
+import TestSCons
+
+_python_ = TestSCons._python_
+_exe = TestSCons._exe
+
+test = TestSCons.TestSCons()
+
+test.dir_fixture('gcc-non-utf8-fixture')
+
+test.write(
+ 'SConstruct',
+ """
+import sys
+
+DefaultEnvironment(tools=[])
+env = Environment(tools=[], CC="%(_python_)s gcc-non-utf8.py")
+try:
+ env.Tool('gcc')
+except UnicodeDecodeError:
+ print("Failed decoding gcc version message.", file=sys.stderr)
+ Exit(1)
+"""
+ % locals(),
+)
+
+test.run(arguments='.')
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: