| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | set -euo pipefail |
| 4 | |
| 5 | artifact_dir="${1:-bazel-testlogs-artifact}" |
| 6 | |
| 7 | testlogs_dir="$(bazel info bazel-testlogs 2>/dev/nullscip-shell filesystem . . `/dev/null`. || truescip-shell system . . true.)" |
| 8 | if [scip-shell system . . `[`. -z "${testlogs_dir}" ] || [scip-shell system . . `[`. ! -d "${testlogs_dir}" ]; then |
| 9 | echoscip-shell system . . echo. "No Bazel testlogs directory found." |
| 10 | exit 0 |
| 11 | fi |
| 12 | |
| 13 | rmscip-shell system . . rm. -rf "${artifact_dir}" |
| 14 | mkdirscip-shell system . . mkdir. -p "${artifact_dir}" |
| 15 | |
| 16 | while IFS= read -r -d '' file; do |
| 17 | relative_path="${file#"${testlogs_dir}/"}" |
| 18 | destination="${artifact_dir}/${relative_path}" |
| 19 | mkdirscip-shell system . . mkdir. -p "$(dirnamescip-shell system . . dirname. "${destination}")" |
| 20 | cpscip-shell system . . cp. "${file}" "${destination}" |
| 21 | done < <( |
| 22 | findscip-shell system . . find. "${testlogs_dir}" \ |
| 23 | \( -name test.log -o -name test.xml -o -name outputs.zip -o -name test.outputs_manifest \) \ |
| 24 | -type f -print0 |
| 25 | ) |
| 26 | |
| 27 | echoscip-shell system . . echo. "Collected Bazel test logs into ${artifact_dir}" |