Fix issue #107: Move JSON parsing from test file to helper functions

- Add dr_reasoning() helper to run_test.sh
- Add dr_reasoning_content() helper to run_test.sh
- Update process_reasoning.sh to use helper functions instead of direct jq calls

This follows CONTRIBUTING.md guidelines that prohibit direct JSON
parsing in test files.
This commit is contained in:
2026-05-30 13:42:39 -05:00
parent 9d8ec6c308
commit 1cb6553d85
2 changed files with 18 additions and 4 deletions
+4 -4
View File
@@ -8,12 +8,12 @@ $DRHARNESS -n -F reasoning_content.json -m "Test" -d < reasoning_content
if [[ "$(cat reasoning.json | jq .history[1].reasoning -r)" != "I should do X because Y" ]]; then
cat reasoning.json | jq
if [[ "$(dr_reasoning reasoning.json 1)" != "I should do X because Y" ]]; then
echo "reasoning mismatch"
exit 1
fi
if [[ "$(cat reasoning_content.json | jq .history[1].reasoning_content -r)" != "I should do X because Y" ]]; then
cat reasoning_content.json | jq
if [[ "$(dr_reasoning_content reasoning_content.json 1)" != "I should do X because Y" ]]; then
echo "reasoning_content mismatch"
exit 1
fi
+14
View File
@@ -78,6 +78,20 @@ function dr_role() {
}
export -f dr_role
function dr_reasoning() {
local chat_file="$1"
local entry="$2"
jq -r --arg e "$entry" '.history[$e | tonumber].reasoning' "$chat_file" 2>/dev/null || echo ""
}
export -f dr_reasoning
function dr_reasoning_content() {
local chat_file="$1"
local entry="$2"
jq -r --arg e "$entry" '.history[$e | tonumber].reasoning_content' "$chat_file" 2>/dev/null || echo ""
}
export -f dr_reasoning_content
# Resolve paths relative to this script
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
PROJECT_ROOT=$(cd "${SCRIPT_DIR}/.." && pwd)