Skip to content

Commit 64320d1

Browse files
committed
check cache state dir state in ci
1 parent 75598a7 commit 64320d1

File tree

8 files changed

+224
-37
lines changed

8 files changed

+224
-37
lines changed

.github/workflows/build-ide.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jobs:
4242
python-version: '3.x'
4343
- run: |
4444
python ./tools/test_mkbuildoptglobals.py --quiet
45+
- run: |
46+
bash ./tests/install_arduino.sh
47+
bash ./tests/test_mkbuildoptglobals.sh run
4548
4649
# Examples are built in parallel to avoid CI total job time limitation
4750
build-linux:

tests/build.sh

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,7 @@
33
# expect to have git available
44
root=$(git rev-parse --show-toplevel)
55

6-
# general configuration related to the builder itself
7-
ESP8266_ARDUINO_BUILD_DIR=${ESP8266_ARDUINO_BUILD_DIR:-$root}
8-
ESP8266_ARDUINO_BUILDER=${ESP8266_ARDUINO_BUILDER:-arduino}
9-
ESP8266_ARDUINO_PRESERVE_CACHE=${ESP8266_ARDUINO_PRESERVE_CACHE:-}
10-
11-
# sketch build options
12-
ESP8266_ARDUINO_DEBUG=${ESP8266_ARDUINO_DEBUG:-nodebug}
13-
ESP8266_ARDUINO_LWIP=${ESP8266_ARDUINO_LWIP:-default}
14-
ESP8266_ARDUINO_SKETCHES=${ESP8266_ARDUINO_SKETCHES:-}
15-
16-
ESP8266_ARDUINO_CLI=${ESP8266_ARDUINO_CLI:-$HOME/.local/bin/arduino-cli}
17-
18-
# ref. https://arduino.github.io/arduino-cli/1.2/configuration/#default-directories
19-
case "${RUNNER_OS:-Linux}" in
20-
"Linux")
21-
ESP8266_ARDUINO_HARDWARE=${ESP8266_ARDUINO_HARDWARE:-$HOME/Arduino/hardware}
22-
ESP8266_ARDUINO_LIBRARIES=${ESP8266_ARDUINO_LIBRARIES:-$HOME/Arduino/libraries}
23-
;;
24-
"macOS")
25-
ESP8266_ARDUINO_HARDWARE=${ESP8266_ARDUINO_HARDWARE:-$HOME/Documents/Arduino/hardware}
26-
ESP8266_ARDUINO_LIBRARIES=${ESP8266_ARDUINO_LIBRARIES:-$HOME/Documents/Arduino/libraries}
27-
;;
28-
"Windows")
29-
ESP8266_ARDUINO_HARDWARE=${ESP8266_ARDUINO_HARDWARE:-$HOME/Documents/Arduino/hardware}
30-
ESP8266_ARDUINO_LIBRARIES=${ESP8266_ARDUINO_LIBRARIES:-$HOME/Documents/Arduino/libraries}
31-
;;
32-
*)
33-
echo 'Unknown ${RUNNER_OS} = "' ${RUNNER_OS} '"'
34-
exit 2
35-
esac
36-
37-
source "$root/tests/lib-skip-ino.sh"
38-
source "$root/tests/common.sh"
6+
source "$root/tests/env.sh"
397

408
cmd=${0##*/}
419
usage="
@@ -56,10 +24,6 @@ USAGE:
5624
$cmd - build every .ino file from ESP8266_ARDUINO_SKETCHES
5725
"
5826

59-
mod=1
60-
rem=0
61-
cnt=0
62-
6327
if [ "$#" -eq 1 ] ; then
6428
case "$1" in
6529
"-h")

tests/install_arduino.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
set -x
4+
5+
root=$(git rev-parse --show-toplevel)
6+
source "$root/tests/env.sh"
7+
8+
install_arduino "$ESP8266_ARDUINO_DEBUG"

tests/test_mkbuildoptglobals.sh

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#!/usr/bin/env bash
2+
3+
root=$(git rev-parse --show-toplevel)
4+
source "$root/tests/env.sh"
5+
6+
unset -f step_summary
7+
function step_summary()
8+
{
9+
echo ""
10+
}
11+
12+
export ARDUINO_BUILD_CACHE_PATH="$cache_dir"
13+
14+
sketches="${cache_dir}/sketches/"
15+
cores="${cache_dir}/cores/"
16+
17+
esp8266_dir="${ESP8266_ARDUINO_BUILD_DIR}"
18+
commonfileh="${esp8266_dir}/cores/esp8266/CommonHFile.h"
19+
20+
tests_dir="$root/tests/test_mkbuildoptglobals"
21+
tests=$(ls -1 "$tests_dir" | sed 's/.sh$//g')
22+
23+
function name_size_mtime()
24+
{
25+
stat --printf '%n:%s:%Y' "$1"
26+
}
27+
28+
function most_recent_file()
29+
{
30+
local name="$1"
31+
local location="$2"
32+
echo $(readlink -f "${location}/"$(ls -t1 "${location}" | grep "$name" | head -1))
33+
}
34+
35+
function most_recent_dir()
36+
{
37+
local location="$1"
38+
echo $(readlink -f "${location}/"$(ls -t1 "$location" | head -1))
39+
}
40+
41+
function assert_build()
42+
{
43+
local name="$1"
44+
local build_dir="$2"
45+
local size_check="${3:-0}"
46+
47+
local build_opt="$build_dir"/sketch/build.opt
48+
test -e "$build_opt"
49+
50+
local globals_h="$build_dir"/${name}.ino.globals.h
51+
test -e "$globals_h"
52+
53+
if [ "$size_check" = "1" ] ; then
54+
test -s "$build_opt"
55+
test -s "$globals_h"
56+
fi
57+
}
58+
59+
function assert_core()
60+
{
61+
local size_check="$1"
62+
63+
if [ "$size_check" = "1" ] ; then
64+
test -s "$commonfileh"
65+
else
66+
test ! -s "$commonfileh"
67+
fi
68+
69+
}
70+
71+
function build_esp8266_example()
72+
{
73+
local name="$1"
74+
75+
ESP8266_ARDUINO_SKETCHES="$root/libraries/esp8266/examples/${name}/${name}.ino"
76+
build_sketches_with_arduino "$ESP8266_ARDUINO_LWIP" "$mod" "$rem" "$cnt"
77+
}
78+
79+
function make_commonh_stat()
80+
{
81+
local stat=$(name_size_mtime "$commonfileh")
82+
test -n "$stat"
83+
84+
echo "$stat"
85+
}
86+
87+
function make_core_stat()
88+
{
89+
local recent_core=$(most_recent_dir "$cores")
90+
local recent_file=$(most_recent_file "core.a" "$recent_core")
91+
92+
local stat=$(name_size_mtime "$recent_file")
93+
test -n "$stat"
94+
95+
echo "$stat"
96+
}
97+
98+
case "${1:-}" in
99+
"list")
100+
printf "%s\n" $tests
101+
;;
102+
103+
"run")
104+
for test in $tests ; do
105+
printf "Checking \"%s\"\n" "$test"
106+
/usr/bin/env bash $root/tests/test_mkbuildoptglobals.sh $test
107+
done
108+
;;
109+
*)
110+
source "$tests_dir/${1}.sh"
111+
;;
112+
esac
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
function buildopt_then_buildopt()
2+
{
3+
build_esp8266_example "GlobalBuildOptions"
4+
5+
local last_sketch=$(most_recent_dir "$sketches")
6+
assert_build "GlobalBuildOptions" "$last_sketch" 1
7+
assert_core 1
8+
9+
local globalbuildoptions_commonh_stat=$(make_commonh_stat)
10+
local globalbuildoptions_core_stat=$(make_core_stat)
11+
12+
build_esp8266_example "HwdtStackDump"
13+
14+
last_sketch=$(most_recent_dir "$sketches")
15+
assert_build "HwdtStackDump" "$last_sketch" 1
16+
assert_core 1
17+
18+
local hwdtstackdump_commonh_stat=$(make_commonh_stat)
19+
local hwdtstackdump_core_stat=$(make_core_stat)
20+
21+
test "$hwdtstackdump_commonh_stat" != "$globalbuildoptions_commonh_stat"
22+
test "$hwdtstackdump_core_stat" != "$globalbuildoptions_core_stat"
23+
}
24+
25+
buildopt_then_buildopt
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
function buildopt_then_nobuildopt()
2+
{
3+
build_esp8266_example "GlobalBuildOptions"
4+
5+
local last_sketch=$(most_recent_dir "$sketches")
6+
assert_build "GlobalBuildOptions" "$last_sketch" 1
7+
assert_core 1
8+
9+
local globalbuildoptions_commonh_stat=$(make_commonh_stat)
10+
local globalbuildoptions_core_stat=$(make_core_stat)
11+
12+
build_esp8266_example "Blink"
13+
14+
last_sketch=$(most_recent_dir "$sketches")
15+
assert_build "Blink" "$last_sketch" 0
16+
assert_core 0
17+
18+
local blink_commonh_stat=$(make_commonh_stat)
19+
local blink_core_stat=$(make_core_stat)
20+
21+
test "$globalbuildoptions_commonh_stat" != "$blink_commonh_stat"
22+
test "$globalbuildoptions_core_stat" != "$blink_core_stat"
23+
}
24+
25+
buildopt_then_nobuildopt
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
function nobuildopt()
2+
{
3+
build_esp8266_example "Blink"
4+
5+
local last_sketch=$(most_recent_dir "$sketches")
6+
assert_build "Blink.ino" "$last_sketch" 0
7+
assert_core 0
8+
9+
local blink_commonh_stat=$(make_commonh_stat)
10+
local blink_core_stat=$(make_core_stat)
11+
12+
build_esp8266_example "TestEspApi"
13+
14+
last_sketch=$(most_recent_dir "$sketches")
15+
assert_build "TestEspApi" "$last_sketch" 0
16+
assert_core 0
17+
18+
local testespapi_commonh_stat=$(make_commonh_stat)
19+
local testespapi_core_stat=$(make_core_stat)
20+
21+
test "$blink_commonh_stat" = "$testespapi_commonh_stat"
22+
test "$blink_core_stat" = "$testespapi_core_stat"
23+
}
24+
25+
nobuildopt
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
function nobuildopt_then_buildopt()
2+
{
3+
build_esp8266_example "Blink"
4+
5+
local last_sketch=$(most_recent_dir "$sketches")
6+
assert_build "Blink" "$last_sketch" 0
7+
assert_core 0
8+
9+
local blink_commonh_stat=$(make_commonh_stat)
10+
local blink_core_stat=$(make_core_stat)
11+
12+
build_esp8266_example "HwdtStackDump"
13+
14+
last_sketch=$(most_recent_dir "$sketches")
15+
assert_build "HwdtStackDump" "$last_sketch" 1
16+
assert_core 1
17+
18+
local hwdtstackdump_commonh_stat=$(make_commonh_stat)
19+
local hwdtstackdump_core_stat=$(make_core_stat)
20+
21+
test "$hwdtstackdump_commonh_stat" != "$blink_commonh_stat"
22+
test "$hwdtstackdump_core_stat" != "$blink_core_stat"
23+
}
24+
25+
nobuildopt_then_buildopt

0 commit comments

Comments
 (0)