Skip to content

Commit 7d854f2

Browse files
committed
fix(shell): Improve shell script exit code handling
1 parent a66628e commit 7d854f2

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

packages/adapter-postgres/src/__tests__/run_tests.sh

100644100755
+9-15
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,23 @@ if [ ! -f "$SCHEMA_PATH" ]; then
5656
exit 1
5757
fi
5858

59-
$DOCKER_COMPOSE_CMD -f docker-compose.test.yml exec -T postgres-test psql -U postgres -d eliza_test -f - < "$SCHEMA_PATH"
60-
if [ $? -ne 0 ]; then
59+
# Fix: Check exit code directly instead of using $?
60+
if ! $DOCKER_COMPOSE_CMD -f docker-compose.test.yml exec -T postgres-test psql -U postgres -d eliza_test -f - < "$SCHEMA_PATH"; then
6161
echo -e "${RED}Failed to load schema${NC}"
6262
exit 1
6363
fi
6464
echo -e "${GREEN}Schema loaded successfully!${NC}"
6565

6666
# Run the tests
6767
echo -e "${YELLOW}Running tests...${NC}"
68-
pnpm vitest vector-extension.test.ts
68+
if ! pnpm vitest vector-extension.test.ts; then
69+
echo -e "${RED}Tests failed!${NC}"
70+
$DOCKER_COMPOSE_CMD -f docker-compose.test.yml down
71+
exit 1
72+
fi
6973

70-
# Capture test exit code
71-
TEST_EXIT_CODE=$?
74+
echo -e "${GREEN}Tests completed successfully!${NC}"
7275

7376
# Clean up
7477
echo -e "${YELLOW}Cleaning up test environment...${NC}"
75-
$DOCKER_COMPOSE_CMD -f docker-compose.test.yml down
76-
77-
# Exit with test exit code
78-
if [ $TEST_EXIT_CODE -eq 0 ]; then
79-
echo -e "${GREEN}Tests completed successfully!${NC}"
80-
else
81-
echo -e "${RED}Tests failed!${NC}"
82-
fi
83-
84-
exit $TEST_EXIT_CODE
78+
$DOCKER_COMPOSE_CMD -f docker-compose.test.yml down

0 commit comments

Comments
 (0)