Skip to content

Commit 4d5a247

Browse files
committed
[skip changelog] Add compile with invalid build.options.json test
1 parent 7df8737 commit 4d5a247

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Diff for: test/test_compile.py

+26
Original file line numberDiff line numberDiff line change
@@ -1021,3 +1021,29 @@ def test_compile_with_conflicting_libraries_include(run_command, data_dir, copy_
10211021
assert 'Multiple libraries were found for "OneWire.h"' in lines
10221022
assert f"Used: {one_wire_lib_path}" in lines
10231023
assert f"Not used: {one_wire_ng_lib_path}" in lines
1024+
1025+
1026+
def test_compile_with_invalid_build_options_json(run_command, data_dir):
1027+
assert run_command("update")
1028+
1029+
assert run_command("core install arduino:[email protected]")
1030+
1031+
sketch_name = "CompileInvalidBuildOptionsJson"
1032+
sketch_path = Path(data_dir, sketch_name)
1033+
fqbn = "arduino:avr:uno"
1034+
1035+
# Create a test sketch
1036+
assert run_command(f"sketch new {sketch_path}")
1037+
1038+
# Get the build directory
1039+
sketch_path_md5 = hashlib.md5(bytes(sketch_path)).hexdigest().upper()
1040+
build_dir = Path(tempfile.gettempdir(), f"arduino-sketch-{sketch_path_md5}")
1041+
1042+
assert run_command(f"compile -b {fqbn} {sketch_path} --verbose")
1043+
1044+
# Breaks the build.options.json file
1045+
build_options_json = build_dir / "build.options.json"
1046+
with open(build_options_json, "w") as f:
1047+
f.write("invalid json")
1048+
1049+
assert run_command(f"compile -b {fqbn} {sketch_path} --verbose")

0 commit comments

Comments
 (0)