跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

load.bash

90 行 · 2.8 KB历史下载
1# SPDX-FileCopyrightText: Copyright The Lima Authors
2# SPDX-License-Identifier: Apache-2.0
3
4set -o errexit -o nounset -o pipefail
5
6# Make sure run() will execute all functions with errexit enabled.
7# This enables the functionality from https://github.com/lima-vm/bats-core/commit/507da84de75fa78798d53eceb42e68851ef5c48b
8# The upstream PR https://github.com/bats-core/bats-core/pull/1118 is still open, so our submodule points to the PR commit.
9export BATS_RUN_ERREXIT=1
10
11# BATS_TEST_RETRIES must be set for the individual test and cannot be imported from the
12# parent environment because the BATS test runner sets it to 0 before running the test.
13BATS_TEST_RETRIES=${LIMA_BATS_ALL_TESTS_RETRIES:-0}
14
15# Known flaky tests should call `flaky` inside the @test to allow retries up to
16# LIMA_BATS_FLAKY_TESTS_RETRIES even when the LIMA_BATS_ALL_TESTS_RETRIES is lower.
17flaky() {
18 BATS_TEST_RETRIES=${LIMA_BATS_FLAKY_TESTS_RETRIES:-$BATS_TEST_RETRIES}
19}
20
21# Don't run the tests in ~/.lima because they may destroy _config, _templates etc.
22export LIMA_HOME=${LIMA_BATS_LIMA_HOME:-$HOME/.lima-bats}
23
24absolute_path() {
25 (
26 cd "$1"
27 pwd
28 )
29}
30
31PATH_BATS_HELPERS=$(absolute_path "$(dirname "${BASH_SOURCE[0]}")")
32PATH_BATS_ROOT=$(absolute_path "$PATH_BATS_HELPERS/..")
33
34source "$PATH_BATS_ROOT/lib/bats-support/load.bash"
35source "$PATH_BATS_ROOT/lib/bats-assert/load.bash"
36source "$PATH_BATS_ROOT/lib/bats-file/load.bash"
37
38source "$PATH_BATS_HELPERS/limactl.bash"
39source "$PATH_BATS_HELPERS/logs.bash"
40
41bats_require_minimum_version 1.5.0
42
43run_e() {
44 run --separate-stderr "$@"
45}
46
47# If called from foo() this function will call local_foo() if it exist.
48call_local_function() {
49 local func
50 func="local_${FUNCNAME[1]}"
51 if [ "$(type -t "$func")" = "function" ]; then
52 "$func"
53 fi
54}
55
56setup_file() {
57 if [[ ${CI:-} == true ]]; then
58 # Without a terminal the output is using TAP formatting, which does not include the filename
59 local TEST_FILENAME=${BATS_TEST_FILENAME#"$PATH_BATS_ROOT/tests/"}
60 TEST_FILENAME=${TEST_FILENAME%.bats}
61 echo "# ===== ${TEST_FILENAME} =====" >&3
62 fi
63 if [[ -n "${INSTANCE:-}" ]]; then
64 ensure_instance "$INSTANCE"
65 fi
66 call_local_function
67}
68teardown_file() {
69 call_local_function
70 if [[ -n "${INSTANCE:-}" ]]; then
71 delete_instance "$INSTANCE"
72 fi
73}
74setup() {
75 call_local_function
76}
77teardown() {
78 call_local_function
79}
80
81assert_output_lines_count() {
82 assert_equal "${#lines[@]}" "$1"
83}
84
85# Use GHCR and ECR to avoid hitting Docker Hub rate limit.
86# NOTE: keep this list in sync with hack/test-templates.sh .
87declare -A -g TEST_CONTAINER_IMAGES=(
88 ["nginx"]="ghcr.io/stargz-containers/nginx:1.19-alpine-org"
89 ["coredns"]="public.ecr.aws/eks-distro/coredns/coredns:v1.12.2-eks-1-31-latest"
90)