You need to implement a functionality to compile and verify an Arduino sketch using the Arduino CLI tool. The specific Arduino sketch to be verified is named arduino-unit-test-with-mocking.ino, and it is located in a directory named arduino-unit-test-with-mocking one level above the directory where your code will reside.
Requirements:
Implement a script that:
Navigates to the arduino-unit-test-with-mocking directory.
Uses the arduino command to verify (compile) the arduino-unit-test-with-mocking.ino file.
Location and Naming:
Your implementation should be a shell script named verify_sketch.sh.
Place this script in the /app/ directory.
Expected Inputs and Outputs:
There are no direct inputs taken from parameters for this specific task.
Outputs:
If the verification of the sketch is successful, the script should complete without any output.
If the verification fails (e.g., due to errors in the code or in finding the file), your script should output the message "error!" and exit with a non-zero status code.
Additional Notes:
Make sure to handle any necessary directory navigation correctly to reach the sketch before attempting to verify it.
Ensure that the arduino CLI tool is installed and accessible in your environment for the verification command to work.
Tests
The following test script will be used to verify your solution:
bash
#!/bin/bash
script_name=$0
script_path=$(dirname "$0")
pushd $script_path/../arduino-unit-test-with-mocking/ && \
arduino --verify arduino-unit-test-with-mocking.ino
if [ ${?} -ne 0 ]; then echo "error!"; exit 1; fi