Debian Codegraph @

util/copy_e2e_test_results.sh

raw
1 #!/bin/bash
2
3 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
4
5 # Define the paths for both directory trees
6 tests_output_root_dir="/tmp/nerdlog_e2e_test_output"
7 tests_input_root_dir="${SCRIPT_DIR}/../cmd/nerdlog/e2e_testdata/test_scenarios"
8
9 # Convert tests_output_root_dir to absolute path for consistency
10 tests_output_root_dir=$(realpath "$tests_output_root_dir")
11
12 # Recurse into subdirectories
13 for scenario_output_dir in "$tests_output_root_dir"/*; do
14 scenario_name="${scenario_output_dir#$tests_output_root_dir/}"
15 scenario_input_dir="$tests_input_root_dir/$scenario_name"
16
17 for step_output_dir in "$scenario_output_dir"/steps/*; do
18 if [ -e "$step_output_dir/got_snapshot.txt" ]; then
19 # This is a query step, so copy the query output
20 want_filename_ptr="$step_output_dir/want_snapshot_filename.txt"
21 if ! [ -e "$want_filename_ptr" ]; then
22 exit 1
23 fi
24 want_filename="$(cat $want_filename_ptr)"
25
26 target_want_filename="$scenario_input_dir/$want_filename"
27 if ! [ -e "$target_want_filename" ]; then
28 echo "warn: $target_want_filename does not exist, skipping" 1>&2
29 continue
30 fi
31
32 #echo "Copying $step_output_dir/got_snapshot.txt -> $target_want_filename"
33 echo -n .
34 cp "$step_output_dir/got_snapshot.txt" "$target_want_filename"
35 fi
36 done
37 done
38
39 echo ""
40 echo "All done"