Browse Source

Merge pull request #149 from patacrep/windows_veyor_tests

Add windows tests (AppVeyor)
pull/152/head
oliverpool 9 years ago
parent
commit
2ae67a6c78
  1. 50
      .appveyor.yml
  2. 3
      patacrep/__init__.py
  3. 20
      patacrep/build.py
  4. 2
      patacrep/content/song.py
  5. 0
      patacrep/data/ast_templates/chordpro/chordpro/content_chord
  6. 0
      patacrep/data/ast_templates/chordpro/chordpro/content_chordlist
  7. 0
      patacrep/data/ast_templates/chordpro/chordpro/content_comment
  8. 0
      patacrep/data/ast_templates/chordpro/chordpro/content_define
  9. 0
      patacrep/data/ast_templates/chordpro/chordpro/content_endofline
  10. 0
      patacrep/data/ast_templates/chordpro/chordpro/content_error
  11. 0
      patacrep/data/ast_templates/chordpro/chordpro/content_guitar_comment
  12. 0
      patacrep/data/ast_templates/chordpro/chordpro/content_image
  13. 0
      patacrep/data/ast_templates/chordpro/chordpro/content_line
  14. 0
      patacrep/data/ast_templates/chordpro/chordpro/content_newline
  15. 0
      patacrep/data/ast_templates/chordpro/chordpro/content_partition
  16. 0
      patacrep/data/ast_templates/chordpro/chordpro/content_space
  17. 0
      patacrep/data/ast_templates/chordpro/chordpro/content_tablature
  18. 0
      patacrep/data/ast_templates/chordpro/chordpro/content_verse
  19. 0
      patacrep/data/ast_templates/chordpro/chordpro/content_word
  20. 0
      patacrep/data/ast_templates/chordpro/chordpro/song
  21. 0
      patacrep/data/ast_templates/chordpro/chordpro/song_body
  22. 0
      patacrep/data/ast_templates/chordpro/chordpro/song_header
  23. 0
      patacrep/data/ast_templates/chordpro/html/content_chord
  24. 0
      patacrep/data/ast_templates/chordpro/html/content_chordlist
  25. 0
      patacrep/data/ast_templates/chordpro/html/content_comment
  26. 0
      patacrep/data/ast_templates/chordpro/html/content_define
  27. 0
      patacrep/data/ast_templates/chordpro/html/content_define_list
  28. 0
      patacrep/data/ast_templates/chordpro/html/content_endofline
  29. 0
      patacrep/data/ast_templates/chordpro/html/content_error
  30. 0
      patacrep/data/ast_templates/chordpro/html/content_guitar_comment
  31. 0
      patacrep/data/ast_templates/chordpro/html/content_image
  32. 0
      patacrep/data/ast_templates/chordpro/html/content_line
  33. 0
      patacrep/data/ast_templates/chordpro/html/content_metadata_cover
  34. 0
      patacrep/data/ast_templates/chordpro/html/content_newline
  35. 0
      patacrep/data/ast_templates/chordpro/html/content_partition
  36. 0
      patacrep/data/ast_templates/chordpro/html/content_space
  37. 0
      patacrep/data/ast_templates/chordpro/html/content_tablature
  38. 0
      patacrep/data/ast_templates/chordpro/html/content_verse
  39. 0
      patacrep/data/ast_templates/chordpro/html/content_word
  40. 0
      patacrep/data/ast_templates/chordpro/html/song
  41. 0
      patacrep/data/ast_templates/chordpro/html/song_body
  42. 0
      patacrep/data/ast_templates/chordpro/html/song_header
  43. 0
      patacrep/data/ast_templates/chordpro/latex/content_chord
  44. 0
      patacrep/data/ast_templates/chordpro/latex/content_chordlist
  45. 0
      patacrep/data/ast_templates/chordpro/latex/content_comment
  46. 0
      patacrep/data/ast_templates/chordpro/latex/content_define
  47. 0
      patacrep/data/ast_templates/chordpro/latex/content_endofline
  48. 0
      patacrep/data/ast_templates/chordpro/latex/content_error
  49. 0
      patacrep/data/ast_templates/chordpro/latex/content_guitar_comment
  50. 2
      patacrep/data/ast_templates/chordpro/latex/content_image
  51. 0
      patacrep/data/ast_templates/chordpro/latex/content_line
  52. 0
      patacrep/data/ast_templates/chordpro/latex/content_newline
  53. 6
      patacrep/data/ast_templates/chordpro/latex/content_partition
  54. 0
      patacrep/data/ast_templates/chordpro/latex/content_space
  55. 0
      patacrep/data/ast_templates/chordpro/latex/content_tablature
  56. 0
      patacrep/data/ast_templates/chordpro/latex/content_verse
  57. 0
      patacrep/data/ast_templates/chordpro/latex/content_word
  58. 2
      patacrep/data/ast_templates/chordpro/latex/song
  59. 0
      patacrep/data/ast_templates/chordpro/latex/song_body
  60. 12
      patacrep/errors.py
  61. 0
      patacrep/songbook/__init__.py
  62. 7
      patacrep/songs/chordpro/__init__.py
  63. 6
      patacrep/songs/chordpro/data/latex/content_partition
  64. 7
      setup.py
  65. 24
      test/test_compilation/test_compilation.py
  66. 18
      texlive_packages.txt
  67. 2
      tox.ini

