From 919b2c9c70e47692ebb902fcf8af3cd352f3734e Mon Sep 17 00:00:00 2001 From: Nicolas Date: Tue, 30 Sep 2025 23:18:58 +0200 Subject: [PATCH] ci fixed --- .github/workflows/ci.yml | 14 ++++---------- build.sh | 3 +++ test.sh | 5 +++-- tests/test_compile.py | 14 +++++++++++++- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f32e1f4..f51d12d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,14 +32,8 @@ jobs: python -m pip install --upgrade pip python -m pip install -e . - - name: Build ops obj file - run: bash build_ops_obj.sh - - - name: Build runner - run: | - mkdir bin - gcc -Wall -Wextra -Wconversion -Wsign-conversion -Wshadow -Wstrict-overflow -Werror src/runner/runmem2.c -Wall -O3 -o bin/runmem2 - x86_64-w64-mingw32-gcc -Wall -Wextra -Wconversion -Wsign-conversion -Wshadow -Wstrict-overflow -Werror src/runner/runmem2.c -Wall -O3 -o bin/runmem2.exe + - name: Build ops obj file and runner + run: bash build.sh #- name: Lint code with flake8 # run: flake8 @@ -47,8 +41,8 @@ jobs: #- name: Type checking with mypy # run: mypy - #- name: Run tests with pytest - # run: pytest + - name: Run tests with pytest + run: pytest - name: Upload obj files uses: actions/upload-artifact@v4 diff --git a/build.sh b/build.sh index a7ad068..f045fe9 100644 --- a/build.sh +++ b/build.sh @@ -7,3 +7,6 @@ gcc -c src/copapy/stencils.c -o src/copapy/obj/stencils_x86_64.o gcc -c src/copapy/stencils.c -O1 -o src/copapy/obj/stencils_x86_64_O1.o gcc -c src/copapy/stencils.c -O2 -o src/copapy/obj/stencils_x86_64_O2.o gcc -c src/copapy/stencils.c -O3 -o src/copapy/obj/stencils_x86_64_O3.o + +gcc -Wall -Wextra -Wconversion -Wsign-conversion -Wshadow -Wstrict-overflow -Werror -g src/runner/runmem2.c -o bin/runmem2 +#x86_64-w64-mingw32-gcc -Wall -Wextra -Wconversion -Wsign-conversion -Wshadow -Wstrict-overflow -Werror src/runner/runmem2.c -Wall -O3 -o bin/runmem2.exe \ No newline at end of file diff --git a/test.sh b/test.sh index feb7f06..6f742de 100644 --- a/test.sh +++ b/test.sh @@ -4,5 +4,6 @@ echo "Compile..." python tests/test_compile.py echo "Run..." echo "-----------------------------------" -gcc -Wall -Wextra -Wconversion -Wsign-conversion -Wshadow -Wstrict-overflow -Werror -g src/runner/runmem2.c -o runmem2 -./runmem2 test.copapy \ No newline at end of file +mkdir bin -p +gcc -Wall -Wextra -Wconversion -Wsign-conversion -Wshadow -Wstrict-overflow -Werror -g src/runner/runmem2.c -o bin/runmem2 +./bin/runmem2 test.copapy \ No newline at end of file diff --git a/tests/test_compile.py b/tests/test_compile.py index 70a3a26..cab4a9c 100644 --- a/tests/test_compile.py +++ b/tests/test_compile.py @@ -1,6 +1,13 @@ from copapy import Write, const import copapy as rc +import subprocess +def run_command(command: list[str], encoding: str = 'utf8') -> str: + process = subprocess.Popen(command, stdout=subprocess.PIPE) + output, error = process.communicate() + + assert error is None, f"Error occurred: {error.decode(encoding)}" + return output.decode(encoding) def test_compile(): c1 = const(1.11) @@ -18,7 +25,12 @@ def test_compile(): print('#', il.print()) - il.to_file('test.copapy') + il.to_file('./bin/test.copapy') + + result = run_command(['./bin/runmem2', 'test.copapy']) + print(result) + + assert 'Return value: 0' in result if __name__ == "__main__":