Unverified Commit ff3302fc authored by Silvano Cerza's avatar Silvano Cerza Committed by GitHub

[skip changelog] Fix sketch tests on Windows (#1061)

parent b9f4d312
......@@ -113,6 +113,7 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/imjasonmiller/godice v0.1.2 h1:T1/sW/HoDzFeuwzOOuQjmeMELz9CzZ53I2CnD+08zD4=
github.com/imjasonmiller/godice v0.1.2/go.mod h1:8cTkdnVI+NglU2d6sv+ilYcNaJ5VSTBwvMbFULJd/QQ=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
......@@ -135,6 +136,7 @@ github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
......
......@@ -12,54 +12,44 @@
# otherwise use the software for commercial activities involving the Arduino
# software without disclosing the source code of your own applications. To purchase
# a commercial license, send an email to license@arduino.cc.
import os
import platform
import zipfile
from pathlib import Path
import pytest
from test.common import running_on_ci
@pytest.mark.skipif(
running_on_ci() and platform.system() == "Windows",
reason="Test disabled on Github Actions Win VM until tmpdir inconsistent behavior bug is fixed",
)
def test_sketch_new(run_command, working_dir):
# Create a test sketch in current directory
current_path = working_dir
sketch_name = "SketchNewIntegrationTest"
current_sketch_path = os.path.join(current_path, sketch_name)
result = run_command("sketch new {}".format(sketch_name))
current_sketch_path = Path(current_path, sketch_name)
result = run_command(f"sketch new {sketch_name}")
assert result.ok
assert "Sketch created in: {}".format(current_sketch_path) in result.stdout
assert os.path.isfile(os.path.join(current_sketch_path, sketch_name + ".ino"))
assert f"Sketch created in: {current_sketch_path}" in result.stdout
assert Path(current_sketch_path, f"{sketch_name}.ino").is_file()
# Create a test sketch in current directory but using an absolute path
sketch_name = "SketchNewIntegrationTestAbsolute"
current_sketch_path = os.path.join(current_path, sketch_name)
result = run_command("sketch new {}".format(current_sketch_path))
current_sketch_path = Path(current_path, sketch_name)
result = run_command(f'sketch new "{current_sketch_path}"')
assert result.ok
assert "Sketch created in: {}".format(current_sketch_path) in result.stdout
assert os.path.isfile(os.path.join(current_sketch_path, sketch_name + ".ino"))
assert f"Sketch created in: {current_sketch_path}" in result.stdout
assert Path(current_sketch_path, f"{sketch_name}.ino").is_file()
# Create a test sketch in current directory subpath but using an absolute path
sketch_name = "SketchNewIntegrationTestSubpath"
sketch_subpath = os.path.join("subpath", sketch_name)
current_sketch_path = os.path.join(current_path, sketch_subpath)
result = run_command("sketch new {}".format(sketch_subpath))
sketch_subpath = Path("subpath", sketch_name)
current_sketch_path = Path(current_path, sketch_subpath)
result = run_command(f"sketch new {sketch_subpath}")
assert result.ok
assert "Sketch created in: {}".format(current_sketch_path) in result.stdout
assert os.path.isfile(os.path.join(current_sketch_path, sketch_name + ".ino"))
assert f"Sketch created in: {current_sketch_path}" in result.stdout
assert Path(current_sketch_path, f"{sketch_name}.ino").is_file()
# Create a test sketch in current directory using .ino extension
sketch_name = "SketchNewIntegrationTestDotIno"
current_sketch_path = os.path.join(current_path, sketch_name)
result = run_command("sketch new {}".format(sketch_name + ".ino"))
current_sketch_path = Path(current_path, sketch_name)
result = run_command(f"sketch new {sketch_name}.ino")
assert result.ok
assert "Sketch created in: {}".format(current_sketch_path) in result.stdout
assert os.path.isfile(os.path.join(current_sketch_path, sketch_name + ".ino"))
assert f"Sketch created in: {current_sketch_path}" in result.stdout
assert Path(current_sketch_path, f"{sketch_name}.ino").is_file()
def verify_zip_contains_sketch_excluding_build_dir(files):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment