summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/codex-plugin-sync/test-sync-to-codex-plugin.sh28
-rwxr-xr-xtests/codex/test-package-codex-plugin.sh22
2 files changed, 50 insertions, 0 deletions
diff --git a/tests/codex-plugin-sync/test-sync-to-codex-plugin.sh b/tests/codex-plugin-sync/test-sync-to-codex-plugin.sh
index 84282c2..fb3aaa7 100755
--- a/tests/codex-plugin-sync/test-sync-to-codex-plugin.sh
+++ b/tests/codex-plugin-sync/test-sync-to-codex-plugin.sh
@@ -571,6 +571,12 @@ main() {
local bootstrap_output
local missing_manifest_status
local missing_manifest_output
+ local linked_upstream_main
+ local linked_upstream
+ local linked_dest_main
+ local linked_dest
+ local linked_preview_status
+ local linked_preview_output
local mixed_only_status
local mixed_only_output
local stale_preview_status
@@ -603,6 +609,10 @@ main() {
dest_branch="fixture/preview-target"
bootstrap_dest_branch="fixture/bootstrap-preview-target"
fake_bin="$TEST_ROOT/bin"
+ linked_upstream_main="$TEST_ROOT/linked-upstream-main"
+ linked_upstream="$TEST_ROOT/linked-upstream"
+ linked_dest_main="$TEST_ROOT/linked-destination-main"
+ linked_dest="$TEST_ROOT/linked-destination"
init_repo "$upstream"
write_upstream_fixture "$upstream"
@@ -635,6 +645,17 @@ main() {
write_bootstrap_destination_fixture "$bootstrap_dest"
checkout_fixture_branch "$bootstrap_dest" "$bootstrap_dest_branch"
+ # The sync script wants upstream on main, so park the primary checkout
+ # on another branch and check main out in the linked worktree.
+ init_repo "$linked_upstream_main"
+ write_upstream_fixture "$linked_upstream_main"
+ git -C "$linked_upstream_main" switch -q -c fixture/parked
+ git -C "$linked_upstream_main" worktree add -q "$linked_upstream" main
+
+ init_repo "$linked_dest_main"
+ write_destination_fixture "$linked_dest_main"
+ git -C "$linked_dest_main" worktree add -q -b fixture/linked-target "$linked_dest"
+
write_fake_gh "$fake_bin"
# This regression test is about dry-run content, so capture the preview
@@ -654,6 +675,8 @@ main() {
noop_apply_status=$?
missing_manifest_output="$(run_preview_without_manifest "$upstream" "$dest" "$fake_bin")"
missing_manifest_status=$?
+ linked_preview_output="$(run_preview "$linked_upstream" "$linked_dest" "$fake_bin")"
+ linked_preview_status=$?
set -e
help_output="$(run_help "$upstream" "$fake_bin")"
script_source="$(cat "$upstream/scripts/sync-to-codex-plugin.sh")"
@@ -731,6 +754,11 @@ Locally modified fixture content." "Dirty local apply preserves tracked working-
short_description: \"Destination-owned OpenAI metadata\"" "Clean no-op local apply preserves OpenAI agent metadata"
echo ""
+ echo "Linked worktree assertions..."
+ assert_equals "$linked_preview_status" "0" "Preview from a linked worktree into a linked worktree exits successfully"
+ assert_not_contains "$linked_preview_output" "is not a git checkout" "Linked worktrees are accepted as git checkouts"
+
+ echo ""
echo "Missing manifest assertions..."
assert_equals "$missing_manifest_status" "1" "Missing manifest exits with failure"
assert_contains "$missing_manifest_output" "ERROR: committed Codex manifest missing at" "Missing manifest reports committed manifest path"
diff --git a/tests/codex/test-package-codex-plugin.sh b/tests/codex/test-package-codex-plugin.sh
index 947cb6d..05e150a 100755
--- a/tests/codex/test-package-codex-plugin.sh
+++ b/tests/codex/test-package-codex-plugin.sh
@@ -9,6 +9,7 @@ FAILURES=0
TEST_ROOT="$(mktemp -d)"
cleanup() {
+ git -C "$REPO_ROOT" worktree remove --force "$TEST_ROOT/linked-worktree" >/dev/null 2>&1 || true
rm -rf "$TEST_ROOT"
}
trap cleanup EXIT
@@ -138,6 +139,8 @@ archive="$TEST_ROOT/superpowers"
tar_archive="$TEST_ROOT/superpowers.tar.gz"
extracted="$TEST_ROOT/extracted"
tar_extracted="$TEST_ROOT/tar-extracted"
+worktree_archive="$TEST_ROOT/superpowers-from-worktree.zip"
+linked_worktree="$TEST_ROOT/linked-worktree"
write_metadata_fixture "$metadata_source"
source_hooks="$(python3 -c 'import json; print(json.load(open("'"$REPO_ROOT"'/.codex-plugin/plugin.json")).get("hooks"))')"
@@ -160,6 +163,25 @@ assert_contains "$output" "Archive:" "reports archive path"
assert_contains "$output" "Format: zip" "reports default zip format"
assert_contains "$output" "SHA-256:" "reports archive checksum"
+if git -C "$REPO_ROOT" worktree add -q --detach "$linked_worktree" HEAD >/dev/null 2>&1; then
+ # The worktree is checked out at HEAD, so copy in the script under test
+ # (it may have uncommitted edits); that dirties the tree, hence --allow-dirty.
+ cp "$SCRIPT_UNDER_TEST" "$linked_worktree/scripts/package-codex-plugin.sh"
+ if output="$("$linked_worktree/scripts/package-codex-plugin.sh" --allow-dirty --metadata-source "$metadata_source" --output "$worktree_archive" 2>&1)"; then
+ pass "package script accepts a linked worktree checkout"
+ else
+ fail "package script accepts a linked worktree checkout"
+ printf '%s\n' "$output" | sed 's/^/ /'
+ fi
+ if [[ -f "$worktree_archive" ]]; then
+ pass "package script writes archive from a linked worktree"
+ else
+ fail "package script writes archive from a linked worktree"
+ fi
+else
+ fail "create linked worktree fixture"
+fi
+
extract_archive "$archive" "$extracted"
archive_paths="$(list_archive "$archive" | normalize_archive_paths)"