#!/bin/bash

# Run FASB DQCRT taxonomy tests 
#
# Tests DQCRT/2024 against XBRL-US filings
#
# Assumes 8 core cpu to run in 5 hrs
#
# Results have been verified by XBRL-US against their databasee of results
#
# Requires arelle disclosure system efm-preview-dqcrt-testing
#
# Result report files merged by script mergeEFMDQC2020TestsOut.sh

ARELLECMDLINESRC=<Arelle-dir>/arelleCmdLine.py
PYTHON=python3.11
PLUGINS='EDGAR/validate'
EFM_VAL=efm-pragmatic-nonblocking

# run Python implemented XULE rules only (not XULE implemented rules)
dqcRuleFilter='dqcRuleFilter=XULE:9999|.*'

rm -f out/DQCRT-2024-less-*

for f in $(seq 1 `ls DQCRT-2024-test-less-*.xml|wc -l`)
do
	TESTCASESROOT=DQCRT-2024-test-less-${f}.xml
	f2dig=$(printf "%02d" ${f})
	OUTPUTLOGFILE=out/DQCRT-2024-less-log-${f2dig}.log
	OUTPUTERRFILE=out/DQCRT-2024-less-err-${f2dig}.txt
	OUTPUTCSVFILE=out/DQCRT-2024-less-report-${f2dig}.csv
	TESTCASESINDEXFILE=$TESTCASESROOT

	$PYTHON $ARELLECMDLINESRC --file "$TESTCASESINDEXFILE" --noCertificateCheck --plugins $PLUGINS --disclosureSystem $EFM_VAL --validate --testcaseResultOptions match-any --csvTestReport "$OUTPUTCSVFILE" --testcaseResultsCaptureWarnings --logFile "$OUTPUTLOGFILE" --parameters $dqcRuleFilter &>  "$OUTPUTERRFILE" &
	echo "$! " >> out/DQCRT-2024-less-PIDs
done