50
.appveyor.yml

@ -0,0 +1,50 @@
environment:
matrix:
- PYTHON: "C:\\Python34"
PYTHON_VERSION: "3.4.x" # currently 3.4.3
PYTHON_ARCH: "32"
install:
# Download setup scripts and unzip
- ps: "wget https://github.com/cloudify-cosmo/appveyor-utils/archive/master.zip -OutFile ./master.zip"
- "7z e master.zip */appveyor/* -oappveyor"
# Install Python (from the official .msi of http://python.org) and pip when
# not already installed.
- "powershell ./appveyor/install.ps1"
# Prepend newly installed Python to the PATH of this build (this cannot be
# done from inside the powershell script as it would require to restart
# the parent CMD process).
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
# Check that we have the expected version and architecture for Python
- "python --version"
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
# Download miktex portable (if not cached)
- ps: "If (!(Test-Path miktex-portable.exe)){wget http://mirrors.ctan.org/systems/win32/miktex/setup/miktex-portable-2.9.5719.exe -OutFile ./miktex-portable.exe}"
# Unzip miktex portable
- "7z x miktex-portable.exe * -aot -omiktex > nul"
# Let the binaries be directly callable
- cmd: set PATH=%PATH%;C:\projects\patacrep\miktex\miktex\bin
# Update fonts
- cmd: luaotfload-tool.exe --update
# Manually install required texlive packages
- cmd: mpm.exe --install-some texlive_packages.txt
build: false # Not a C# project, build stuff at the test step instead.
before_test:
- "pip install tox"
test_script:
- "tox"
# Cache Miktex Portable file
cache:
- C:\projects\patacrep\miktex-portable.exe

3
patacrep/__init__.py

@ -17,3 +17,6 @@ __version__ = '.'.join([str(number) for number in __TUPLE_VERSION__])
# etc.)
__DATADIR__ = os.path.abspath(resource_filename(__name__, 'data'))
def pkg_datapath(*path):
"""Return the package data path"""
return os.path.join(__DATADIR__, *path)

20
patacrep/build.py

