|
@ -6,11 +6,13 @@ import glob |
|
|
import os |
|
|
import os |
|
|
import subprocess |
|
|
import subprocess |
|
|
import unittest |
|
|
import unittest |
|
|
|
|
|
import logging |
|
|
|
|
|
|
|
|
from patacrep.encoding import open_read |
|
|
from patacrep.encoding import open_read |
|
|
|
|
|
|
|
|
from .. import dynamic # pylint: disable=unused-import |
|
|
from .. import dynamic # pylint: disable=unused-import |
|
|
|
|
|
|
|
|
|
|
|
LOGGER = logging.getLogger(__name__) |
|
|
|
|
|
|
|
|
class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): |
|
|
class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): |
|
|
"""Test of songbook compilation. |
|
|
"""Test of songbook compilation. |
|
@ -92,14 +94,18 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): |
|
|
@staticmethod |
|
|
@staticmethod |
|
|
def compile_songbook(songbook, steps=None): |
|
|
def compile_songbook(songbook, steps=None): |
|
|
"""Compile songbook, and return the command return code.""" |
|
|
"""Compile songbook, and return the command return code.""" |
|
|
command = ['python', '-m', 'patacrep.songbook', songbook] |
|
|
command = ['python', '-m', 'patacrep.songbook', songbook, '-v'] |
|
|
if steps: |
|
|
if steps: |
|
|
command.extend(['--steps', steps]) |
|
|
command.extend(['--steps', steps]) |
|
|
|
|
|
|
|
|
return subprocess.check_call( |
|
|
try: |
|
|
command, |
|
|
subprocess.check_output( |
|
|
stdin=subprocess.DEVNULL, |
|
|
command, |
|
|
stdout=subprocess.DEVNULL, |
|
|
stderr=subprocess.STDOUT, |
|
|
stderr=subprocess.DEVNULL, |
|
|
universal_newlines=True, |
|
|
cwd=os.path.dirname(songbook), |
|
|
cwd=os.path.dirname(songbook), |
|
|
) |
|
|
) |
|
|
|
|
|
return 0 |
|
|
|
|
|
except subprocess.CalledProcessError as error: |
|
|
|
|
|
LOGGER.warning(error.output) |
|
|
|
|
|
return error.returncode |
|
|