| #!/bin/bash | |
| # Copyright 2026 The Fuchsia Authors. All rights reserved. | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/../../lib/vars.sh || exit $? | |
| BT_FILE_DEPS=( | |
| "prebuilt/third_party/jq/${HOST_PLATFORM}/bin/jq" | |
| "tools/devshell/jq.fx" | |
| "tools/devshell/lib/fx-cmd-locator.sh" | |
| "tools/devshell/lib/fx-optional-features.sh" | |
| "tools/devshell/lib/generate-ssh-config.sh" | |
| "tools/devshell/lib/vars.sh" | |
| "tools/devshell/lib/is_invoked_by_agent.sh" | |
| "tools/devshell/lib/agents.txt" | |
| "tools/devshell/lib/platform.sh" | |
| ) | |
| BT_SET_UP() { | |
| source "${BT_TEMP_DIR}/tools/devshell/tests/lib/fuchsia-mock.sh" | |
| local _BUILD_DIR="out/default" | |
| echo "${_BUILD_DIR}" > "${BT_TEMP_DIR}/.fx-build-dir" | |
| _create_build_dir "$_BUILD_DIR" | |
| } | |
| _create_build_dir() { | |
| local build_dir="$1" | |
| mkdir -p "${BT_TEMP_DIR}/${build_dir}" | |
| } | |
| TEST_fx-regenerator_update_args_skips_wait_ignoring_signals() { | |
| mkdir -p "${FUCHSIA_DIR}/build" | |
| local -r stdin_record="${BT_TEMP_DIR}/regenerator_stdin" | |
| cat > "${FUCHSIA_DIR}/build/regenerator" <<EOF | |
| #!/bin/bash | |
| cat > "${stdin_record}" | |
| EOF | |
| chmod +x "${FUCHSIA_DIR}/build/regenerator" | |
| local wait_called=false | |
| eval "_orig_$(declare -f fx-wait-ignoring-signals)" | |
| fx-wait-ignoring-signals() { | |
| wait_called=true | |
| _orig_fx-wait-ignoring-signals "$@" | |
| } | |
| # With --update-args, fx-wait-ignoring-signals should not be called and stdin | |
| # should be preserved rather than redirected from /dev/null. | |
| fx-regenerator --update-args <<< "interactive_input" | |
| BT_EXPECT_EQ "${wait_called}" "false" | |
| BT_EXPECT_FILE_CONTAINS "${stdin_record}" "interactive_input" | |
| # Without --update-args, fx-wait-ignoring-signals should be used. | |
| wait_called=false | |
| fx-regenerator | |
| BT_EXPECT_EQ "${wait_called}" "true" | |
| eval "$(declare -f _orig_fx-wait-ignoring-signals | sed '1s/^_orig_//')" | |
| unset -f _orig_fx-wait-ignoring-signals | |
| } | |
| BT_RUN_TESTS "$@" |