Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Migrate TestCompileSketchWithMultipleMainFiles from test_compile_part…
…_3.py to compile_part_3_test.go
  • Loading branch information
MatteoPologruto committed Oct 13, 2022
commit 648268660f384608712548d2e2956da651444d91
42 changes: 42 additions & 0 deletions internal/integrationtest/compile/compile_part_3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,45 @@ func TestCompileSketchWithPdeExtension(t *testing.T) {
require.Contains(t, string(stderr), "Sketches with .pde extension are deprecated, please rename the following files to .ino:")
require.Contains(t, string(stderr), sketchFilePde.String())
}

func TestCompileSketchWithMultipleMainFiles(t *testing.T) {
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
defer env.CleanUp()

// Init the environment explicitly
_, _, err := cli.Run("update")
require.NoError(t, err)

// Install core to compile
_, _, err = cli.Run("core", "install", "arduino:avr@1.8.3")
require.NoError(t, err)

sketchName := "CompileSketchMultipleMainFiles"
sketchPath := cli.SketchbookDir().Join(sketchName)
fqbn := "arduino:avr:uno"

// Create a test sketch
_, _, err = cli.Run("sketch", "new", sketchPath.String())
require.NoError(t, err)

// Copy .ino sketch file to .pde
sketchFileIno := sketchPath.Join(sketchName + ".ino")
sketchFilePde := sketchPath.Join(sketchName + ".pde")
err = sketchFileIno.CopyTo(sketchFilePde)
require.NoError(t, err)

// Build sketch from folder
_, stderr, err := cli.Run("compile", "--clean", "-b", fqbn, sketchPath.String())
require.Error(t, err)
require.Contains(t, string(stderr), "Error opening sketch: multiple main sketch files found")

// Build sketch from .ino file
_, stderr, err = cli.Run("compile", "--clean", "-b", fqbn, sketchFileIno.String())
require.Error(t, err)
require.Contains(t, string(stderr), "Error opening sketch: multiple main sketch files found")

// Build sketch from .pde file
_, stderr, err = cli.Run("compile", "--clean", "-b", fqbn, sketchFilePde.String())
require.Error(t, err)
require.Contains(t, string(stderr), "Error opening sketch: multiple main sketch files found")
}
35 changes: 0 additions & 35 deletions test/test_compile_part_3.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,41 +39,6 @@
# assert "Skipping dependencies detection for precompiled library Arduino_TensorFlowLite" in result.stdout


def test_compile_sketch_with_multiple_main_files(run_command, data_dir):
# Init the environment explicitly
assert run_command(["update"])

# Install core to compile
assert run_command(["core", "install", "arduino:avr@1.8.3"])

sketch_name = "CompileSketchMultipleMainFiles"
sketch_path = Path(data_dir, sketch_name)
fqbn = "arduino:avr:uno"

# Create a test sketch
assert run_command(["sketch", "new", sketch_path])

# Copy .ino sketch file to .pde
sketch_ino_file = Path(sketch_path, f"{sketch_name}.ino")
sketch_pde_file = Path(sketch_path / f"{sketch_name}.pde")
shutil.copyfile(sketch_ino_file, sketch_pde_file)

# Build sketch from folder
res = run_command(["compile", "--clean", "-b", fqbn, sketch_path])
assert res.failed
assert "Error opening sketch: multiple main sketch files found" in res.stderr

# Build sketch from .ino file
res = run_command(["compile", "--clean", "-b", fqbn, sketch_ino_file])
assert res.failed
assert "Error opening sketch: multiple main sketch files found" in res.stderr

# Build sketch from .pde file
res = run_command(["compile", "--clean", "-b", fqbn, sketch_pde_file])
assert res.failed
assert "Error opening sketch: multiple main sketch files found" in res.stderr


def test_compile_sketch_case_mismatch_fails(run_command, data_dir):
# Init the environment explicitly
assert run_command(["update"])
Expand Down