1# The browser's code path, headless: demo/serve.ts serves code.db in byte2# ranges (206) and sqlite-wasm's .wasm as application/wasm, and the range3# VFS in site/assets/codesearch.ts finds a line through it.4. "$(dirname "$0")/../lib.sh"5user dami6repo dami/greet7clone dami dami/greet "$T/w/dami"8i=19while [ $i -le 30 ]; do printf 'filler line %s\n' "$i"; i=$((i + 1)); done >"$T/w/dami/greet.sh"10printf 'echo "Hello, $1"\n' >>"$T/w/dami/greet.sh"11at "$T/w/dami" commit "first"12push_as dami "$T/w/dami" origin main13build14ok node --no-warnings "$T_HOME/test/code-search-bench.ts" http "$FORGE_ROOT/.forge" dami/greet 'hello, $1'15has "$T_LOG" '^greet\.sh:31: echo "Hello, \$1"$'16has "$T_LOG" '^requests [1-9][0-9]* rounds [1-9][0-9]* bytes [1-9][0-9]*$'17has "$T_LOG" '^range 206 bytes 0-99/[0-9]+ type application/vnd\.sqlite3 encoding none length 100$'18has "$T_LOG" '^wasm 200 type application/wasm cache public, max-age=31536000, immutable$'19# Several words: a first look (12 chunks) that finds chunks with both but no20# line with both reads on, once, and finds the line further down.21mkdir "$T/w/dami/many"22i=1023while [ $i -le 40 ]; do printf 'alpha %s\nbeta %s\n' "$i" "$i" >"$T/w/dami/many/a$i.txt"; i=$((i + 1)); done24printf 'beta and alpha\n' >"$T/w/dami/many/zz.txt"25at "$T/w/dami" commit "many"26push_as dami "$T/w/dami" origin main27build28ok node --no-warnings "$T_HOME/test/code-search-bench.ts" http "$FORGE_ROOT/.forge" dami/greet 'ALPHA beta' 1229eq "$(sed -n 1p "$T_LOG")" 'many/zz.txt:1: beta and alpha'30has "$T_LOG" '^requests [1-9][0-9]* rounds [1-9][0-9]* bytes'31# Too short for trigrams: nothing, and nothing fetched; nor for short words only.32ok node --no-warnings "$T_HOME/test/code-search-bench.ts" http "$FORGE_ROOT/.forge" dami/greet 'if he'33has "$T_LOG" '^requests 0 '34ok node --no-warnings "$T_HOME/test/code-search-bench.ts" http "$FORGE_ROOT/.forge" dami/greet 'he'35has "$T_LOG" '^requests 0 '