-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.sh
85 lines (68 loc) · 2.68 KB
/
run.sh
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env bash
set -e
# if GCCRS_PATH is set
if [ -z "$GCCRS_PATH" ]; then
echo "Error: GCCRS_PATH environment variable is not set."
echo -e "Please set it using the command:\n\texport GCCRS_PATH=/path/to/gccrs"
exit 1
fi
# if RUST_PATH is set
if [ -z "$RUST_PATH" ]; then
echo "Error: RUST_PATH environment variable is not set."
echo -e "Please set it using the command:\n\texport RUST_PATH=/path/to/rust"
exit 1
fi
# check for rusttest-to-dg path
if [ -z "$RUSTTEST_TO_DG_PATH" ]; then
echo "Error: RUSTTEST_TO_DG_PATH environment variable is not set."
echo -e "Please set it using the command:\n\texport RUSTTEST_TO_DG_PATH=/path/to/rusttest-to-dg"
exit 1
fi
echo "GCCRS_PATH: $GCCRS_PATH"
echo "RUST_PATH: $RUST_PATH"
echo "RUSTTEST_TO_DG_PATH: $RUSTTEST_TO_DG_PATH"
# Installing rusttest-to-dg
cd "$RUSTTEST_TO_DG_PATH"
echo -e "\nInstalling rusttest-to-dg\n"
cargo install --path .
echo -e "\nInstalled rusttest-to-dg\n"
# Check if the ui directory exists and remove it if it does
if [ -d "$GCCRS_PATH/gcc/testsuite/rust/rustc/ui" ]; then
echo "Removing existing ui directory at $GCCRS_PATH/gcc/testsuite/rust/rustc/ui"
rm -rf "$GCCRS_PATH/gcc/testsuite/rust/rustc/ui"
fi
# Copying the RUST_PATH/tests/ui to GCCRS_PATH/gcc/testsuite/rust/rustc
echo -e "Copying tests from $RUST_PATH/tests/ui to $GCCRS_PATH/gcc/testsuite/rust/rustc"
cp -r "$RUST_PATH"/tests/ui "$GCCRS_PATH"/gcc/testsuite/rust/rustc
echo -e "Copied $RUST_PATH/tests/ui tests to $GCCRS_PATH/gcc/testsuite/rust/rustc/ui"
cd "$GCCRS_PATH"/gcc/testsuite/rust/rustc/ui
process_files() {
# Recursively process rust files
for file in "$1"/*.rs; do
if [[ -f "$file" ]]; then
base_name="${file%.rs}"
stderr_file="${base_name}.stderr"
output_file="${base_name}_dg.rs"
# if we have `.stderr` file
if [[ -f "$stderr_file" ]]; then
rusttest-to-dg "$file" --stderr "$stderr_file" > "$output_file"
else
rusttest-to-dg "$file" > "$output_file"
fi
mv "$output_file" "$file"
fi
done
# Recursively process subdirectories
for dir in "$1"/*/; do
if [[ -d "$dir" ]]; then
process_files "$dir"
fi
done
}
echo -e "Converting rustc source files to DejaGnu format..."
process_files "$GCCRS_PATH/gcc/testsuite/rust/rustc/ui/"
# Remove all files that don't end with .rs extension in the ui directory
echo "Removing non-.rs files in $GCCRS_PATH/gcc/testsuite/rust/rustc/ui"
find "$GCCRS_PATH/gcc/testsuite/rust/rustc/ui" -type f ! -name '*.rs' -exec rm -f {} +
echo "Removed non-.rs files in $GCCRS_PATH/gcc/testsuite/rust/rustc/ui"
echo -e "Processing complete."