@@ -153,8 +153,8 @@ def test_compilesketches():
153
153
platforms = unittest .mock .sentinel .platforms
154
154
libraries = unittest .mock .sentinel .libraries
155
155
sketch_paths = "examples/FooSketchPath examples/BarSketchPath"
156
- expected_sketch_paths_list = [pathlib . PurePath ( "examples/FooSketchPath" ),
157
- pathlib . PurePath ( "examples/BarSketchPath" )]
156
+ expected_sketch_paths_list = [compilesketches . absolute_path ( path = "examples/FooSketchPath" ),
157
+ compilesketches . absolute_path ( path = "examples/BarSketchPath" )]
158
158
verbose = "false"
159
159
github_token = "fooGitHubToken"
160
160
report_sketch = unittest .mock .sentinel .report_sketch
@@ -771,19 +771,19 @@ def __init__(self):
771
771
"libraries, expected_manager, expected_path, expected_repository, expected_download" ,
772
772
[("" ,
773
773
[],
774
- [{compilesketches .CompileSketches .dependency_source_path_key : pathlib . PurePath ( os .environ ["GITHUB_WORKSPACE" ]) }],
774
+ [{compilesketches .CompileSketches .dependency_source_path_key : os .environ ["GITHUB_WORKSPACE" ]}],
775
775
[],
776
776
[]),
777
777
("foo bar" ,
778
778
[{compilesketches .CompileSketches .dependency_name_key : "foo" },
779
779
{compilesketches .CompileSketches .dependency_name_key : "bar" }],
780
- [{compilesketches .CompileSketches .dependency_source_path_key : pathlib . PurePath ( os .environ ["GITHUB_WORKSPACE" ]) }],
780
+ [{compilesketches .CompileSketches .dependency_source_path_key : os .environ ["GITHUB_WORKSPACE" ]}],
781
781
[],
782
782
[]),
783
783
("\" foo\" \" bar\" " ,
784
784
[{compilesketches .CompileSketches .dependency_name_key : "foo" },
785
785
{compilesketches .CompileSketches .dependency_name_key : "bar" }],
786
- [{compilesketches .CompileSketches .dependency_source_path_key : pathlib . PurePath ( os .environ ["GITHUB_WORKSPACE" ]) }],
786
+ [{compilesketches .CompileSketches .dependency_source_path_key : os .environ ["GITHUB_WORKSPACE" ]}],
787
787
[],
788
788
[]),
789
789
("-" ,
@@ -925,8 +925,7 @@ def test_install_libraries_from_path(capsys, monkeypatch, mocker, path_exists, l
925
925
symlink_to_calls .append (
926
926
unittest .mock .call (symlink_source_path ,
927
927
target = compilesketches .absolute_path (
928
- library [compilesketches .CompileSketches .dependency_source_path_key ]
929
- ),
928
+ library [compilesketches .CompileSketches .dependency_source_path_key ]),
930
929
target_is_directory = True ))
931
930
932
931
# noinspection PyUnresolvedReferences
@@ -1011,8 +1010,11 @@ def test_find_sketches(capsys):
1011
1010
)
1012
1011
with pytest .raises (expected_exception = SystemExit , match = "1" ):
1013
1012
compile_sketches .find_sketches ()
1014
- assert capsys .readouterr ().out .strip () == ("::error::Sketch path: " + str (pathlib .PurePath (nonexistent_sketch_path ))
1015
- + " doesn't exist" )
1013
+ assert capsys .readouterr ().out .strip () == (
1014
+ "::error::Sketch path: "
1015
+ + str (compilesketches .path_relative_to_workspace (path = nonexistent_sketch_path ))
1016
+ + " doesn't exist"
1017
+ )
1016
1018
1017
1019
# Test sketch path is a sketch file
1018
1020
compile_sketches = get_compilesketches_object (
@@ -1080,7 +1082,7 @@ def test_path_is_sketch():
1080
1082
(0 , True )])
1081
1083
def test_compile_sketch (capsys , mocker , returncode , expected_success ):
1082
1084
stdout = unittest .mock .sentinel .stdout
1083
- relative_sketch_path = pathlib .PurePath ("FooSketch" , "FooSketch.ino" )
1085
+ sketch_path = pathlib .Path ("FooSketch" , "FooSketch.ino" ). resolve ( )
1084
1086
1085
1087
# Stub
1086
1088
class CompilationData :
@@ -1095,19 +1097,19 @@ class CompilationData:
1095
1097
return_value = CompilationData ())
1096
1098
1097
1099
compilation_result = compile_sketches .compile_sketch (
1098
- sketch_path = pathlib . PurePath ( os . environ [ "GITHUB_WORKSPACE" ]). joinpath ( relative_sketch_path )
1100
+ sketch_path = sketch_path
1099
1101
)
1100
1102
1101
1103
expected_stdout = (
1102
- "::group::Compiling sketch: " + str (relative_sketch_path ) + "\n "
1104
+ "::group::Compiling sketch: " + str (compilesketches . path_relative_to_workspace ( path = sketch_path ) ) + "\n "
1103
1105
+ str (stdout ) + "\n "
1104
1106
+ "::endgroup::"
1105
1107
)
1106
1108
if not expected_success :
1107
1109
expected_stdout += "\n ::error::Compilation failed"
1108
1110
assert capsys .readouterr ().out .strip () == expected_stdout
1109
1111
1110
- assert compilation_result .sketch == relative_sketch_path
1112
+ assert compilation_result .sketch == sketch_path
1111
1113
assert compilation_result .success == expected_success
1112
1114
assert compilation_result .output == stdout
1113
1115
@@ -1124,7 +1126,6 @@ def __init__(self, sketch_input):
1124
1126
1125
1127
compilation_result = CompilationResult (sketch_input = sketch )
1126
1128
1127
- sketch_absolute_path = unittest .mock .sentinel .sketch_absolute_path
1128
1129
previous_compilation_result = unittest .mock .sentinel .previous_compilation_result
1129
1130
sketch_size = unittest .mock .sentinel .sketch_size
1130
1131
@@ -1148,7 +1149,6 @@ def checkout(self):
1148
1149
return_value = do_size_deltas_report )
1149
1150
mocker .patch ("git.Repo" , autospec = True , return_value = Repo ())
1150
1151
mocker .patch ("compilesketches.CompileSketches.checkout_pull_request_base_ref" , autospec = True )
1151
- mocker .patch ("compilesketches.absolute_path" , autospec = True , return_value = sketch_absolute_path )
1152
1152
mocker .patch ("compilesketches.CompileSketches.compile_sketch" , autospec = True ,
1153
1153
return_value = previous_compilation_result )
1154
1154
mocker .patch .object (Repo , "checkout" )
@@ -1162,8 +1162,7 @@ def checkout(self):
1162
1162
if do_size_deltas_report :
1163
1163
git .Repo .assert_called_once_with (path = os .environ ["GITHUB_WORKSPACE" ])
1164
1164
compile_sketches .checkout_pull_request_base_ref .assert_called_once ()
1165
- compilesketches .absolute_path .assert_called_once_with (path = compilation_result .sketch )
1166
- compile_sketches .compile_sketch .assert_called_once_with (compile_sketches , sketch_path = sketch_absolute_path )
1165
+ compile_sketches .compile_sketch .assert_called_once_with (compile_sketches , sketch_path = compilation_result .sketch )
1167
1166
Repo .checkout .assert_called_once_with (original_git_ref )
1168
1167
get_sketch_size_from_output_calls .append (
1169
1168
unittest .mock .call (compile_sketches , compilation_result = previous_compilation_result ))
@@ -1269,11 +1268,11 @@ def checkout(self):
1269
1268
get_compilesketches_object ().not_applicable_indicator )]
1270
1269
)
1271
1270
def test_get_sketch_report_from_output (compilation_success , compilation_output , flash , ram ):
1272
- sketch_path = unittest . mock . sentinel . sketch
1271
+ sketch_path = pathlib . PurePath ( "foo/bar" )
1273
1272
compilation_output = compilation_output .format (flash = str (flash ), ram = str (ram ))
1274
1273
compile_sketches = get_compilesketches_object ()
1275
1274
compilation_result = type ("CompilationResult" , (),
1276
- {compile_sketches . report_sketch_key : sketch_path ,
1275
+ {"sketch" : sketch_path ,
1277
1276
"success" : compilation_success ,
1278
1277
"output" : compilation_output })
1279
1278
0 commit comments