From 77389c851b94752e57aeb2d6db8a77c9c6c3d15d Mon Sep 17 00:00:00 2001 From: B13nch3n <b13nch3n_01@theb-si.de> Date: Thu, 6 Jul 2023 18:09:04 +0200 Subject: [PATCH] Enable compilation on macos (Clang), fix unit test --- cmake_support/PROMOD3.cmake | 3 +++ core/tests/test_pm3argparse.py | 48 ++++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/cmake_support/PROMOD3.cmake b/cmake_support/PROMOD3.cmake index 01f5f74c..43c58be4 100644 --- a/cmake_support/PROMOD3.cmake +++ b/cmake_support/PROMOD3.cmake @@ -990,6 +990,9 @@ endfunction(get_compiler_version) macro(setup_compiler_flags) + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "AppleClang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + endif() if(CMAKE_COMPILER_IS_GNUCXX) get_compiler_version(_GCC_VERSION) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall" ) diff --git a/core/tests/test_pm3argparse.py b/core/tests/test_pm3argparse.py index d5c19598..ab5270de 100644 --- a/core/tests/test_pm3argparse.py +++ b/core/tests/test_pm3argparse.py @@ -22,6 +22,7 @@ import unittest import tempfile import gzip import json +import sys import ost from promod3.core import pm3argparse @@ -89,22 +90,35 @@ class PM3ArgParseTests(unittest.TestCase): with self.assertRaises(SystemExit) as ecd: parser.Parse(['--help']) self.assertEqual(ecd.exception.code, 0) - self.assertEqual(self.log.messages['SCRIPT'], - ['usage: test_pm3argparse.py [-h]\n\nTesting our '+ - 'own little argument parser.\n\noptional '+ - 'arguments:\n -h, --help show this help message '+ - 'and exit']) + self.assertEqual(ecd.exception.code, 0) + if sys.version_info >= (3,11): + self.assertEqual(self.log.messages['SCRIPT'], + ['usage: test_pm3argparse.py [-h]\n\nTesting our '+ + 'own little argument parser.\n\noptions:\n -h, '+ + '--help show this help message and exit']) + else: + self.assertEqual(self.log.messages['SCRIPT'], + ['usage: test_pm3argparse.py [-h]\n\nTesting our '+ + 'own little argument parser.\n\noptional '+ + 'arguments:\n -h, --help show this help '+ + 'message and exit']) self.log.messages = dict() parser = pm3argparse.PM3ArgumentParser(__doc__, action=True) with self.assertRaises(SystemExit) as ecd: parser.Parse(['--help']) self.assertEqual(ecd.exception.code, 0) - self.assertEqual(self.log.messages['SCRIPT'], - ['usage: t_pm3argparse.py [-h]\n\nTesting our own '+ - 'little argument parser.\n\noptional '+ - 'arguments:\n -h, --help show this help message '+ - 'and exit']) + if sys.version_info >= (3,11): + self.assertEqual(self.log.messages['SCRIPT'], + ['usage: t_pm3argparse.py [-h]\n\nTesting our '+ + 'own little argument parser.\n\noptions:\n '+ + '-h, --help show this help message and exit']) + else: + self.assertEqual(self.log.messages['SCRIPT'], + ['usage: t_pm3argparse.py [-h]\n\nTesting our '+ + 'own little argument parser.\n\noptional '+ + 'arguments:\n -h, --help show this help '+ + 'message and exit']) def testDescription(self): @@ -113,10 +127,16 @@ class PM3ArgParseTests(unittest.TestCase): with self.assertRaises(SystemExit) as ecd: parser.Parse(['--help']) self.assertEqual(ecd.exception.code, 0) - self.assertEqual(self.log.messages['SCRIPT'], - ['usage: test_pm3argparse.py [-h]\n\nThis is a '+ - 'test.\n\noptional arguments:\n -h, --help show '+ - 'this help message and exit']) + if sys.version_info >= (3,11): + self.assertEqual(self.log.messages['SCRIPT'], + ['usage: test_pm3argparse.py [-h]\n\nThis is a '+ + 'test.\n\noptions:\n -h, --help '+ + 'show this help message and exit']) + else: + self.assertEqual(self.log.messages['SCRIPT'], + ['usage: test_pm3argparse.py [-h]\n\nThis is a '+ + 'test.\n\noptional arguments:\n -h, --help '+ + 'show this help message and exit']) def testAddAlignmentNoFileArg(self): # check failure on missing file argument -- GitLab