Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test #12634

Open
AMDmi3 opened this issue Apr 21, 2022 · 0 comments
Open

Test #12634

AMDmi3 opened this issue Apr 21, 2022 · 0 comments
Labels
bug mypy got something wrong topic-mypyc mypyc bugs topic-tests

Comments

@AMDmi3
Copy link

AMDmi3 commented Apr 21, 2022

Bug Report

On FreeBSD where clang is the default compiler, one test from mypy testsuite fails: TestExternal.test_c_unit_test, because -std=c++11 flag is set for both C and CXX compilers, but it only applies to C++, and clang refuses to compile C code with it.

=================================== FAILURES ===================================
________________________ TestExternal.test_c_unit_test _________________________

self = <mypyc.test.test_external.TestExternal testMethod=test_c_unit_test>

    @unittest.skipIf(sys.platform.startswith("win"), "rt tests don't work on windows")
    def test_c_unit_test(self) -> None:
        """Run C unit tests in a subprocess."""
        # Build Google Test, the C++ framework we use for testing C code.
        # The source code for Google Test is copied to this repository.
        cppflags: List[str] = []
        env = os.environ.copy()
        if sys.platform == 'darwin':
            cppflags += ['-mmacosx-version-min=10.10', '-stdlib=libc++']
        env['CPPFLAGS'] = ' '.join(cppflags)
        subprocess.check_call(
            ['make', 'libgtest.a'],
            env=env,
            cwd=os.path.join(base_dir, 'mypyc', 'external', 'googletest', 'make'))
        # Build Python wrapper for C unit tests.
        env = os.environ.copy()
        env['CPPFLAGS'] = ' '.join(cppflags)
>       status = subprocess.check_call(
            [sys.executable, 'setup.py', 'build_ext', '--inplace'],
            env=env,
            cwd=os.path.join(base_dir, 'mypyc', 'lib-rt'))

mypyc/test/test_external.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

popenargs = (['/usr/local/bin/python3.8', 'setup.py', 'build_ext', '--inplace'],)
kwargs = {'cwd': '/work/usr/ports/devel/py-mypy/work-py38/mypy-0.940/mypyc/test/../../mypyc/lib-rt', 'env': {'ARCH': 'amd64', 'BATCH': '1', 'BLOCKSIZE': 'K', 'BSD_INSTALL_DATA': 'install  -m 0644', ...}}
retcode = 1
cmd = ['/usr/local/bin/python3.8', 'setup.py', 'build_ext', '--inplace']

    def check_call(*popenargs, **kwargs):
        """Run command with arguments.  Wait for command to complete.  If
        the exit code was zero then return, otherwise raise
        CalledProcessError.  The CalledProcessError object will have the
        return code in the returncode attribute.

        The arguments are the same as for the call function.  Example:

        check_call(["ls", "-l"])
        """
        retcode = call(*popenargs, **kwargs)
        if retcode:
            cmd = kwargs.get("args")
            if cmd is None:
                cmd = popenargs[0]
>           raise CalledProcessError(retcode, cmd)
E           subprocess.CalledProcessError: Command '['/usr/local/bin/python3.8', 'setup.py', 'build_ext', '--inplace']' returned non-zero exit status 1.

/usr/local/lib/python3.8/subprocess.py:364: CalledProcessError
----------------------------- Captured stdout call -----------------------------
c++  -isystem ../include -I.. -O2 -pipe -fstack-protector-strong -fno-strict-aliasing   -g -Wall -Wextra -pthread -fPIC -c  ../src/gtest-all.cc
ar -crsD libgtest.a
running build_ext
building 'test_capi' extension
creating build
creating build/temp.freebsd-13.0-RELEASE-amd64-3.8
cc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fPIC -I../external/googletest -I../external/googletest/include -I/usr/local/include/python3.8 -c test_capi.cc -o build/temp.freebsd-13.0-RELEASE-amd64-3.8/test_capi.o -Wno-unused-function -Wno-sign-compare --std=c++11
cc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fPIC -I../external/googletest -I../external/googletest/include -I/usr/local/include/python3.8 -c init.c -o build/temp.freebsd-13.0-RELEASE-amd64-3.8/init.o -Wno-unused-function -Wno-sign-compare --std=c++11
----------------------------- Captured stderr call -----------------------------
error: invalid argument '--std=c++11' not allowed with 'C'
error: command 'cc' failed with exit status 1

Full log: https://gist.github.com/7b5fb7d6e43d83e9ccdacf34cddc2dec

To Reproduce

Run tests when clang compiler.

Expected Behavior

Tests pass

Actual Behavior

Tests fail

Your Environment

  • Mypy version used: 0.940
  • Python version used: 3.8
  • Operating system and version: FreeBSD 13.0 amd64, clang 11.0.1
@AMDmi3 AMDmi3 added the bug mypy got something wrong label Apr 21, 2022
@hauntsaninja hauntsaninja added the topic-mypyc mypyc bugs label May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-mypyc mypyc bugs topic-tests
Projects
None yet
Development

No branches or pull requests

3 participants