Initial commit
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
|
||||
import asyncio
|
||||
import sys
|
||||
import glob
|
||||
from pathlib import Path
|
||||
from loguru import logger
|
||||
|
||||
# Add project root to path
|
||||
sys.path.insert(0, str(Path(__file__).parent))
|
||||
|
||||
# Import the logic from the previous test script to reuse it
|
||||
# (Assuming it's safe to import, or I'll copy the core logic if cleaner)
|
||||
from test_full_flow_random_sample import run_random_sample_test
|
||||
|
||||
async def run_batch_test():
|
||||
print("🚀 Starting Batch Test on all EPUBs")
|
||||
print("=" * 60)
|
||||
|
||||
# Find all EPUBs
|
||||
epub_files = []
|
||||
# Search in current directory
|
||||
epub_files.extend(glob.glob("*.epub"))
|
||||
# Search in 'input' directory if it exists
|
||||
if Path("input").exists():
|
||||
epub_files.extend(glob.glob("input/*.epub"))
|
||||
# Search in subfolders (e.g. "未命名文件夹")
|
||||
epub_files.extend(glob.glob("**/*.epub", recursive=True))
|
||||
|
||||
# Deduplicate and filter out output files
|
||||
unique_epubs = set()
|
||||
for f in epub_files:
|
||||
path = Path(f)
|
||||
if "output" in path.parts or "_bilingual" in path.name or "test_output" in path.parts:
|
||||
continue
|
||||
unique_epubs.add(str(path))
|
||||
|
||||
sorted_epubs = sorted(list(unique_epubs))
|
||||
|
||||
if not sorted_epubs:
|
||||
print("❌ No EPUB files found.")
|
||||
return
|
||||
|
||||
print(f"📚 Found {len(sorted_epubs)} unique EPUBs to test:")
|
||||
for f in sorted_epubs:
|
||||
print(f" - {f}")
|
||||
print("-" * 60)
|
||||
|
||||
results = {}
|
||||
|
||||
for i, epub_file in enumerate(sorted_epubs, 1):
|
||||
print(f"\n[{i}/{len(sorted_epubs)}] Testing: {epub_file}")
|
||||
try:
|
||||
await run_random_sample_test(epub_file)
|
||||
results[epub_file] = "✅ Success"
|
||||
except Exception as e:
|
||||
print(f"❌ Failed: {e}")
|
||||
logger.error(f"Test failed for {epub_file}", exc_info=True)
|
||||
results[epub_file] = f"❌ Failed: {e}"
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print("📊 Batch Test Summary")
|
||||
print("=" * 60)
|
||||
for f, status in results.items():
|
||||
print(f"{status} - {f}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(run_batch_test())
|
||||
Reference in New Issue
Block a user