Exemplo n.º 1
0
 def test_wrong_compiler_warning(self):
     # clear environ
     self.del_environ()
     compiler = 'python'  # fake wrong compiler
     with warnings.catch_warnings(record=True) as error:
         flag = utils.check_abi_compatibility(compiler, verbose=True)
         # check return False
         self.assertFalse(flag)
         # check Compiler Compatibility WARNING
         self.assertTrue(len(error) == 1)
         self.assertTrue(
             "Compiler Compatibility WARNING" in str(error[0].message))
Exemplo n.º 2
0
    def test_compiler_version(self):
        # clear environ
        self.del_environ()
        if utils.OS_NAME.startswith('linux'):
            compiler = 'g++'
        elif utils.IS_WINDOWS:
            compiler = 'cl'

        # Linux: all CI gcc version > 5.4.0
        # Windows: all CI MSVC version > 19.00.24215
        # Mac: clang has no version limitation, always return true
        self.assertTrue(utils.check_abi_compatibility(compiler, verbose=True))
Exemplo n.º 3
0
 def test_exception_windows(self):
     # clear environ
     self.del_environ()
     compiler = 'fake compiler'  # fake command
     if utils.IS_WINDOWS:
         with warnings.catch_warnings(record=True) as error:
             flag = utils.check_abi_compatibility(compiler, verbose=True)
             # check return False
             self.assertFalse(flag)
             # check ABI Compatibility WARNING
             self.assertTrue(len(error) == 1)
             self.assertTrue("Failed to check compiler version for" in str(
                 error[0].message))
Exemplo n.º 4
0
    def test_exception_mac(self):
        # clear environ
        self.del_environ()
        compiler = 'python'  # fake command
        if utils.OS_NAME.startswith('darwin'):

            def fake():
                return [compiler]

            # mock a fake function
            raw_func = utils._expected_compiler_current_platform
            utils._expected_compiler_current_platform = fake
            with warnings.catch_warnings(record=True) as error:
                flag = utils.check_abi_compatibility(compiler, verbose=True)
                # check return True
                self.assertTrue(flag)
                # check ABI Compatibility without WARNING
                self.assertTrue(len(error) == 0)

            # restore
            utils._expected_compiler_current_platform = raw_func
Exemplo n.º 5
0
    def test_exception(self):
        # clear environ
        self.del_environ()
        compiler = 'python'  # fake command
        if utils.OS_NAME.startswith('linux'):

            def fake():
                return [compiler]

            # mock a fake function
            raw_func = utils._expected_compiler_current_platform
            utils._expected_compiler_current_platform = fake
            with warnings.catch_warnings(record=True) as error:
                flag = utils.check_abi_compatibility(compiler, verbose=True)
                # check return False
                self.assertFalse(flag)
                # check ABI Compatibility WARNING
                self.assertTrue(len(error) == 1)
                self.assertTrue("Failed to check compiler version for" in
                                str(error[0].message))

            # restore
            utils._expected_compiler_current_platform = raw_func
Exemplo n.º 6
0
 def test_environ(self):
     compiler_list = ['gcc', 'cl']
     for compiler in compiler_list:
         for flag in ['1', 'True', 'true']:
             os.environ['PADDLE_SKIP_CHECK_ABI'] = flag
             self.assertTrue(utils.check_abi_compatibility(compiler))