Тааак
This commit is contained in:
parent
8429487f57
commit
a354c34e1d
1 changed files with 60 additions and 37 deletions
97
.github/workflows/compile-and-test.yml
vendored
97
.github/workflows/compile-and-test.yml
vendored
|
|
@ -13,45 +13,68 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Make `makefile.sh` executable
|
- name: Make `makefile.sh` executable
|
||||||
run: |
|
run: |
|
||||||
chmod +x makefile.sh
|
chmod +x makefile.sh
|
||||||
|
|
||||||
- name: Run `makefile.sh` to prepare Makefile
|
- name: Run `makefile.sh` to prepare Makefile
|
||||||
run: |
|
run: |
|
||||||
./makefile.sh
|
./makefile.sh
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "::error::makefile.sh failed"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Compile using Makefile
|
|
||||||
run: |
|
|
||||||
cd ComputationalGeometry/6Ex
|
|
||||||
make
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "::error::Compilation failed"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Run Tests
|
|
||||||
run: |
|
|
||||||
cd ComputationalGeometry/6Ex
|
|
||||||
if [ ! -f "./a.out" ]; then
|
|
||||||
echo "::error::Executable not found: a.out"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
for file in t/*; do
|
|
||||||
echo "Testing with file: $file"
|
|
||||||
|
|
||||||
# Передаём последовательный ввод
|
|
||||||
printf "0\n$file\n" | ./a.out
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "::error::Test failed for $file"
|
echo "::error::makefile.sh failed"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
- name: Compile using Makefile
|
||||||
|
run: |
|
||||||
|
cd ComputationalGeometry/6Ex
|
||||||
|
make
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "::error::Compilation failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
run: |
|
||||||
|
cd ComputationalGeometry/6Ex
|
||||||
|
if [ ! -f "./a.out" ]; then
|
||||||
|
echo "::error::Executable not found: a.out"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Проверяем, что есть папка t/ с тестовыми файлами
|
||||||
|
if [ ! -d "t" ]; then
|
||||||
|
echo "::error::Directory 't' with test files not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for file in t/*; do
|
||||||
|
echo "------------------------------------"
|
||||||
|
echo "Testing with file: $file"
|
||||||
|
|
||||||
|
# Способ 1. Передавать через временный файл
|
||||||
|
# echo "0" > test_input.txt
|
||||||
|
# echo "$file" >> test_input.txt
|
||||||
|
# echo "=== Test input ==="
|
||||||
|
# cat test_input.txt
|
||||||
|
# echo "=================="
|
||||||
|
# ./a.out < test_input.txt
|
||||||
|
|
||||||
|
# Способ 2. Через printf (важно экранировать %s и $file)
|
||||||
|
printf "0\n%s\n" "$file" | ./a.out
|
||||||
|
# Или можно так (если хотите увидеть ввод на экране лога):
|
||||||
|
echo -e "0\n$file\n" | ./a.out
|
||||||
|
|
||||||
|
status=$?
|
||||||
|
echo "Exit code: $status"
|
||||||
|
|
||||||
|
if [ $status -ne 0 ]; then
|
||||||
|
echo "::error::Test failed for $file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "All tests passed successfully."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue