Skip to content

Commit da8111c

Browse files
author
Roberto Sora
committed
add whitebox testing to combo compile upload command integ test
1 parent dba2d34 commit da8111c

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

test/test_compile.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def test_compile_with_simple_sketch(run_command, data_dir):
5757

5858
@pytest.mark.skipif(running_on_ci(), reason="VMs have no serial ports")
5959
def test_compile_and_compile_combo(run_command, data_dir):
60-
6160
# Init the environment explicitly
6261
result = run_command("core update-index")
6362
assert result.ok
@@ -68,7 +67,8 @@ def test_compile_and_compile_combo(run_command, data_dir):
6867
assert result.ok
6968

7069
# Create a test sketch
71-
sketch_path = os.path.join(data_dir, "CompileAndUploadIntegrationTest")
70+
sketch_name = "CompileAndUploadIntegrationTest"
71+
sketch_path = os.path.join(data_dir, sketch_name)
7272
result = run_command("sketch new CompileAndUploadIntegrationTest")
7373
assert result.ok
7474
assert "Sketch created in: {}".format(sketch_path) in result.stdout
@@ -96,7 +96,7 @@ def test_compile_and_compile_combo(run_command, data_dir):
9696
# }
9797
# ]
9898

99-
detected_boards = []
99+
detected_boards = []
100100

101101
ports = json.loads(result.stdout)
102102
assert isinstance(ports, list)
@@ -109,12 +109,21 @@ def test_compile_and_compile_combo(run_command, data_dir):
109109
assert len(detected_boards) >= 1, "There are no boards available for testing"
110110

111111
# Build sketch for each detected board
112-
for board in detected_boards:
112+
for board in detected_boards:
113+
log_file = "compile.log"
113114
result = run_command(
114-
"compile -b {fqbn} --upload -p {address} {sketch_path}".format(
115+
"compile -b {fqbn} --upload -p {address} {sketch_path} --log-format json --log-file {log_file} --log-level trace".format(
115116
fqbn=board.get('fqbn'),
116117
address=board.get('address'),
117-
sketch_path=sketch_path)
118+
sketch_path=sketch_path,
119+
log_file=log_file
120+
)
118121
)
122+
log_json = open(log_file,'r')
123+
log_json_lines = log_json.readlines()
124+
assert is_value_in_any_json_log_message("copying sketch build output",log_json_lines)
125+
assert is_value_in_any_json_log_message("Executing `arduino upload`",log_json_lines)
119126
assert result.ok
120-
assert "Verify successful" in result.stdout
127+
128+
def is_value_in_any_json_log_message(value,log_json_lines ):
129+
return bool([index for index, line in enumerate(log_json_lines) if json.loads(line).get("msg") == value])

0 commit comments

Comments
 (0)