forked from YangHarvey/exp_yacc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunflex.sh
More file actions
executable file
·31 lines (31 loc) · 849 Bytes
/
runflex.sh
File metadata and controls
executable file
·31 lines (31 loc) · 849 Bytes
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
#!/bin/bash
echo "====Running Flex tests...===="
# 项目根目录
ROOT_DIR=$(pwd)
# 编译目录
BUILD_DIR="$ROOT_DIR/mine/flex"
# 测试目录
TEST_DIR="$ROOT_DIR/tests/flex_tests"
# 编译lexer
cd "$BUILD_DIR" && make clean && make
# 检查lexer是否编译成功
if [ ! -f "$BUILD_DIR/lexer" ]; then
echo "Lexer Compilation failed."
exit 1
fi
# 运行测试
cd "$TEST_DIR"
# 测试文件和输出文件
TEST_FILES=("testfile1.txt" "testfile2.txt")
OUTPUT_FILES=("my_output1.txt" "my_output2.txt")
EXPECTED_FILES=("output1.txt" "output2.txt")
# 运行lexer并比较输出
for i in ${!TEST_FILES[@]}; do
"$BUILD_DIR/lexer" < "${TEST_FILES[$i]}" > "${OUTPUT_FILES[$i]}"
diff "${OUTPUT_FILES[$i]}" "${EXPECTED_FILES[$i]}"
if [ $? -ne 0 ]; then
echo "Test failed for ${TEST_FILES[$i]}"
exit 1
fi
done
echo "All flex tests passed."