1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-18 17:53:47 +01:00
This commit is contained in:
J. Nick Koston
2025-10-08 13:52:27 -10:00
parent 7cca868c41
commit 1448969019

View File

@@ -6,7 +6,7 @@ help() {
echo "Usage: $0 [-e <config|compile|clean>] [-c <string>] [-t <string>] [-f]" 1>&2 echo "Usage: $0 [-e <config|compile|clean>] [-c <string>] [-t <string>] [-f]" 1>&2
echo 1>&2 echo 1>&2
echo " - e - Parameter for esphome command. Default compile. Common alternative is config." 1>&2 echo " - e - Parameter for esphome command. Default compile. Common alternative is config." 1>&2
echo " - c - Component folder name to test. Default *. E.g. '-c logger'." 1>&2 echo " - c - Component folder name(s) to test. Default *. Supports comma-separated list. E.g. '-c logger' or '-c logger,api,ota'." 1>&2
echo " - t - Target name to test. Put '-t list' to display all possibilities. E.g. '-t esp32-s2-idf-51'." 1>&2 echo " - t - Target name to test. Put '-t list' to display all possibilities. E.g. '-t esp32-s2-idf-51'." 1>&2
echo " - f - Continue on fail. Don't exit on first error." 1>&2 echo " - f - Continue on fail. Don't exit on first error." 1>&2
exit 1 exit 1
@@ -65,50 +65,55 @@ start_esphome() {
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
} }
# Split comma-separated components into array
IFS=',' read -r -a component_list <<< "$target_component"
# Find all test yaml files. # Find all test yaml files.
# - `./tests/components/[target_component]/[test_name].[target_platform].yaml` # - `./tests/components/[target_component]/[test_name].[target_platform].yaml`
# - `./tests/components/[target_component]/[test_name].all.yaml` # - `./tests/components/[target_component]/[test_name].all.yaml`
for f in ./tests/components/$target_component/*.*.yaml; do for component_pattern in "${component_list[@]}"; do
[ -f "$f" ] || continue for f in ./tests/components/$component_pattern/*.*.yaml; do
IFS='/' read -r -a folder_name <<< "$f" [ -f "$f" ] || continue
target_component="${folder_name[3]}" IFS='/' read -r -a folder_name <<< "$f"
target_component="${folder_name[3]}"
IFS='.' read -r -a file_name <<< "${folder_name[4]}" IFS='.' read -r -a file_name <<< "${folder_name[4]}"
test_name="${file_name[0]}" test_name="${file_name[0]}"
target_platform="${file_name[1]}" target_platform="${file_name[1]}"
file_name_parts=${#file_name[@]} file_name_parts=${#file_name[@]}
if [ "$target_platform" = "all" ] || [ $file_name_parts = 2 ]; then if [ "$target_platform" = "all" ] || [ $file_name_parts = 2 ]; then
# Test has *not* defined a specific target platform. Need to run tests for all possible target platforms. # Test has *not* defined a specific target platform. Need to run tests for all possible target platforms.
for target_platform_file in ./tests/test_build_components/build_components_base.*.yaml; do for target_platform_file in ./tests/test_build_components/build_components_base.*.yaml; do
IFS='/' read -r -a folder_name <<< "$target_platform_file" IFS='/' read -r -a folder_name <<< "$target_platform_file"
IFS='.' read -r -a file_name <<< "${folder_name[3]}" IFS='.' read -r -a file_name <<< "${folder_name[3]}"
target_platform="${file_name[1]}" target_platform="${file_name[1]}"
start_esphome start_esphome
done done
else else
# Test has defined a specific target platform. # Test has defined a specific target platform.
# Validate we have a base test yaml for selected platform. # Validate we have a base test yaml for selected platform.
# The target_platform is sourced from the following location. # The target_platform is sourced from the following location.
# 1. `./tests/test_build_components/build_components_base.[target_platform].yaml` # 1. `./tests/test_build_components/build_components_base.[target_platform].yaml`
# 2. `./tests/test_build_components/build_components_base.[target_platform]-ard.yaml` # 2. `./tests/test_build_components/build_components_base.[target_platform]-ard.yaml`
target_platform_file="./tests/test_build_components/build_components_base.$target_platform.yaml" target_platform_file="./tests/test_build_components/build_components_base.$target_platform.yaml"
if ! [ -f "$target_platform_file" ]; then if ! [ -f "$target_platform_file" ]; then
echo "No base test file [./tests/test_build_components/build_components_base.$target_platform.yaml] for component test [$f] found." echo "No base test file [./tests/test_build_components/build_components_base.$target_platform.yaml] for component test [$f] found."
exit 1 exit 1
fi
for target_platform_file in ./tests/test_build_components/build_components_base.$target_platform*.yaml; do
# trim off "./tests/test_build_components/build_components_base." prefix
target_platform_with_version=${target_platform_file:52}
# ...now remove suffix starting with "." leaving just the test target hardware and software platform (possibly with version)
# For example: "esp32-s3-idf-50"
target_platform_with_version=${target_platform_with_version%.*}
start_esphome
done
fi fi
done
for target_platform_file in ./tests/test_build_components/build_components_base.$target_platform*.yaml; do
# trim off "./tests/test_build_components/build_components_base." prefix
target_platform_with_version=${target_platform_file:52}
# ...now remove suffix starting with "." leaving just the test target hardware and software platform (possibly with version)
# For example: "esp32-s3-idf-50"
target_platform_with_version=${target_platform_with_version%.*}
start_esphome
done
fi
done done