aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-12-10 14:46:28 -0800
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2020-12-11 17:46:11 +0530
commitb65168c558c64cd2af4a9586443c295c5bec1114 (patch)
tree1056409435cff250db3d935895d017a86a05fb0f
parentd4328011cfc0b238e831a36a309b74f129179fee (diff)
downloadmeson-b65168c558c64cd2af4a9586443c295c5bec1114.zip
meson-b65168c558c64cd2af4a9586443c295c5bec1114.tar.gz
meson-b65168c558c64cd2af4a9586443c295c5bec1114.tar.bz2
unit tests: correctly skip c++20 checks if the compiler doesn't support
them I can't find a supported version for AppleClang, and you need relatively recent versions of GCC and Clang for -std=c++20 to work.
-rwxr-xr-xrun_unittests.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/run_unittests.py b/run_unittests.py
index a461df5..84719d6 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from mesonbuild.compilers.objc import AppleClangObjCCompiler
import time
import stat
import subprocess
@@ -79,6 +78,9 @@ from run_tests import (
run_configure_inprocess, run_mtest_inprocess
)
+if T.TYPE_CHECKING:
+ from mesonbuild.compilers import Compiler
+
URLOPEN_TIMEOUT = 5
@@ -6273,13 +6275,16 @@ class LinuxlikeTests(BasePlatformTests):
Oargs = [arg for arg in cmd if arg.startswith('-O')]
self.assertEqual(Oargs, [Oflag, '-O0'])
- def _test_stds_impl(self, testdir, compiler, p: str):
+ def _test_stds_impl(self, testdir, compiler: 'Compiler', p: str) -> None:
has_cpp17 = (compiler.get_id() not in {'clang', 'gcc'} or
compiler.get_id() == 'clang' and _clang_at_least(compiler, '>=5.0.0', '>=9.1') or
compiler.get_id() == 'gcc' and version_compare(compiler.version, '>=5.0.0'))
has_cpp2a_c17 = (compiler.get_id() not in {'clang', 'gcc'} or
compiler.get_id() == 'clang' and _clang_at_least(compiler, '>=6.0.0', '>=10.0') or
compiler.get_id() == 'gcc' and version_compare(compiler.version, '>=8.0.0'))
+ has_cpp20 = (compiler.get_id() not in {'clang', 'gcc'} or
+ compiler.get_id() == 'clang' and _clang_at_least(compiler, '>=10.0.0', None) or
+ compiler.get_id() == 'gcc' and version_compare(compiler.version, '>=10.0.0'))
has_c18 = (compiler.get_id() not in {'clang', 'gcc'} or
compiler.get_id() == 'clang' and _clang_at_least(compiler, '>=8.0.0', '>=11.0') or
compiler.get_id() == 'gcc' and version_compare(compiler.version, '>=8.0.0'))
@@ -6294,6 +6299,8 @@ class LinuxlikeTests(BasePlatformTests):
continue
elif '++2a' in v and not has_cpp2a_c17: # https://en.cppreference.com/w/cpp/compiler_support
continue
+ elif '++20' in v and not has_cpp20:
+ continue
# now C
elif '17' in v and not has_cpp2a_c17:
continue
@@ -9269,7 +9276,7 @@ class SubprojectsCommandTests(BasePlatformTests):
out = self._subprojects_cmd(['foreach', '--types', 'git'] + dummy_cmd)
self.assertEqual(ran_in(out), ['subprojects/sub_git'])
-def _clang_at_least(compiler, minver: str, apple_minver: str) -> bool:
+def _clang_at_least(compiler, minver: str, apple_minver: T.Optional[str]) -> bool:
"""
check that Clang compiler is at least a specified version, whether AppleClang or regular Clang
@@ -9289,6 +9296,8 @@ def _clang_at_least(compiler, minver: str, apple_minver: str) -> bool:
"""
if isinstance(compiler, (mesonbuild.compilers.AppleClangCCompiler,
mesonbuild.compilers.AppleClangCPPCompiler)):
+ if apple_minver is None:
+ return False
return version_compare(compiler.version, apple_minver)
return version_compare(compiler.version, minver)