From a354c34e1d87147311a5e909ac017ab9213771a3 Mon Sep 17 00:00:00 2001 From: AZEN-SGG Date: Sat, 21 Dec 2024 21:21:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B0=D0=B0=D0=B0=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/compile-and-test.yml | 97 ++++++++++++++++---------- 1 file changed, 60 insertions(+), 37 deletions(-) diff --git a/.github/workflows/compile-and-test.yml b/.github/workflows/compile-and-test.yml index e6e7af7..bdd7f1b 100644 --- a/.github/workflows/compile-and-test.yml +++ b/.github/workflows/compile-and-test.yml @@ -13,45 +13,68 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v3 - - name: Make `makefile.sh` executable - run: | - chmod +x makefile.sh + - name: Make `makefile.sh` executable + run: | + chmod +x makefile.sh - - name: Run `makefile.sh` to prepare Makefile - run: | - ./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 + - name: Run `makefile.sh` to prepare Makefile + run: | + ./makefile.sh if [ $? -ne 0 ]; then - echo "::error::Test failed for $file" + echo "::error::makefile.sh failed" exit 1 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."