Setting the file. One moment.
Smoke · Remotion To Hyperframes · heygen-com/hyperframes · Skills Docs
ContentsBack to the top of the page (opens in a new tab)
scripts/tests/ smoke.sh
Shell · 90 lines · 4 KB
"$(
dirname
"${
BASH_SOURCE
[0]}")" &&
pwd
)"
15 SCRIPTS_DIR = "$( cd " $THIS_DIR /.." && pwd )"
16 WORK = "$( mktemp -d )"
17 trap 'rm -rf "$WORK"' EXIT
18
19 echo "==> smoke: render_diff.sh against identical inputs"
20 # Generate the same test pattern twice. Identical inputs → SSIM should be ~1.0.
21 ffmpeg -y -hide_banner -loglevel error \
22 -f lavfi -i "testsrc=duration=2:size=320x240:rate=30" \
23 -pix_fmt yuv420p " $WORK /baseline.mp4"
24 cp " $WORK /baseline.mp4" " $WORK /translated.mp4"
25
26 R2HF_SSIM_THRESHOLD = 0.99 " $SCRIPTS_DIR /render_diff.sh" \
27 " $WORK /baseline.mp4" " $WORK /translated.mp4" " $WORK /diff" > /dev/null
28
29 MEAN = $( python3 -c "import json,sys; print(json.load(open(' $WORK /diff/summary.json'))['mean'])" )
30 PASS = $( python3 -c "import json,sys; print(json.load(open(' $WORK /diff/summary.json'))['pass'])" )
31 if [[ " $PASS " != "True" ]]; then
32 echo "FAIL: identical inputs failed pass check (mean= $MEAN )"
33 exit 1
34 fi
35 echo " identical inputs → mean SSIM= $MEAN (pass=True)"
36
37 echo "==> smoke: render_diff.sh against different inputs"
38 # Different test pattern → SSIM should be lower. With a high threshold it should fail.
39 ffmpeg -y -hide_banner -loglevel error \
40 -f lavfi -i "testsrc2=duration=2:size=320x240:rate=30" \
41 -pix_fmt yuv420p " $WORK /different.mp4"
42
43 set +e
44 R2HF_SSIM_THRESHOLD = 0.99 " $SCRIPTS_DIR /render_diff.sh" \
45 " $WORK /baseline.mp4" " $WORK /different.mp4" " $WORK /diff2" > /dev/null
46 RC = $?
47 set -e
48 if [[ " $RC " -eq 0 ]]; then
49 echo "FAIL: different inputs unexpectedly passed at threshold 0.99"
50 exit 1
51 fi
52 DIFF_MEAN = $( python3 -c "import json; print(json.load(open(' $WORK /diff2/summary.json'))['mean'])" )
53 echo " different inputs → mean SSIM= $DIFF_MEAN (correctly failed at 0.99)"
54
55 echo "==> smoke: frame_strip.sh produces a strip"
56 " $SCRIPTS_DIR /frame_strip.sh" " $WORK /baseline.mp4" " $WORK /different.mp4" " $WORK /strip" 4 > /dev/null
57 if [[ ! -f " $WORK /strip/strip.png" ]]; then
58 echo "FAIL: frame_strip.sh did not produce strip.png"
59 exit 1
60 fi
61 echo " strip.png written ($( stat -c%s " $WORK /strip/strip.png" 2> /dev/null || stat -f%z " $WORK /strip/strip.png") bytes)"
62
63 echo "==> smoke: lint_source.py on clean fixture (expect exit 0)"
64 set +e
65 python3 " $SCRIPTS_DIR /lint_source.py" " $THIS_DIR /fixtures/clean.tsx" --json > " $WORK /clean.json"
66 RC = $?
67 set -e
68 BLOCKERS = $( python3 -c "import json; print(json.load(open(' $WORK /clean.json'))['blockers'])" )
69 if [[ " $RC " -ne 0 || " $BLOCKERS " -ne 0 ]]; then
70 echo "FAIL: clean fixture reported $BLOCKERS blockers (rc= $RC )"
71 exit 1
72 fi
73 INFOS = $( python3 -c "import json; print(json.load(open(' $WORK /clean.json'))['infos'])" )
74 echo " clean.tsx → 0 blockers, $INFOS info findings"
75
76 echo "==> smoke: lint_source.py on blocker fixture (expect exit 1)"
77 set +e
78 python3 " $SCRIPTS_DIR /lint_source.py" " $THIS_DIR /fixtures/blocker.tsx" --json > " $WORK /blocker.json"
79 RC = $?
80 set -e
81 BLOCKERS = $( python3 -c "import json; print(json.load(open(' $WORK /blocker.json'))['blockers'])" )
82 if [[ " $RC " -eq 0 || " $BLOCKERS " -lt 3 ]]; then
83 echo "FAIL: blocker fixture reported $BLOCKERS blockers, expected >=3 (rc= $RC )"
84 cat " $WORK /blocker.json"
85 exit 1
86 fi
87 echo " blocker.tsx → $BLOCKERS blockers detected (correctly refused)"
88
89 echo
90 echo "✅ smoke tests passed"