fix: support piped installer execution

This commit is contained in:
Qiufeng
2026-08-04 00:33:16 +08:00
parent a604460542
commit 882d8f559c
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -520,6 +520,6 @@ main() {
say "Local URL: http://127.0.0.1:${ERP_SERVER_PORT:-8091}" say "Local URL: http://127.0.0.1:${ERP_SERVER_PORT:-8091}"
} }
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then if [[ "${BASH_SOURCE[0]:-$0}" == "$0" ]]; then
main "$@" main "$@"
fi fi
+9
View File
@@ -498,6 +498,14 @@ test_release_workflow_uses_scoped_job_token() (
! grep -Fq 'vars.GITEA_BASE_URL' "$workflow" ! grep -Fq 'vars.GITEA_BASE_URL' "$workflow"
) )
test_installer_runs_when_piped_to_bash() (
local output status=0
output="$(ERP_GITEA_BASE_URL= bash -s -- --no-service < "$PROJECT_ROOT/install.sh" 2>&1)" || status=$?
[[ "$status" -ne 0 ]]
[[ "$output" == *'[ERP Install] ERROR:'* ]]
[[ "$output" != *'BASH_SOURCE'* ]]
)
run_test 'erp-run preserves Java option arguments' test_erp_run_preserves_java_option_arguments run_test 'erp-run preserves Java option arguments' test_erp_run_preserves_java_option_arguments
run_test 'installer accepts a correctly signed archive' test_installer_verifies_signed_safe_archive run_test 'installer accepts a correctly signed archive' test_installer_verifies_signed_safe_archive
run_test 'installer rejects symlinks in release archives' test_installer_rejects_archive_symlinks run_test 'installer rejects symlinks in release archives' test_installer_rejects_archive_symlinks
@@ -510,6 +518,7 @@ run_test 'noninteractive install reports a missing database password' test_nonin
run_test 'installer requires an explicit Gitea URL' test_installer_requires_explicit_gitea_url run_test 'installer requires an explicit Gitea URL' test_installer_requires_explicit_gitea_url
run_test 'no-service install disables online update' test_no_service_install_disables_online_update run_test 'no-service install disables online update' test_no_service_install_disables_online_update
run_test 'release workflow uses the scoped Gitea job token' test_release_workflow_uses_scoped_job_token run_test 'release workflow uses the scoped Gitea job token' test_release_workflow_uses_scoped_job_token
run_test 'installer starts correctly when piped to bash' test_installer_runs_when_piped_to_bash
printf 'RESULT pass=%s fail=%s\n' "$PASS" "$FAIL" printf 'RESULT pass=%s fail=%s\n' "$PASS" "$FAIL"
[[ "$FAIL" -eq 0 ]] [[ "$FAIL" -eq 0 ]]