Skip to content

Commit 325c0c2

Browse files
committed
[skip changelog] CI Test again
1 parent 981272d commit 325c0c2

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

Diff for: test/test_archive.py

+30-7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import shutil
1717
from pathlib import Path
1818

19+
from invoke.context import Context
1920
import pytest
2021

2122

@@ -28,15 +29,37 @@ def copy_sketch(working_dir):
2829
yield str(test_sketch_path)
2930

3031

31-
def test_archive_no_args(run_command, copy_sketch, working_dir):
32-
result = run_command("echo %cd%", copy_sketch)
33-
print(result.stdout)
34-
print(result.stderr)
35-
36-
result = run_command("dir", copy_sketch)
32+
@pytest.fixture(scope="function")
33+
def run_simple(pytestconfig, data_dir, downloads_dir, working_dir):
34+
"""
35+
Provide a wrapper around invoke's `run` API so that every test
36+
will work in the same temporary folder.
37+
38+
Useful reference:
39+
http://docs.pyinvoke.org/en/1.4/api/runners.html#invoke.runners.Result
40+
"""
41+
42+
env = {
43+
"ARDUINO_DATA_DIR": data_dir,
44+
"ARDUINO_DOWNLOADS_DIR": downloads_dir,
45+
"ARDUINO_SKETCHBOOK_DIR": data_dir,
46+
}
47+
48+
def _run(cmd_string, custom_working_dir):
49+
run_context = Context()
50+
# Context.cd() is not used since it doesn't work correctly on Windows.
51+
# It escapes spaces in the path using "\ " but it doesn't always work,
52+
# wrapping the path in quotation marks is the safest approach
53+
with run_context.prefix(f'cd "{custom_working_dir}"'):
54+
return run_context.run(cmd_string, echo=False, hide=True, warn=True, env=env)
55+
56+
return _run
57+
58+
59+
def test_archive_no_args(run_simple, run_command, copy_sketch, working_dir):
60+
result = run_simple("dir", copy_sketch)
3761
print(result.stdout)
3862
print(result.stderr)
39-
4063
result = run_command("archive", copy_sketch)
4164
print(result.stdout)
4265
print(result.stderr)

0 commit comments

Comments
 (0)