Skip to content

[skip changelog] Fix sketch tests on Windows #1061

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

Merged
merged 1 commit into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand Down
44 changes: 17 additions & 27 deletions test/test_sketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected].
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):
Expand Down