summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Cunningham <cc@local.lan>2026-03-05 16:13:04 -0800
committerChristian Cunningham <cc@local.lan>2026-03-05 16:13:04 -0800
commitaa6f21f2e79b8d8c0c0ef353f66f5a4ec15989f6 (patch)
tree4b4b2723cabc69c56de779675298217e4a82750e
parent766ef8362886af250faf2deb044b161fb7f39505 (diff)
Automatic test writing
-rwxr-xr-xwrite_tests.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/write_tests.sh b/write_tests.sh
new file mode 100755
index 0000000..18bc777
--- /dev/null
+++ b/write_tests.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+[ ! -f .env ] || export $(grep -v '^#' .env | xargs)
+[ ! -f .teagent ] || export $(grep -v '^#' .teagent | xargs)
+if [ -z "$REPO" ]; then
+ exit 1
+fi
+
+SERVER="${OLLAMA_HOST:-http://localhost:11434}"
+MODEL="${OLLAMA_MODEL:-llama3.2}"
+
+SOURCE_FILES=`find . -type f -iname \*.py`
+
+for source_file in $SOURCE_FILES; do
+ if [ ! -s "${source_file}" ]; then
+ continue
+ fi
+ SOURCE=$(<"${source_file}")
+ PROMPT=$(cat << EOF
+Please write tests for the following source, leaving ample documentation.
+If there don't seem to be any natural tests, simply write: DONE
+EOF
+)
+ PROMPT="${PROMPT}
+${SOURCE}"
+ RESPONSE=$(curl -s "$SERVER/api/generate" \
+ -H "Content-Type: application/json" \
+ -d "$(jq -n --arg model "$MODEL" --arg prompt "$PROMPT" \
+ '{model:$model, prompt:$prompt, stream:false}')" \
+ | jq -r '.response')
+ if [[ "$RESPONSE" = 'DONE'* ]]; then
+ echo > /dev/null
+ else
+ tea issues create --title "Cleanup ${source_file} (TeAgent)" --body "${RESPONSE}" --login teagent --repo "${REPO}"
+ fi
+done