Skip to content

Commit f8e84d5

Browse files
committed
add ps1 file to process with the column name
update expected_memory.tsv for failing values update the verify_runtime.sh to check with usr/bin/time
1 parent fea468f commit f8e84d5

File tree

4 files changed

+46
-46
lines changed

4 files changed

+46
-46
lines changed

test_scripts/test_data/expected_memory.tsv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ build/iqtree3 -s test_scripts/test_data/turtle.fa -p test_scripts/test_data/turt
1414
build/iqtree3 -s test_scripts/test_data/turtle.fa -p test_scripts/test_data/turtle.nex -g test_scripts/test_data/turtle.constr.tree2 -B 1000 -alrt 1000 --prefix test_scripts/test_data/turtle.nex.constr2 -T 1 -seed 73073 3 18.82 18.70 17.55 13.29 14.00 19.74
1515
build/iqtree3 -s test_scripts/test_data/turtle.fa -m MIX+MF --prefix test_scripts/test_data/turtle.mixfinder -T 1 -seed 73073 3 14.55 15.50 11.68 9.21 9.28 20.19
1616
build/iqtree3 -s test_scripts/test_data/turtle_aa.fasta -B 1000 -T 1 -seed 73073 3 25.57 25.66 24.47 21.26 15.77 22.72
17-
build/iqtree3 -s test_scripts/test_data/turtle_aa.fasta -p test_scripts/test_data/turtle_aa.nex -B 1000 -T 1 -seed 73073 3 76.22 67.05 26.73 23.80 16.39 24.45
18-
build/iqtree3 -s test_scripts/test_data/turtle_aa.fasta -p test_scripts/test_data/turtle_aa.nex -B 1000 -T 1 -m MFP+MERGE -rcluster 10 --prefix test_scripts/test_data/turtle_aa.merge -seed 73073 3 41.34 31.46 26.11 22.30 16.56 25.05
17+
build/iqtree3 -s test_scripts/test_data/turtle_aa.fasta -p test_scripts/test_data/turtle_aa.nex -B 1000 -T 1 -seed 73073 3 76.22 67.05 26.73 23.80 16.39 28.9
18+
build/iqtree3 -s test_scripts/test_data/turtle_aa.fasta -p test_scripts/test_data/turtle_aa.nex -B 1000 -T 1 -m MFP+MERGE -rcluster 10 --prefix test_scripts/test_data/turtle_aa.merge -seed 73073 3 41.34 31.46 26.11 22.30 16.56 28.35
1919
build/iqtree3 -s test_scripts/test_data/turtle_aa.fasta -p test_scripts/test_data/turtle_aa.merge.best_scheme.nex -z test_scripts/test_data/turtle_aa.trees -zb 10000 -au -n 0 --prefix test_scripts/test_data/turtle_aa.test -seed 73073 -T 1 3 33.53 33.46 32.43 31.32 30.30 33.82
2020
build/iqtree3 -s test_scripts/test_data/turtle_aa.fasta -p test_scripts/test_data/turtle_aa.nex.best_scheme.nex -z test_scripts/test_data/turtle_aa.trees -n 0 -wpl --prefix test_scripts/test_data/turtle_aa.wpl -seed 73073 -T 1 3 18.26 18.32 16.95 14.17 12.81 14.99
2121
build/iqtree3 -s test_scripts/test_data/turtle_aa.fasta -S test_scripts/test_data/turtle_aa.nex --prefix test_scripts/test_data/turtle_aa.loci -T 1 -seed 73073 3 16.49 16.11 13.53 11.07 9.69 14.96

test_scripts/verify_memory.ps1

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
param (
2-
[int] $ExpectedColumn = 8
2+
[string] $ExpectedColumnName = "windows-x86"
33
)
44

55
$WD = "test_scripts/test_data"
@@ -9,11 +9,21 @@ $selectedColumnsFile = Join-Path $WD "selected_columns.tsv"
99
$reportedColumnFile = "$env:TEMP\reported_column.tsv"
1010
$finalFile = Join-Path $WD "combined_with_reported.tsv"
1111

12-
# Read expected: Command, Threshold, ExpectedColumn
12+
# Get the header and find the index of the expected column name
13+
$header = Get-Content $expectedFile -TotalCount 1
14+
$columns = $header -split "`t"
15+
$columnIndex = $columns.IndexOf($ExpectedColumnName)
16+
17+
if ($columnIndex -lt 0) {
18+
Write-Error "Column '$ExpectedColumnName' not found in $expectedFile"
19+
exit 1
20+
}
21+
22+
# Adjust to 0-based indexing for arrays
1323
$expectedLines = Get-Content $expectedFile | Select-Object -Skip 1
1424
$selectedColumns = foreach ($line in $expectedLines) {
1525
$parts = $line -split "`t"
16-
"$($parts[0])`t$($parts[1])`t$($parts[$ExpectedColumn - 1])"
26+
"$($parts[0])`t$($parts[1])`t$($parts[$columnIndex])"
1727
}
1828
$selectedColumns | Set-Content $selectedColumnsFile
1929

