From a968c5c6fbc48093f193307a7c52e0d67a1c8d7b Mon Sep 17 00:00:00 2001 From: AZEN-SGG Date: Sat, 21 Dec 2024 21:56:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=BB=D0=B6=D0=B5=D0=BD=20=D0=B7=D0=B0=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=B0=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/compile-and-test.yml | 93 ++++++++++---------------- makefile.sh | 14 +++- 2 files changed, 48 insertions(+), 59 deletions(-) diff --git a/.github/workflows/compile-and-test.yml b/.github/workflows/compile-and-test.yml index 1580ceb..ce4f9f5 100644 --- a/.github/workflows/compile-and-test.yml +++ b/.github/workflows/compile-and-test.yml @@ -13,64 +13,45 @@ 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 + - name: Run `makefile.sh` to prepare Makefile + run: | + ./makefile.sh delete + 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" + + # Создаём файл ввода + (echo "0"; echo "$file") | ./a.out if [ $? -ne 0 ]; then - echo "::error::makefile.sh failed" + echo "::error::Test failed for $file" 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 - - 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" - - # Создаём временный файл с "0" и именем тестового файла: - echo "0" > test_input.txt - echo "$file" >> test_input.txt - - echo "==== DEBUG test_input.txt ====" - cat -A test_input.txt - echo "==============================" - - # Теперь фидим это stdin - ./a.out < test_input.txt - 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." + done \ No newline at end of file diff --git a/makefile.sh b/makefile.sh index a730a4f..b807678 100644 --- a/makefile.sh +++ b/makefile.sh @@ -5,9 +5,17 @@ find . -type f -name "makefile" | while read -r file; do tmp_file=$(mktemp) - sed -e 's/a\.exe/\.\/a\.out/g' \ - -e 's/\/rm/g' \ - -e 's/\-lssp//g' "$file" > "$tmp_file" + if [ "$1" == "delete" ]; then + # Удаление строк с a.exe + sed -e '/a\.exe/d' \ + -e 's/\/rm/g' \ + -e 's/\-lssp//g' "$file" > "$tmp_file" + else + # Замена a.exe на ./a.out + sed -e 's/a\.exe/\.\/a\.out/g' \ + -e 's/\/rm/g' \ + -e 's/\-lssp//g' "$file" > "$tmp_file" + fi mv "$tmp_file" "$file" echo "File $file processed."