@ -6,7 +6,7 @@ import glob
import logging
import threading
import os.path
from subprocess import Popen, PIPE, call
from subprocess import Popen, PIPE, call, check_call
from patacrep import __DATADIR__, authors, content, errors, files
from patacrep.index import process_sxd
@ -217,13 +217,27 @@ class SongbookBuilder(object):
LOGGER.info("Building '{}.pdf'".format(self.basename))
self._run_once(self._set_latex)
compiler = "lualatex"
# Test if the LaTeX compiler is accessible
try:
check_call(
[compiler, "--version"],
stdin=PIPE,
stdout=PIPE,
stderr=PIPE,
universal_newlines=True,
)
except Exception as error:
raise errors.ExecutableNotFound(compiler)
# Perform compilation
try:
process = Popen(
["lualatex"] + self._lualatex_options + [self.basename],
[compiler] + self._lualatex_options + [self.basename],
stdin=PIPE,
stdout=PIPE,
stderr=PIPE,
env=os.environ,
universal_newlines=True,
)
except Exception as error:

2
patacrep/content/song.py

@ -42,7 +42,7 @@ class SongRenderer(Content):
{song}
""").format(
separator="%"*80,
path=self.song.subpath,
path=files.path2posix(self.song.subpath),
song=self.song.render(output=context['filename']),
)

0
patacrep/songs/chordpro/data/chordpro/content_chord → patacrep/data/ast_templates/chordpro/chordpro/content_chord

0
patacrep/songs/chordpro/data/chordpro/content_chordlist → patacrep/data/ast_templates/chordpro/chordpro/content_chordlist

0
patacrep/songs/chordpro/data/chordpro/content_comment → patacrep/data/ast_templates/chordpro/chordpro/content_comment

0
patacrep/songs/chordpro/data/chordpro/content_define → patacrep/data/ast_templates/chordpro/chordpro/content_define

0
patacrep/songs/chordpro/data/chordpro/content_endofline → patacrep/data/ast_templates/chordpro/chordpro/content_endofline

0
patacrep/songs/chordpro/data/chordpro/content_error → patacrep/data/ast_templates/chordpro/chordpro/content_error

0
patacrep/songs/chordpro/data/chordpro/content_guitar_comment → patacrep/data/ast_templates/chordpro/chordpro/content_guitar_comment

0
patacrep/songs/chordpro/data/chordpro/content_image → patacrep/data/ast_templates/chordpro/chordpro/content_image

0
patacrep/songs/chordpro/data/chordpro/content_line → patacrep/data/ast_templates/chordpro/chordpro/content_line

0
patacrep/songs/chordpro/data/chordpro/content_newline → patacrep/data/ast_templates/chordpro/chordpro/content_newline

0
patacrep/songs/chordpro/data/chordpro/content_partition → patacrep/data/ast_templates/chordpro/chordpro/content_partition

0
patacrep/songs/chordpro/data/chordpro/content_space → patacrep/data/ast_templates/chordpro/chordpro/content_space

0
patacrep/songs/chordpro/data/chordpro/content_tablature → patacrep/data/ast_templates/chordpro/chordpro/content_tablature

0
patacrep/songs/chordpro/data/chordpro/content_verse → patacrep/data/ast_templates/chordpro/chordpro/content_verse

0
patacrep/songs/chordpro/data/chordpro/content_word → patacrep/data/ast_templates/chordpro/chordpro/content_word

0
patacrep/songs/chordpro/data/chordpro/song → patacrep/data/ast_templates/chordpro/chordpro/song

0
patacrep/songs/chordpro/data/chordpro/song_body → patacrep/data/ast_templates/chordpro/chordpro/song_body

0
patacrep/songs/chordpro/data/chordpro/song_header → patacrep/data/ast_templates/chordpro/chordpro/song_header

0
patacrep/songs/chordpro/data/html/content_chord → patacrep/data/ast_templates/chordpro/html/content_chord

0
patacrep/songs/chordpro/data/html/content_chordlist → patacrep/data/ast_templates/chordpro/html/content_chordlist

0
patacrep/songs/chordpro/data/html/content_comment → patacrep/data/ast_templates/chordpro/html/content_comment

0
patacrep/songs/chordpro/data/html/content_define → patacrep/data/ast_templates/chordpro/html/content_define

0
patacrep/songs/chordpro/data/html/content_define_list → patacrep/data/ast_templates/chordpro/html/content_define_list

0
patacrep/songs/chordpro/data/html/content_endofline → patacrep/data/ast_templates/chordpro/html/content_endofline

0
patacrep/songs/chordpro/data/html/content_error → patacrep/data/ast_templates/chordpro/html/content_error

0
patacrep/songs/chordpro/data/html/content_guitar_comment → patacrep/data/ast_templates/chordpro/html/content_guitar_comment

0
patacrep/songs/chordpro/data/html/content_image → patacrep/data/ast_templates/chordpro/html/content_image

0
patacrep/songs/chordpro/data/html/content_line → patacrep/data/ast_templates/chordpro/html/content_line

0
patacrep/songs/chordpro/data/html/content_metadata_cover → patacrep/data/ast_templates/chordpro/html/content_metadata_cover

0
patacrep/songs/chordpro/data/html/content_newline → patacrep/data/ast_templates/chordpro/html/content_newline

0
patacrep/songs/chordpro/data/html/content_partition → patacrep/data/ast_templates/chordpro/html/content_partition

0
patacrep/songs/chordpro/data/html/content_space → patacrep/data/ast_templates/chordpro/html/content_space

0
patacrep/songs/chordpro/data/html/content_tablature → patacrep/data/ast_templates/chordpro/html/content_tablature

0
patacrep/songs/chordpro/data/html/content_verse → patacrep/data/ast_templates/chordpro/html/content_verse

0
patacrep/songs/chordpro/data/html/content_word → patacrep/data/ast_templates/chordpro/html/content_word

0
patacrep/songs/chordpro/data/html/song → patacrep/data/ast_templates/chordpro/html/song

0
patacrep/songs/chordpro/data/html/song_body → patacrep/data/ast_templates/chordpro/html/song_body

0
patacrep/songs/chordpro/data/html/song_header → patacrep/data/ast_templates/chordpro/html/song_header

0
patacrep/songs/chordpro/data/latex/content_chord → patacrep/data/ast_templates/chordpro/latex/content_chord

0
patacrep/songs/chordpro/data/latex/content_chordlist → patacrep/data/ast_templates/chordpro/latex/content_chordlist

0
patacrep/songs/chordpro/data/latex/content_comment → patacrep/data/ast_templates/chordpro/latex/content_comment

0
patacrep/songs/chordpro/data/latex/content_define → patacrep/data/ast_templates/chordpro/latex/content_define

0
patacrep/songs/chordpro/data/latex/content_endofline → patacrep/data/ast_templates/chordpro/latex/content_endofline

0
patacrep/songs/chordpro/data/latex/content_error → patacrep/data/ast_templates/chordpro/latex/content_error

0
patacrep/songs/chordpro/data/latex/content_guitar_comment → patacrep/data/ast_templates/chordpro/latex/content_guitar_comment

2
patacrep/songs/chordpro/data/latex/content_image → patacrep/data/ast_templates/chordpro/latex/content_image

@ -1,5 +1,5 @@
(* block image *)
(* set image = content.argument|search_image *)
(* set image = content.argument|search_image|path2posix *)
(* if image *)
\image{(( image ))}
(*- endif *)

0
patacrep/songs/chordpro/data/latex/content_line → patacrep/data/ast_templates/chordpro/latex/content_line

0
patacrep/songs/chordpro/data/latex/content_newline → patacrep/data/ast_templates/chordpro/latex/content_newline

6
patacrep/data/ast_templates/chordpro/latex/content_partition

@ -0,0 +1,6 @@
(* block partition *)
(* set partition = content.argument|search_partition|path2posix *)
(* if partition *)
\lilypond{ ((- partition -)) }
(*- endif -*)
(*- endblock -*)

0
patacrep/songs/chordpro/data/latex/content_space → patacrep/data/ast_templates/chordpro/latex/content_space

0
patacrep/songs/chordpro/data/latex/content_tablature → patacrep/data/ast_templates/chordpro/latex/content_tablature

0
patacrep/songs/chordpro/data/latex/content_verse → patacrep/data/ast_templates/chordpro/latex/content_verse

0
patacrep/songs/chordpro/data/latex/content_word → patacrep/data/ast_templates/chordpro/latex/content_word

2
patacrep/songs/chordpro/data/latex/song → patacrep/data/ast_templates/chordpro/latex/song

@ -29,7 +29,7 @@
(* endfor *)
(* if 'cover' in metadata *)
(* block cover *)
(* set cover = metadata["cover"].argument|search_image *)
(* set cover = metadata["cover"].argument|search_image|path2posix *)
(* if cover *)
cover={(( cover ))},
(* endif *)

0
patacrep/songs/chordpro/data/latex/song_body → patacrep/data/ast_templates/chordpro/latex/song_body

12
patacrep/errors.py

@ -31,6 +31,16 @@ class TemplateError(SongbookError):
else:
return self.message
class ExecutableNotFound(SongbookError):
"""Couldn't find a LaTeX executable."""
def __init__(self, executable):
super(ExecutableNotFound, self).__init__(
(
"""Could not find the following executable: {executable}"""
).format(executable=executable)
)
class StepError(SongbookError):
"""Error during execution of one compilation step."""
@ -47,7 +57,7 @@ class LatexCompilationError(StepError):
def __init__(self, basename):
super(LatexCompilationError, self).__init__(
(
"""Error while pdfLaTeX compilation of "{basename}.tex" """
"""Error while LaTeX compilation of "{basename}.tex" """
"""(see {basename}.log for more information)."""
).format(basename=basename)
)

