Skip to content

Commit

Permalink
Fix compilation blocking (#168)
Browse files Browse the repository at this point in the history
* Fix compilation blocking

* Add tests

* Fix shell ingen

* Fix tests
  • Loading branch information
MasloMaslane authored Jan 3, 2024
1 parent fcf91cb commit 3af16b9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/sinol_make/helpers/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ def compile(program, output, compilers: Compilers = None, compile_log = None, we
raise CompilationError('Unknown file extension: ' + ext)

process = subprocess.Popen(arguments, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
process.wait()
out, _ = process.communicate()
if compile_log is not None:
compile_log.write(out.decode('utf-8'))
Expand Down
19 changes: 19 additions & 0 deletions tests/helpers/test_compile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import os
import pytest
import tempfile

from sinol_make.helpers.cache import save_compiled, check_compiled
from tests import util
from tests.fixtures import create_package
from tests.commands.gen.test_integration import simple_run


def test_compilation_caching():
Expand All @@ -16,3 +20,18 @@ def test_compilation_caching():
save_compiled(os.path.join(os.getcwd(), "test.txt"),
os.path.join(os.getcwd(), "test.e"))
assert check_compiled(os.path.join(os.getcwd(), "test.txt")) == os.path.join(os.getcwd(), "test.e")


@pytest.mark.parametrize("create_package", [util.get_shell_ingen_pack_path()], indirect=True)
def test_large_failed_output(create_package):
"""
Test `ingen` command with large failed output.
"""
with open(os.path.join(create_package, "prog", "geningen2.cpp"), "r") as f:
code = f.read()
code = code.replace("<<", "<")
with open(os.path.join(create_package, "prog", "geningen2.cpp"), "w") as f:
f.write(code)

with pytest.raises(SystemExit):
simple_run(["prog/geningen2.cpp"])
2 changes: 1 addition & 1 deletion tests/packages/gen/prog/geningen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function generate() {

cache=$(dirname "$0")/../.cache
mkdir -p "$cache"
g++ gen_helper.cpp -o "$cache"/gen
g++ "$(dirname "$0")/gen_helper.cpp" -o "$cache"/gen

cpu_num=$(nproc)

Expand Down

0 comments on commit 3af16b9

Please sign in to comment.