Skip to content

Commit 4b64cde

Browse files
authored
./.github/scripts: When only when skecth is built, the build directory (#7037)
should default to "build".
1 parent fef932c commit 4b64cde

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

Diff for: .github/scripts/sketch_utils.sh

+18-6
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,30 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
109109
exit 1
110110
fi
111111

112+
# The directory that will hold all the artifcats (the build directory) is
113+
# provided through:
114+
# 1. An env variable called ARDUINO_BUILD_DIR.
115+
# 2. Created at the sketch level as "build" in the case of a single
116+
# configuration test.
117+
# 3. Created at the sketch level as "buildX" where X is the number
118+
# of configuration built in case of a multiconfiguration test.
119+
112120
ARDUINO_CACHE_DIR="$HOME/.arduino/cache.tmp"
113-
if [ -z "$ARDUINO_BUILD_DIR" ]; then
114-
build_dir="$sketchdir/build"
115-
else
121+
if [ -n "$ARDUINO_BUILD_DIR" ]; then
116122
build_dir="$ARDUINO_BUILD_DIR"
123+
elif [ $len -eq 1 ]; then
124+
build_dir="$sketchdir/build"
117125
fi
118126

119127
mkdir -p "$ARDUINO_CACHE_DIR"
120128
for i in `seq 0 $(($len - 1))`
121129
do
122-
rm -rf "$build_dir$i"
123-
mkdir -p "$build_dir$i"
130+
if [ $len -ne 1 ]; then
131+
build_dir="$sketchdir/build$i"
132+
fi
133+
rm -rf $build_dir
134+
mkdir -p $build_dir
135+
124136
currfqbn=`echo $fqbn | jq -r --argjson i $i '.[$i]'`
125137
sketchname=$(basename $sketchdir)
126138
echo "Building $sketchname with FQBN=$currfqbn"
@@ -134,7 +146,7 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
134146
-hardware "$user_path/hardware" \
135147
-libraries "$user_path/libraries" \
136148
-build-cache "$ARDUINO_CACHE_DIR" \
137-
-build-path "$build_dir$i" \
149+
-build-path "$build_dir" \
138150
$xtra_opts "${sketchdir}/${sketchname}.ino"
139151
done
140152
}

Diff for: .github/scripts/tests_run.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,24 @@ function run_test() {
1414
len=1
1515
fi
1616

17+
if [ $len -eq 1 ]; then
18+
build_dir="tests/$sketchname/build"
19+
report_file="tests/$sketchname/$sketchname.xml"
20+
fi
21+
1722
for i in `seq 0 $(($len - 1))`
1823
do
1924
echo "Running test: $sketchname -- Config: $i"
2025
if [ $erase_flash -eq 1 ]; then
2126
esptool.py -c $target erase_flash
2227
fi
2328

24-
pytest tests --build-dir tests/$sketchname/build$i -k test_$sketchname --junit-xml=tests/$sketchname/$sketchname$i.xml
29+
if [ $len -ne 1 ]; then
30+
build_dir="tests/$sketchname/build$i"
31+
report_file="tests/$sketchname/$sketchname$i.xml"
32+
fi
33+
34+
pytest tests --build-dir $build_dir -k test_$sketchname --junit-xml=$report_file
2535
result=$?
2636
if [ $result -ne 0 ]; then
2737
return $result

0 commit comments

Comments
 (0)