Skip to content

Commit 698107b

Browse files
committed
Fixed test compile-build on very long paths on Windows
1 parent c0fcd2c commit 698107b

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Diff for: test/conftest.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import simplejson as json
2121
from invoke import Local
2222
from invoke.context import Context
23+
import tempfile
2324

2425
from .common import Board
2526

@@ -31,7 +32,28 @@ def data_dir(tmpdir_factory):
3132
each test and deleted at the end, this way all the
3233
tests work in isolation.
3334
"""
34-
return str(tmpdir_factory.mktemp("ArduinoTest"))
35+
36+
# it seems that paths generated by pytest's tmpdir_factory are too
37+
# long and may lead to arduino-cli compile failures due to the
38+
# combination of (some or all of) the following reasons:
39+
# 1) Windows not liking path >260 chars in len
40+
# 2) arm-gcc not fully optimizing long paths
41+
# 3) libraries requiring headers deep down the include path
42+
# for example:
43+
#
44+
# from C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\A7\packages\arduino\hardware\mbed\1.1.4\cores\arduino/mbed/rtos/Thread.h:29,
45+
# from C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\A7\packages\arduino\hardware\mbed\1.1.4\cores\arduino/mbed/rtos/rtos.h:28,
46+
# from C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\A7\packages\arduino\hardware\mbed\1.1.4\cores\arduino/mbed/mbed.h:23,
47+
# from C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\A7\packages\arduino\hardware\mbed\1.1.4\cores\arduino/Arduino.h:32,
48+
# from C:\Users\RUNNER~1\AppData\Local\Temp\arduino-sketch-739B2B6DD21EB014317DA2A46062811B\sketch\magic_wand.ino.cpp:1:
49+
##[error]c:\users\runneradmin\appdata\local\temp\pytest-of-runneradmin\pytest-0\a7\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\c++\7.2.1\new:39:10: fatal error: bits/c++config.h: No such file or directory
50+
#
51+
# due to the above on Windows we cut the tmp path straight to /tmp/xxxxxxxx
52+
if platform.system() == "Windows":
53+
with tempfile.TemporaryDirectory() as tmp:
54+
yield tmp
55+
else:
56+
yield str(tmpdir_factory.mktemp("ArduinoTest"))
3557

3658

3759
@pytest.fixture(scope="session")

0 commit comments

Comments
 (0)