-
Notifications
You must be signed in to change notification settings - Fork 1
85 lines (83 loc) · 2.1 KB
/
test.yml
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
name: C/C++ CI
on:
push:
branches:
- main
- master
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Environment
run: rustup override set nightly
- name: Run tests
run: |
cargo test
cargo build
- name: algorithm_test
run: |
cd test/algorithm
cp ../../src/io.c ./io.c
echo "test for algorithm"
for file in `ls`
do
if [[ $file =~ ".c" ]] && [ $file != "io.c" ];
then
../../target/debug/main $file
echo "================"$file"================"
cat input.txt | ./a.out | diff - output.txt
fi
done
- name: with_output_test
run: |
cd test/with_output
cp ../../src/io.c ./io.c
echo "test for with_output"
for file in `ls`
do
if [[ $file =~ ".c" ]] && [ $file != "io.c" ];
then
../../target/debug/main $file
echo "================"$file"================"
./a.out | diff - `echo $file | sed 's/\.c//'`_out.txt
fi
done
- name: wrong_test
run: |
echo "test for wrong"
cd test/wrong
cp ../../src/io.c ./io.c
for file in `ls`
do
if [[ $file =~ ".c" ]] && [ $file != "io.c" ];
then
echo "================"$file"================"
if ../../target/debug/main $file;then
echo "wrong"
exit 1
else
echo "right"
fi
fi
done
- name: ok_test
run: |
echo "test for ok"
cd test/ok
cp ../../src/io.c ./io.c
for file in `ls`
do
if [[ $file =~ ".c" ]] && [ $file != "io.c" ];
then
echo "================"$file"================"
if ../../target/debug/main $file;then
echo "right"
else
echo "wrong"
exit 1
fi
fi
done