File size: 1,767 Bytes
ef987bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
set -euo pipefail

TEST_DIR="$(cd "$(dirname "$0")" && pwd)"
TEMP_DIR="$(mktemp -d /tmp/task-060-enhanced-XXXXXX)"
cleanup() { rm -rf -- "$TEMP_DIR"; }
trap cleanup EXIT

# Preserve legitimate local packages and support assets, not only root Go files.
tar --exclude='./tests' --exclude='./logs' --exclude='./.git' -cf - . | tar -xf - -C "$TEMP_DIR"
cp "$TEST_DIR/enhanced_cases_test.go.fixture" "$TEMP_DIR/enhanced_cases_test.go"
cp ./sensitive_words.txt "$TEMP_DIR/sensitive_words.txt"
test -f "$TEMP_DIR/go.mod"

export GOPROXY=off
export GOSUMDB=off
# Reuse Go's container-local compilation cache across the five isolated test
# cases. A fresh empty cache per case can spend the 45s limit compiling stdlib.
export HARBOR_TEST_SEED=60001
command -v timeout >/dev/null 2>&1

case "${1:-}" in
  '') test_names=(TestEnhancedDistinctWordsAcrossAllContentTypes TestEnhancedRepeatedConfigurationReplacement TestEnhancedAuditTrailForMultipleAttempts TestEnhancedFileConfigAndSubmission TestEnhancedInvalidTypeAndDefensiveCopies) ;;
  ENHANCED_CASE_1) test_names=(TestEnhancedDistinctWordsAcrossAllContentTypes) ;;
  ENHANCED_CASE_2) test_names=(TestEnhancedRepeatedConfigurationReplacement) ;;
  ENHANCED_CASE_3) test_names=(TestEnhancedAuditTrailForMultipleAttempts) ;;
  ENHANCED_CASE_4) test_names=(TestEnhancedFileConfigAndSubmission) ;;
  ENHANCED_CASE_5) test_names=(TestEnhancedInvalidTypeAndDefensiveCopies TestEnhancedWordOwnershipAndEmptyReplacement) ;;
  *) echo "unknown enhanced case: $1" >&2; exit 2 ;;
esac

for test_name in "${test_names[@]}"; do
  (cd "$TEMP_DIR" && timeout --signal=TERM --kill-after=5s 45s go test -count=1 -run "^${test_name}$" ./...)
done
echo "task 60 enhanced cases passed (${#test_names[@]}/${#test_names[@]})"