Skip to content

Commit 06d9f8b

Browse files
Migrate TestCompileWithInvalidUrl from test_compile_part_2.py to compile_part_2_test.go
1 parent 6814a08 commit 06d9f8b

File tree

2 files changed

+30
-28
lines changed

2 files changed

+30
-28
lines changed

internal/integrationtest/compile/compile_part_2_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,33 @@ func TestCompileWithCustomBuildPath(t *testing.T) {
152152
require.NoFileExists(t, buildDir.Join(sketchName+".ino.with_bootloader.bin").String())
153153
require.NoFileExists(t, buildDir.Join(sketchName+".ino.with_bootloader.hex").String())
154154
}
155+
156+
func TestCompileWithInvalidUrl(t *testing.T) {
157+
env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t)
158+
defer env.CleanUp()
159+
160+
// Init the environment explicitly
161+
_, _, err := cli.Run("core", "update-index")
162+
require.NoError(t, err)
163+
164+
// Download latest AVR
165+
_, _, err = cli.Run("core", "install", "arduino:avr")
166+
require.NoError(t, err)
167+
168+
sketchName := "CompileWithInvalidURL"
169+
sketchPath := cli.SketchbookDir().Join(sketchName)
170+
fqbn := "arduino:avr:uno"
171+
172+
// Create a test sketch
173+
_, _, err = cli.Run("sketch", "new", sketchPath.String())
174+
require.NoError(t, err)
175+
176+
_, _, err = cli.Run("config", "init", "--dest-dir", ".", "--additional-urls", "https://example.com/package_example_index.json")
177+
require.NoError(t, err)
178+
179+
_, stderr, err := cli.Run("compile", "-b", fqbn, sketchPath.String())
180+
require.NoError(t, err)
181+
require.Contains(t, string(stderr), "Error initializing instance: Loading index file: loading json index file")
182+
expectedIndexfile := cli.DataDir().Join("package_example_index.json")
183+
require.Contains(t, string(stderr), "loading json index file "+expectedIndexfile.String()+": open "+expectedIndexfile.String()+":")
184+
}

test/test_compile_part_2.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -90,34 +90,6 @@ def test_compile_with_export_binaries_config(run_command, data_dir, downloads_di
9090
assert (sketch_path / "build" / fqbn.replace(":", ".") / f"{sketch_name}.ino.with_bootloader.hex").exists()
9191

9292

93-
def test_compile_with_invalid_url(run_command, data_dir):
94-
# Init the environment explicitly
95-
run_command(["core", "update-index"])
96-
97-
# Download latest AVR
98-
run_command(["core", "install", "arduino:avr"])
99-
100-
sketch_name = "CompileWithInvalidURL"
101-
sketch_path = Path(data_dir, sketch_name)
102-
fqbn = "arduino:avr:uno"
103-
104-
# Create a test sketch
105-
assert run_command(["sketch", "new", sketch_path])
106-
107-
# Create settings with custom invalid URL
108-
assert run_command(
109-
["config", "init", "--dest-dir", ".", "--additional-urls", "https://example.com/package_example_index.json"]
110-
)
111-
112-
# Verifies compilation fails cause of missing local index file
113-
res = run_command(["compile", "-b", fqbn, sketch_path])
114-
assert res.ok
115-
lines = [l.strip() for l in res.stderr.splitlines()]
116-
assert "Error initializing instance: Loading index file: loading json index file" in lines[0]
117-
expected_index_file = Path(data_dir, "package_example_index.json")
118-
assert f"loading json index file {expected_index_file}: " + f"open {expected_index_file}:" in lines[-1]
119-
120-
12193
def test_compile_with_custom_libraries(run_command, copy_sketch):
12294
# Creates config with additional URL to install necessary core
12395
url = "http://arduino.esp8266.com/stable/package_esp8266com_index.json"

0 commit comments

Comments
 (0)