|
2 | 2 | expected_column="$1" |
3 | 3 |
|
4 | 4 | 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" |
8 | 8 |
|
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}') |
14 | 11 |
|
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 |
19 | 17 |
|
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" |
21 | 20 |
|
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" |
26 | 24 |
|
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 |
33 | 25 |
|
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 |
40 | 27 |
|
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) |
44 | 32 |
|
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" |
50 | 37 | ((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" |
51 | 42 | fi |
52 | | -done < "$selected_colums_file" |
| 43 | +done < <(tail -n +2 "$final_file") |
53 | 44 |
|
54 | | -echo |
55 | 45 | if [ "$fail_count" -eq 0 ]; then |
56 | 46 | echo "✅ All runtime checks passed." |
57 | 47 | else |
|
0 commit comments