0
patacrep/songbook/__init__.py

7
patacrep/songs/chordpro/__init__.py

@ -5,13 +5,13 @@ import jinja2
import logging
import operator
import os
from pkg_resources import resource_filename
from patacrep import encoding, files
from patacrep import encoding, files, pkg_datapath
from patacrep.songs import Song
from patacrep.songs.chordpro.syntax import parse_song
from patacrep.templates import Renderer
from patacrep.latex import lang2babel
from patacrep.files import path2posix
LOGGER = logging.getLogger(__name__)
@ -53,13 +53,14 @@ class ChordproSong(Song):
self.get_datadirs(os.path.join("templates", self.output_language))
),
FileSystemLoader(
os.path.join(resource_filename(__name__, 'data'), self.output_language)
pkg_datapath('ast_templates', 'chordpro', self.output_language)
),
]))
jinjaenv.filters['search_image'] = self.search_image
jinjaenv.filters['search_partition'] = self.search_partition
jinjaenv.filters['lang2babel'] = lang2babel
jinjaenv.filters['sortargs'] = sort_directive_argument
jinjaenv.filters['path2posix'] = path2posix
try:
return Renderer(

6
patacrep/songs/chordpro/data/latex/content_partition

@ -1,6 +0,0 @@
(* block partition *)
(* set partition = content.argument|search_partition *)
(* if partition *)
\lilypond{ ((- content.argument|search_partition -)) }
(*- endif -*)
(*- endblock -*)

7
setup.py

@ -21,7 +21,12 @@ setup(
"unidecode", "jinja2", "chardet", "ply",
],
setup_requires=["hgtools"],
include_package_data=True,
package_data={'patacrep': [
'data/ast_templates/*/*/*',
'data/img/*',
'data/latex/*',
'data/templates/*',
]},
entry_points={
'console_scripts': [
"songbook = patacrep.songbook.__main__:main",

24
test/test_compilation/test_compilation.py

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

18
texlive_packages.txt

@ -0,0 +1,18 @@
babel-english
babel-esperanto
babel-french
babel-german
babel-latin
babel-spanish
fancybox
framed
import
l3kernel
l3packages
mptopdf
ms
pgf
tipa
url
xcolor
xstring

2
tox.ini

@ -7,7 +7,7 @@ envlist = py34, lint
[testenv]
commands = {envpython} setup.py test
passenv = TRAVIS
passenv = TRAVIS APPVEYOR CI
deps =
[testenv:lint]

Loading…
Cancel
Save