|
@ -5,10 +5,12 @@ |
|
|
import glob |
|
|
import glob |
|
|
import logging |
|
|
import logging |
|
|
import os |
|
|
import os |
|
|
|
|
|
import sys |
|
|
import subprocess |
|
|
import subprocess |
|
|
import unittest |
|
|
import unittest |
|
|
|
|
|
|
|
|
from patacrep.encoding import open_read |
|
|
from patacrep.encoding import open_read |
|
|
|
|
|
from patacrep.files import path2posix |
|
|
|
|
|
|
|
|
from .. import dynamic # pylint: disable=unused-import |
|
|
from .. import dynamic # pylint: disable=unused-import |
|
|
|
|
|
|
|
@ -67,16 +69,18 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): |
|
|
expected = expectfile.read().strip() |
|
|
expected = expectfile.read().strip() |
|
|
expected = expected.replace( |
|
|
expected = expected.replace( |
|
|
"@TEST_FOLDER@", |
|
|
"@TEST_FOLDER@", |
|
|
os.path.dirname(__file__), |
|
|
path2posix(os.path.dirname(__file__)), |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
expected = expected.replace( |
|
|
expected = expected.replace( |
|
|
"@DATA_FOLDER@", |
|
|
"@DATA_FOLDER@", |
|
|
|
|
|
path2posix( |
|
|
subprocess.check_output( |
|
|
subprocess.check_output( |
|
|
["python", "-c", 'import patacrep, pkg_resources; print(pkg_resources.resource_filename(patacrep.__name__, "data"))'], # pylint: disable=line-too-long |
|
|
[sys.executable, "-c", 'import patacrep; print(patacrep.__DATADIR__)'], # pylint: disable=line-too-long |
|
|
universal_newlines=True, |
|
|
universal_newlines=True, |
|
|
cwd=os.path.dirname(songbook), |
|
|
cwd=os.path.dirname(songbook), |
|
|
).strip(), |
|
|
).strip() |
|
|
|
|
|
), |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
self.assertMultiLineEqual( |
|
|
self.assertMultiLineEqual( |
|
@ -108,12 +112,16 @@ 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, '-v'] |
|
|
command = [sys.executable, '-m', 'patacrep.songbook', songbook] |
|
|
if steps: |
|
|
if steps: |
|
|
command.extend(['--steps', steps]) |
|
|
command.extend(['--steps', steps]) |
|
|
|
|
|
|
|
|
|
|
|
# Continuous Integration will be verbose |
|
|
|
|
|
if 'CI' in os.environ: |
|
|
|
|
|
command.append('-v') |
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
subprocess.check_output( |
|
|
subprocess.check_call( |
|
|
command, |
|
|
command, |
|
|
stderr=subprocess.STDOUT, |
|
|
stderr=subprocess.STDOUT, |
|
|
universal_newlines=True, |
|
|
universal_newlines=True, |
|
|