-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_package.sh
More file actions
121 lines (107 loc) · 3.62 KB
/
Copy pathtest_package.sh
File metadata and controls
121 lines (107 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
# Test script for kindle-pdf-annotator from TestPyPI
# Usage: ./test_package.sh [version]
set -e # Exit on error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Get version
VERSION="$1"
if [ "$VERSION" == "" ]; then
VERSION=$(grep -oP '__version__ = "\K[^"]+' src/kindle_pdf_annotator/__init__.py)
fi
echo -e "${GREEN}=== Testing kindle-pdf-annotator v${VERSION} from TestPyPI ===${NC}"
echo ""
# Create test directory
TEST_DIR="/tmp/kindle-pdf-annotator-test-$$"
echo -e "${GREEN}Step 1: Creating test environment...${NC}"
mkdir -p "$TEST_DIR"
cd "$TEST_DIR"
echo " ✓ Created test directory: $TEST_DIR"
# Create virtual environment
echo -e "${GREEN}Step 2: Creating virtual environment...${NC}"
python3 -m venv test_env
source test_env/bin/activate
echo " ✓ Virtual environment created and activated"
# Install from TestPyPI
echo -e "${GREEN}Step 3: Installing package from TestPyPI...${NC}"
echo " (This may take a moment...)"
pip install --index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
kindle-pdf-annotator==$VERSION || {
echo -e "${RED}Installation failed!${NC}"
deactivate
rm -rf "$TEST_DIR"
exit 1
}
echo " ✓ Package installed successfully"
# Test imports
echo -e "${GREEN}Step 4: Testing imports...${NC}"
python -c "import kindle_pdf_annotator" && echo " ✓ Can import kindle_pdf_annotator" || {
echo -e "${RED} ✗ Cannot import kindle_pdf_annotator${NC}"
deactivate
rm -rf "$TEST_DIR"
exit 1
}
# Check version
echo -e "${GREEN}Step 5: Verifying version...${NC}"
INSTALLED_VERSION=$(python -c "from kindle_pdf_annotator import __version__; print(__version__)")
if [ "$INSTALLED_VERSION" == "$VERSION" ]; then
echo " ✓ Version matches: $INSTALLED_VERSION"
else
echo -e "${RED} ✗ Version mismatch! Expected: $VERSION, Got: $INSTALLED_VERSION${NC}"
deactivate
rm -rf "$TEST_DIR"
exit 1
fi
# Test CLI command
echo -e "${GREEN}Step 6: Testing CLI command...${NC}"
if command -v kindle-pdf-annotator &> /dev/null; then
kindle-pdf-annotator --help > /dev/null && echo " ✓ CLI command works" || {
echo -e "${RED} ✗ CLI command failed${NC}"
deactivate
rm -rf "$TEST_DIR"
exit 1
}
else
echo -e "${RED} ✗ CLI command not found${NC}"
deactivate
rm -rf "$TEST_DIR"
exit 1
fi
# Test GUI command
echo -e "${GREEN}Step 7: Testing GUI command...${NC}"
if command -v kindle-pdf-annotator-gui &> /dev/null; then
echo " ✓ GUI command found"
echo " ℹ Skipping GUI execution (requires display)"
else
echo -e "${RED} ✗ GUI command not found${NC}"
deactivate
rm -rf "$TEST_DIR"
exit 1
fi
# Test basic functionality
echo -e "${GREEN}Step 8: Testing basic functionality...${NC}"
python << 'PYTHON_TEST'
from kindle_pdf_annotator.kindle_parser import pds_parser, clippings_parser
from kindle_pdf_annotator.pdf_processor import pdf_annotator
from kindle_pdf_annotator.utils import file_utils
print(" ✓ All core modules import successfully")
PYTHON_TEST
# Cleanup
echo -e "${GREEN}Step 9: Cleaning up...${NC}"
deactivate
cd /
rm -rf "$TEST_DIR"
echo " ✓ Test environment removed"
echo ""
echo -e "${GREEN}=== All Tests Passed! ===${NC}"
echo -e "Package ${GREEN}kindle-pdf-annotator v${VERSION}${NC} is working correctly on TestPyPI"
echo ""
echo -e "${YELLOW}Next steps:${NC}"
echo " 1. Check TestPyPI page: https://test.pypi.org/project/kindle-pdf-annotator/${VERSION}/"
echo " 2. Verify screenshots display correctly"
echo " 3. If everything looks good, release to PyPI with: ./release.sh patch pypi"
echo ""