TestExternal.test_c_unit_test fails on FreeBSD
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da mypyc/test/test_external.py e dall’invocazione di setup.py build_ext in mypyc/lib-rt; riproduci TestExternal.test_c_unit_test su FreeBSD e analizza gli argomenti del compilatore mostrati nell’errore. Il lavoro è completato quando la suite di test compila correttamente i sorgenti C e C++ con clang e TestExternal.test_c_unit_test ha esito positivo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c, cpp, python
- Ambito
- build-system, testing-qa
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 66/100