@@ -59,7 +69,7 @@ foreach ($line in $finalLines) {
5969
Write-Host ""
6070

6171
if ($failCount -eq 0) {
62-
Write-Host "✅ All runtime/memory checks passed."
72+
Write-Host "✅ All memory checks passed."
6373
exit 0
6474
} else {
6575
Write-Host "$failCount checks failed."

test_scripts/verify_memory.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ while IFS=$'\t' read -r command threshold expected reported; do
4343
done < <(tail -n +2 "$final_file")
4444

4545
if [ "$fail_count" -eq 0 ]; then
46-
echo "✅ All runtime checks passed."
46+
echo "✅ All memory checks passed."
4747
else
4848
echo "$fail_count checks failed."
4949
exit 1

test_scripts/verify_runtime.sh

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,46 @@
22
expected_column="$1"
33

44
WD="test_scripts/test_data"
5-
input_file="${WD}/expected_runtimes.tsv"
6-
selected_colums_file="${WD}/selected_columns.tsv"
7-
cut -f1,2,3,"$expected_column" "$input_file" > "${selected_colums_file}"
5+
input_file="${WD}/expected_runtime.tsv"
6+
reported_file="time_log.tsv"
7+
selected_columns_file="${WD}/selected_columns.tsv"
88

9-
fail_count=0
10-
line_num=0
11-
12-
while IFS=$'\t' read -r iqtree_file field_name threshold expected_value || [ -n "$iqtree_file" ]; do
13-
((line_num++))
9+
# Get the column index (1-based) of the expected column name
10+
col_index=$(head -1 "$input_file" | tr '\t' '\n' | awk -v col="$expected_column" '{if ($0 == col) print NR}')
1411

15-
# Skip header (first line)
16-
if [ "$line_num" -eq 1 ]; then
17-
continue
18-
fi
12+
# Check if column was found
13+
if [[ -z "$col_index" ]]; then
14+
echo "Column '$expected_column' not found in $input_file"
15+
exit 1
16+
fi
1917

20-
iqtree_file="${WD}/${iqtree_file}"
18+
cut -f1,2,"$col_index" "$input_file" > "${selected_columns_file}"
19+
final_file="${WD}/combined_with_reported.tsv"
2120

22-
if [ ! -f "$iqtree_file" ]; then
23-
echo "File not found: $iqtree_file"
24-
continue
25-
fi
21+
# assuming the reported file and expected file have the same order of commands
22+
cut -f2 "$reported_file" > /tmp/reported_column.tsv
23+
paste "$selected_columns_file" /tmp/reported_column.tsv > "$final_file"
2624

27-
# Look for the line containing the field name
28-
report_line=$(grep -F "$field_name" "$iqtree_file")
29-
if [ -z "$report_line" ]; then
30-
echo "Field not found in $iqtree_file: $field_name"
31-
continue
32-
fi
3325

34-
# Extract the first numeric value from the matched line
35-
report_value=$(echo "$report_line" | grep -Eo '[-+]?[0-9]+(\.[0-9]+)?([eE][-+]?[0-9]+)?' | head -n1)
36-
if [ -z "$report_value" ]; then
37-
echo "No numeric value found in line: $report_line"
38-
continue
39-
fi
26+
fail_count=0
4027

41-
# Compute report value less than the highest value
42-
higest_value=$(echo "$expected_value + $threshold" | bc -l)
43-
result=$(echo "$report_value <= $higest_value" | bc -l)
28+
# Skip header
29+
while IFS=$'\t' read -r command threshold expected reported; do
30+
allowed=$(echo "$expected + $threshold" | bc -l)
31+
is_exceed=$(echo "$reported > $allowed" | bc -l)
4432

45-
if [ "$result" -eq 1 ]; then
46-
echo "PASS: $iqtree_file -- Expected: ${expected_value}, Reported: ${report_value}, Threshold: $threshold"
47-
else
48-
echo "FAIL: $iqtree_file ($field_name)"
49-
echo " Expected: ${expected_value}, Reported: ${report_value}, Threshold: $threshold"
33+
if [ "$is_exceed" = "1" ]; then
34+
diff=$(echo "$reported - $expected" | bc -l)
35+
echo "$command exceeded the allowed runtime usage."
36+
echo "Expected: $expected S, Threshold: $threshold S, Reported: $reported S, Difference: $diff S"
5037
((fail_count++))
38+
else
39+
echo "$command passed the runtime check."
40+
diff=$(echo "$reported - $expected" | bc -l)
41+
echo "Expected: $expected S, Threshold: $threshold S, Reported: $reported S, Difference: $diff S"
5142
fi
52-
done < "$selected_colums_file"
43+
done < <(tail -n +2 "$final_file")
5344

54-
echo
5545
if [ "$fail_count" -eq 0 ]; then
5646
echo "✅ All runtime checks passed."
5747
else

0 commit comments

Comments
 (0)