mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
Yoloadd a bash -n to check bash syntax near the very beginning of the test suite to crash early if there are obvious syntax errors
This commit is contained in:
parent
56ec8ec4f0
commit
dc17670f62
1 changed files with 15 additions and 1 deletions
16
lib/tests.sh
16
lib/tests.sh
|
@ -16,7 +16,21 @@ _STUFF_TO_RUN_BEFORE_INITIAL_SNAPSHOT()
|
|||
# Set witness files
|
||||
set_witness_files
|
||||
|
||||
[[ -e $package_path/manifest.toml ]] || return
|
||||
[[ -e $package_path/manifest.toml ]] || log_critical "The app CI / package_check doesn't support testing packaging v1 apps anymore."
|
||||
|
||||
|
||||
log_title "Basic bash syntax checks"
|
||||
|
||||
local syntax_issue=false
|
||||
pushd $package_path/scripts >/dev/null
|
||||
for SCRIPT in $(ls _common.sh install remove upgrade backup restore change_url config 2>/dev/null)
|
||||
do
|
||||
# bash -n / noexec option allows to find syntax issues without actually running the scripts
|
||||
# cf https://unix.stackexchange.com/questions/597743/bash-shell-noexec-option-usage-purpose
|
||||
bash -n $SCRIPT | tee -a /proc/self/fd/3 || syntax_issue=true
|
||||
done
|
||||
popd >/dev/null
|
||||
[[ $syntax_issue == true ]] && log_report_test_success || log_critical "Obvious syntax issues found which will make the scripts crash ... not running the actual tests until these are fixed"
|
||||
|
||||
# We filter apt deps starting with $app_id to prevent stupid issues with for example cockpit and transmission where the apt package is not properly reinstalled on reinstall-after-remove test ...
|
||||
local apt_deps=$(python3 -c "import toml, sys; t = toml.loads(sys.stdin.read()); P = t['resources'].get('apt', {}).get('packages', ''); P = P.replace(',', ' ').split() if isinstance(P, str) else P; P = [p for p in P if p != '$app_id' and not p.startswith('$app_id-')]; print(' '.join(P));" < $package_path/manifest.toml)
|
||||
|
|
Loading…
Add table
Reference in a new issue