@@ -953,3 +953,46 @@ def test_compile_with_library_priority(run_command, data_dir):
953
953
f" Not used: { cli_installed_lib_path } " ,
954
954
]
955
955
assert "\n " .join (expected_output ) in res .stdout
956
+
957
+
958
+ def test_recompile_with_different_library (run_command , data_dir ):
959
+ assert run_command ("update" )
960
+
961
+ assert run_command (
"core install arduino:[email protected] " )
962
+
963
+ sketch_name = "RecompileCompileSketchWithDifferentLibrary"
964
+ sketch_path = Path (data_dir , sketch_name )
965
+ fqbn = "arduino:avr:uno"
966
+
967
+ # Install library
968
+ assert run_command ("lib install WiFi101" )
969
+
970
+ # Manually installs the same library already installed
971
+ git_url = "https://github.com/arduino-libraries/WiFi101.git"
972
+ manually_install_lib_path = Path (data_dir , "my-libraries" , "WiFi101" )
973
+ assert Repo .clone_from (git_url , manually_install_lib_path , multi_options = ["-b 0.16.1" ])
974
+
975
+ # Create new sketch and add library include
976
+ assert run_command (f"sketch new { sketch_path } " )
977
+ sketch_file = sketch_path / f"{ sketch_name } .ino"
978
+ lines = []
979
+ with open (sketch_file , "r" ) as f :
980
+ lines = f .readlines ()
981
+ lines = ["#include <WiFi101.h>" ] + lines
982
+ with open (sketch_file , "w" ) as f :
983
+ f .writelines (lines )
984
+
985
+ sketch_path_md5 = hashlib .md5 (bytes (sketch_path )).hexdigest ().upper ()
986
+ build_dir = Path (tempfile .gettempdir (), f"arduino-sketch-{ sketch_path_md5 } " )
987
+
988
+ # Compile sketch using library not managed by CLI
989
+ res = run_command (f"compile -b { fqbn } --library { manually_install_lib_path } { sketch_path } -v" )
990
+ assert res .ok
991
+ obj_path = build_dir / "libraries" / "WiFi101" / "WiFi.cpp.o"
992
+ assert f"Using previously compiled file: { obj_path } " not in res .stdout
993
+
994
+ # Compile again using library installed from CLI
995
+ res = run_command (f"compile -b { fqbn } { sketch_path } -v" )
996
+ assert res .ok
997
+ obj_path = build_dir / "libraries" / "WiFi101" / "WiFi.cpp.o"
998
+ assert f"Using previously compiled file: { obj_path } " not in res .stdout
0 commit comments