From 57ab47f82965753e3ad97545d9ef0c3f7fa97f1c Mon Sep 17 00:00:00 2001 From: Louis Date: Sun, 18 Oct 2015 23:09:25 +0200 Subject: [PATCH 01/32] [test] New test case for compilation test Nothing is tested yet --- examples/example-subdir.sb | 18 ----------------- examples/img/datadir.png | Bin 645 -> 0 bytes examples/root.ly | 19 ------------------ examples/root.png | Bin 513 -> 0 bytes examples/songs/subdir/relative.png | Bin 645 -> 0 bytes examples/songs/subdir/root.sg | 10 --------- examples/songs/subdir/root.sgc | 6 ------ {examples => patacrep/data}/img/treble_a.png | Bin test/test_compilation/.gitignore | 2 ++ test/test_compilation/subdir.sb | 7 +++++++ .../subdir_datadir}/img/datadir.ly | 0 .../subdir_datadir/img/datadir.png | Bin 0 -> 4053 bytes .../subdir_datadir/songs}/datadir.sg | 0 .../subdir_datadir/songs}/datadir.sgc | 0 .../subdir_datadir/songs}/datadir2.sg | 0 .../subdir_datadir/songs}/datadir2.sgc | 0 .../subdir_datadir/songs}/relative.ly | 0 .../subdir_datadir/songs/relative.png | Bin 0 -> 4036 bytes .../subdir_datadir/songs}/relative.sg | 0 .../subdir_datadir/songs}/relative.sgc | 0 .../subdir_datadir2}/img/datadir2.ly | 0 .../subdir_datadir2}/img/datadir2.png | Bin 22 files changed, 9 insertions(+), 53 deletions(-) delete mode 100644 examples/example-subdir.sb delete mode 100644 examples/img/datadir.png delete mode 100644 examples/root.ly delete mode 100644 examples/root.png delete mode 100644 examples/songs/subdir/relative.png delete mode 100644 examples/songs/subdir/root.sg delete mode 100644 examples/songs/subdir/root.sgc rename {examples => patacrep/data}/img/treble_a.png (100%) create mode 100644 test/test_compilation/.gitignore create mode 100644 test/test_compilation/subdir.sb rename {examples => test/test_compilation/subdir_datadir}/img/datadir.ly (100%) create mode 100644 test/test_compilation/subdir_datadir/img/datadir.png rename {examples/songs/subdir => test/test_compilation/subdir_datadir/songs}/datadir.sg (100%) rename {examples/songs/subdir => test/test_compilation/subdir_datadir/songs}/datadir.sgc (100%) rename {examples/songs/subdir => test/test_compilation/subdir_datadir/songs}/datadir2.sg (100%) rename {examples/songs/subdir => test/test_compilation/subdir_datadir/songs}/datadir2.sgc (100%) rename {examples/songs/subdir => test/test_compilation/subdir_datadir/songs}/relative.ly (100%) create mode 100644 test/test_compilation/subdir_datadir/songs/relative.png rename {examples/songs/subdir => test/test_compilation/subdir_datadir/songs}/relative.sg (100%) rename {examples/songs/subdir => test/test_compilation/subdir_datadir/songs}/relative.sgc (100%) rename {examples/datadir2 => test/test_compilation/subdir_datadir2}/img/datadir2.ly (100%) rename {examples/datadir2 => test/test_compilation/subdir_datadir2}/img/datadir2.png (100%) diff --git a/examples/example-subdir.sb b/examples/example-subdir.sb deleted file mode 100644 index b1c93e9f..00000000 --- a/examples/example-subdir.sb +++ /dev/null @@ -1,18 +0,0 @@ -{ -"bookoptions" : [ - "diagram", - "repeatchords", - "lilypond", - "pictures" - ], -"datadir": ["datadir2"], -"booktype" : "chorded", -"template" : "patacrep.tex", -"lang" : "french", -"encoding": "utf8", -"authwords" : { - "sep" : ["and", "et"] - }, - "content": [["sorted", "subdir/*.sg", "subdir/*.sgc"]] - -} diff --git a/examples/img/datadir.png b/examples/img/datadir.png deleted file mode 100644 index e2efe4090f86b7660f3979865031caf604943e82..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 645 zcmV;00($+4P)e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00HeuL_t(o!|j+mO9Md^g+D=! zk6u5d!KDu&}aJEJS>P5BveP`U@;X$PWD82DHh`zW|hgmKs8I)z$j94YA93oOiWN z)l2;=z|RZ6V{n_oEz}UAtFG3+>&9{hbZVRGl=@SE&kH|daDBi}l}F!pJy%_=f0qzn zfU#QMQ4>->H@K|D(ITr@Pot~xZ~Hi>js~*Xf~%R%Hgz^L#gIeKp7p+Jk5SPb#600000NkvXXu0mjfLbVnn diff --git a/examples/root.ly b/examples/root.ly deleted file mode 100644 index 1fd2bccb..00000000 --- a/examples/root.ly +++ /dev/null @@ -1,19 +0,0 @@ -\include "_lilypond/header" -\paper{paper-height = 6.5\cm} - -{ - \key a \minor - \time 6/8 - \partial 8 a'8 - \relative c''{ - c4 d8 e8. (f16) e8 d4 b8 g8. (a16) b8 - c4 a8 a8. (gis16) a8 b4 gis8 e4 a8 - c4 d8 e8. (f16 e8) d4 b8 g8. (a16) b8 - c8. (b16) a8 gis8. (fis16) gis8 a4 a8 a4. - - g'4. g8. (fis16) e8 d4 b8 g8. (a16) b8 - c4 (a8) a8. (gis16) a8 b4 gis8 e4. - g'4. g8. (fis16) e8 d4 b8 g8. (a16) b8 - c8. (b16) a8 gis8. (fis16) gis8 a4. a4. - } -} diff --git a/examples/root.png b/examples/root.png deleted file mode 100644 index 70ea3b7c9a4ed2d588df4d3a04ea3cffc8434609..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 513 zcmV+c0{;DpP)e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00C)9L_t(o!|j&6N(3w;dZ>1O^`8K$=ir za8kcm0FD*AwQOt#=ok1^pb2Ea3UDK?FKwvLb+bxczar)o`?l!!#64?MCYr#DG`kUe z(UW?!=r6^sd*ZJ|^*gcX-^I;)=ImGwrLHe1DRW#oHZT@H<(ab~%{YQD zT2i0DnnPda#M?FhR6FEPO6FUc%EV@U1yPk!+hBm|()O?HBSFERGZPo8d z<=8|f&Q<-Y`l408hDvV^>{u3m6?d&3lc~2XD`x9Ab$!v2LJQ@e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00HeuL_t(o!|j*7OB_KQhMz6M zX(C#PCI&5SLg2vCO3^C)6(Wj)A4wOB5Rl|gNFjo);1?-^t@e`RFsGzB8@>NP{2;k- z5zX1W2g9+q+4W}DW?op>eShzMJv%cy172QUUS4Ua*0B8s3cy5ya~ij>Y+Pl4bKnAK zOL*UA&(U~%tm9n7bL5mcdf3wy3F94ftwfh7%V4 zVEmnf6u_><0K4W0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)T)a^`8Re)@}jcbIk&aE)7E zLFRGT^<-rv2`l$md9QTD`7DXD0@=z+mIcT>yetlI*ddRrnSop%lrT;_B^13%&yn+J zBTJhweFJ6oGX3N1t)Tle05{in6pTSuPZ-~|BMEYpZ|6qr*7@obp~tY>$E*z{+=WKX zTqw&Ctsx1HUdt)qGy$5og zz&I|W-?MP<*6;d)d+$Fa3JJ3q@yzCV4i4@mmldp}nKYZuDd}5|mCHGmMf+Bh@ma|? z$803DfHP4nI(&>>>rIh#QI%~RUGh+sIap>Q1#V>XAju7*sdsY7Im5~+ta3T76!D~r zdr!yg<88hM`wu@P%}{X^t{wmY03~!qSaf7zbY(hYa%Ew3WdJfTF*PkQFfB1SR5CL< zFg7|dI4dwRIxsM#)R_|i001R)MObuXVRU6WZEs|0W_bWIFflbPF)%GLI8-t-Ixsdm zF*qwQGCD9Y)rldm0000KbVXQnaAamWR%LQ?X>V=-P((&8F)lSA1zZa`00000NkvXX Hu0mjfWkHmC literal 0 HcmV?d00001 diff --git a/examples/songs/subdir/datadir.sg b/test/test_compilation/subdir_datadir/songs/datadir.sg similarity index 100% rename from examples/songs/subdir/datadir.sg rename to test/test_compilation/subdir_datadir/songs/datadir.sg diff --git a/examples/songs/subdir/datadir.sgc b/test/test_compilation/subdir_datadir/songs/datadir.sgc similarity index 100% rename from examples/songs/subdir/datadir.sgc rename to test/test_compilation/subdir_datadir/songs/datadir.sgc diff --git a/examples/songs/subdir/datadir2.sg b/test/test_compilation/subdir_datadir/songs/datadir2.sg similarity index 100% rename from examples/songs/subdir/datadir2.sg rename to test/test_compilation/subdir_datadir/songs/datadir2.sg diff --git a/examples/songs/subdir/datadir2.sgc b/test/test_compilation/subdir_datadir/songs/datadir2.sgc similarity index 100% rename from examples/songs/subdir/datadir2.sgc rename to test/test_compilation/subdir_datadir/songs/datadir2.sgc diff --git a/examples/songs/subdir/relative.ly b/test/test_compilation/subdir_datadir/songs/relative.ly similarity index 100% rename from examples/songs/subdir/relative.ly rename to test/test_compilation/subdir_datadir/songs/relative.ly diff --git a/test/test_compilation/subdir_datadir/songs/relative.png b/test/test_compilation/subdir_datadir/songs/relative.png new file mode 100644 index 0000000000000000000000000000000000000000..7c1aecc395b92fc007b746e17f75af983b78fc31 GIT binary patch literal 4036 zcmV;#4?FOQP)FEKql{wtqdX2DW{OMGLQqrdU!*PL%G`kLeG&0TsG3IH4_`UejGf&Y8&vQ#*N z^w_A#Y^G0gRC-pJAd;E3+zB3+%k&f^N5v*Y{!sA0O8y6>M`oulM{aV;20?6eOgi)b z4mC0`Gz8yg@z(2Wk0D0?|ITMw-@W8|0NAqtAbY-h;gtY%?f^jg@pn&csjrlL06OmQ zGX$C6Jk;`r1_VF>bRYv1fhy1hy1)pS0ZU*D9Dob(0KOmytOI-y0}_D%WPx0;4HSSP zum|i1RiG9$fF{riPJ>Qx9$W#}!EJCC41*^?2qwTQAOi2fJOn{lhz!vn8Au6Ihjbt# zhz(go4v-t<4Fy4=P&AYTWk9*mcBlv{g{q)Bs0sQ7ItN{WZbF05BWMhohW>^=!3a!( z>97K<0qetTm;<}QzVKQ&8cv0C;Cy&DTmjd^C*ThF3Va(LhK2AecoqQ&5n&+8h%UlL zxQGW5j6@*E7FbhA@>j=GJ||XVNf&_6Qzr?L^-4UP<&J>YBQ=BRfRf^ z>Ol3P?xDs|BGeZ&87+_2L0h1C=sLMXXw^Lu^RwH3d&mr*J6iC^?jJ${ETX%8WQ( zTtl2I9wxq7yjuL6_=xzd1Wm$F!b2iaqFAC?;-PyQEsBhNR}C<)m$;Bc%(a+oXr3Kglp<9Ax5U_R4h1Je5VsYRh`bX2~9s zy(T*&N0+mdKO)~RKdYdq;G~eEP^oZLVMdXmXsZ~fSf+SU zaaxI{WUUmdRHk%E=_ON=$zdiiE111Zk+Qt9vvP)Vo$`S4yb4RjPbE*KP35U7L6xl< zrCO%iqbgEUQgc_!Rcldutd3V_tH-DxQ14Tp(_m=?XzbMJ)RnwbhrTTQ3U)XYN7YRpF1bhanEn0><> zZE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%ZEN zE%f7j-?NdJ9!db@7NU0)quT&KXMlw0#!F3A4Pa!9jVLMTnsyo>xv<~~s;yqdo)M^q zGqyUl6O)M)KrqI}n^-Wb9gr-_?GK&?J*@qh+bN>IN9r8PE(6Fhx^7I)HIvnP-cG`U zc7mlb#9NwgPU{c2@h*@p0GSa7Bni?zNqX1&nnD4tJxr(bPJ*i$M~#94ytdEyuNa^9 z^DHW60y}__X$In8=B`ENeKK(xfdQ7@AlLISE+2+(#b14#(WXlG(WrKji1Xbfn#Aa{ z%S;Ai=}%csqK-3=*D=OqwsYiYU>u1W>0!oFeMrjL=^8LZy@1R~i~juFrmrDdOMmJM za&W5WxB$Rb=wl|X3QTKaQ>Ift&$IR@dm`G;+w+XtW`>6~bn^;)KMm$u2FL7S#>#ec zc^+fT7CyH+=7setj*6I>U_a1PeMYC7Nh%}m=h>x9U3=*rvmt{fh~9A4KjvwvG$}+m zy#N3JC3HntbYx+4WjbSWWnpw>05UK!H7zkPEipJ$GBY|bH##seD=;!TFfbA%w_pGO z03~!qSaf7zbY(hiZ)9m^c>ppnF*PkQFfB1SR5CL6WpZ0000 Date: Mon, 19 Oct 2015 00:15:58 +0200 Subject: [PATCH 02/32] [test] Add compilation tests --- .../{songbook.py => songbook/__main__.py} | 5 +- setup.py | 2 +- songbook | 7 +- test/dynamic.py | 25 +++ test/test_chordpro/test_parser.py | 39 ++-- test/test_compilation/__init__.py | 0 test/test_compilation/subdir.tex.control | 180 ++++++++++++++++++ test/test_compilation/test_compilation.py | 89 +++++++++ 8 files changed, 318 insertions(+), 29 deletions(-) rename patacrep/{songbook.py => songbook/__main__.py} (97%) create mode 100644 test/dynamic.py create mode 100644 test/test_compilation/__init__.py create mode 100644 test/test_compilation/subdir.tex.control create mode 100644 test/test_compilation/test_compilation.py diff --git a/patacrep/songbook.py b/patacrep/songbook/__main__.py similarity index 97% rename from patacrep/songbook.py rename to patacrep/songbook/__main__.py index 71340cae..8ce858a5 100644 --- a/patacrep/songbook.py +++ b/patacrep/songbook/__main__.py @@ -39,7 +39,10 @@ class VerboseAction(argparse.Action): def argument_parser(args): """Parse arguments""" - parser = argparse.ArgumentParser(description="A song book compiler") + parser = argparse.ArgumentParser( + prog="songbook", + description="A song book compiler", + ) parser.add_argument( '--version', help='Show version', action='version', diff --git a/setup.py b/setup.py index f9977913..4cfaeda0 100755 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ setup( include_package_data=True, entry_points={ 'console_scripts': [ - "songbook = patacrep.songbook:main", + "songbook = patacrep.songbook.__main__:main", ], }, classifiers=[ diff --git a/songbook b/songbook index 80e12f88..f4850774 100755 --- a/songbook +++ b/songbook @@ -1,9 +1,6 @@ -#! /usr/bin/env python3 +#! /bin/sh # Do not edit this file. This file is just a helper file for development test. # It is not part of the distributed software. -"""Command line tool to compile songbooks using the songbook library.""" - -from patacrep.songbook import main -main() +python -m patacrep.songbook $* diff --git a/test/dynamic.py b/test/dynamic.py new file mode 100644 index 00000000..19b721a3 --- /dev/null +++ b/test/dynamic.py @@ -0,0 +1,25 @@ +"""Dynamic creation of test methods.""" + +class DynamicTest(type): + """Metaclass that creates on-the-fly test methods. + + Each class implementing this metaclass must define two class methods: + + - `_iter_testmethods`, which iterate over `(methodname, args)`, where + `methodname` is the name of a test method to create, and `args` is a list + of arguments to pass to `_create_test`; + - `_create_test`, a method returning a test method. + """ + + def __init__(cls, name, bases, nmspc): + super().__init__(name, bases, nmspc) + for methodname, args in cls._iter_testmethods(): + setattr(cls, methodname, cls._create_test(*args)) + + def _iter_testmethods(cls): + """Iterate over test methods.""" + raise NotImplementedError() + + def _create_test(cls, *args, **kwargs): + """Create and return a test method.""" + raise NotImplementedError() diff --git a/test/test_chordpro/test_parser.py b/test/test_chordpro/test_parser.py index 20cafd38..b0760fa8 100644 --- a/test/test_chordpro/test_parser.py +++ b/test/test_chordpro/test_parser.py @@ -10,6 +10,7 @@ from patacrep.build import DEFAULT_CONFIG from patacrep.songs.chordpro import ChordproSong from .. import disable_logging +from .. import dynamic # pylint: disable=unused-import LANGUAGES = { 'tex': 'latex', @@ -17,15 +18,22 @@ LANGUAGES = { 'html': 'html', } -class FileTestMeta(type): - """Metaclass that creates on-the-fly test function according to files. +class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): + """Test of chorpro parser, and several renderers. + + For any given `foo.source`, it is parsed as a chordpro file, and should be + rendered as `foo.sgc` with the chordpro renderer, and `foo.tex` with the + latex renderer. - See the :class:`FileTest` documentation for more information. + This class does nothing by itself, but its metaclass populates it with test + methods testing parser and renderers. """ - def __init__(cls, name, bases, nmspc): - super().__init__(name, bases, nmspc) + maxDiff = None + @classmethod + def _iter_testmethods(cls): + """Iterate over song files to test.""" for source in sorted(glob.glob(os.path.join( os.path.dirname(__file__), '*.source', @@ -35,14 +43,13 @@ class FileTestMeta(type): destname = "{}.{}".format(base, dest) if not os.path.exists(destname): continue - setattr( - cls, + yield ( "test_{}_{}".format(os.path.basename(base), dest), - cls._create_test(base, dest), + [base, dest], ) - @staticmethod - def _create_test(base, dest): + @classmethod + def _create_test(cls, base, dest): """Return a function testing that `base` compilation in `dest` format. """ @@ -67,15 +74,3 @@ class FileTestMeta(type): ).format(base=os.path.basename(base), format=dest) return test_parse_render -class FileTest(unittest.TestCase, metaclass=FileTestMeta): - """Test of chorpro parser, and several renderers. - - For any given `foo.source`, it is parsed as a chordpro file, and should be - rendered as `foo.sgc` with the chordpro renderer, and `foo.tex` with the - latex renderer. - - This class does nothing by itself, but its metaclass populates it with test - methods testing parser and renderers. - """ - - maxDiff = None diff --git a/test/test_compilation/__init__.py b/test/test_compilation/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/test/test_compilation/subdir.tex.control b/test/test_compilation/subdir.tex.control new file mode 100644 index 00000000..c026fa96 --- /dev/null +++ b/test/test_compilation/subdir.tex.control @@ -0,0 +1,180 @@ + + + + + + +%% Automatically generated document. +%% You may edit this file but all changes will be overwritten. +%% If you want to change this document, have a look at +%% the templating system. +%% +%% Generated using Songbook + +\makeatletter +\def\input@path{ % + {/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/latex/} % + {/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir2/latex/} % + {/home/louis/projets/patacrep/patacrep/test/test_compilation/latex/} % + {/home/louis/projets/patacrep/patacrep/patacrep/data/latex/} % +} +\makeatother + +\documentclass[ + ]{article} + +\usepackage[ + chorded, +lilypond, +pictures, +guitar, + ]{patacrep} + +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +\usepackage{lmodern} + + +\PassOptionsToPackage{french}{babel} +\usepackage[english]{babel} +\lang{english} + +\usepackage{graphicx} +\graphicspath{ % + {/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/img/} % + {/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir2/img/} % + {/home/louis/projets/patacrep/patacrep/test/test_compilation/img/} % + {/home/louis/projets/patacrep/patacrep/patacrep/data/img/} % +} + + +\makeatletter +\@ifpackageloaded{hyperref}{}{ + \usepackage{url} + \newcommand{\phantomsection}{} + \newcommand{\hyperlink}[2]{#2} + \newcommand{\href}[2]{\expandafter\url\expandafter{#1}} +} +\makeatother + + +\usepackage{chords} + +\title{Guitar songbook} +\author{The Patacrep Team} + +\newindex{titleidx}{subdir_title} +\newauthorindex{authidx}{subdir_auth} + + +\notenamesout{A}{B}{C}{D}{E}{F}{G} + + +\begin{document} + +\maketitle + + +\showindex{\songindexname}{titleidx} +\showindex{\authorindexname}{authidx} + +% list of chords +\ifchorded + \ifdiagram + \phantomsection + \addcontentsline{toc}{section}{\chordlistname} + \chords + \fi +\fi + +\phantomsection +\addcontentsline{toc}{section}{\songlistname} + +\begin{songs}{titleidx,authidx} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% songs/./datadir2.sgc + +\selectlanguage{french} + +\beginsong{Image included from a different datadir\\ +Chordpro}[ + by={ + }, + cov={/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir2/img/datadir2.png}, +] + +\cover + + + +\lilypond{datadir2.ly} +\image{/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir2/img/datadir2.png} + + +\endsong + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% songs/./datadir2.sg + +\import{subdir_datadir/songs/}{datadir2.sg} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% songs/./relative.sgc + +\selectlanguage{french} + +\beginsong{Image included from song directory\\ +Chordpro}[ + by={ + }, + cov={/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/relative.png}, +] + +\cover + + + +\lilypond{/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/relative.ly} +\image{/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/relative.png} + + +\endsong + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% songs/./datadir.sgc + +\selectlanguage{french} + +\beginsong{Image included from datadir\\ +Chordpro}[ + by={ + }, + cov={/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/img/datadir.png}, +] + +\cover + + + +\lilypond{datadir.ly} +\image{/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/img/datadir.png} + + +\endsong + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% songs/./relative.sg + +\import{subdir_datadir/songs/}{relative.sg} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% songs/./datadir.sg + +\import{subdir_datadir/songs/}{datadir.sg} + +\end{songs} + + + + +\end{document} \ No newline at end of file diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py new file mode 100644 index 00000000..374396f1 --- /dev/null +++ b/test/test_compilation/test_compilation.py @@ -0,0 +1,89 @@ +"""Tests for the chordpro parser.""" + +# pylint: disable=too-few-public-methods + +import glob +import os +import subprocess +import unittest + +from .. import dynamic # pylint: disable=unused-import + + +class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): + """Test of songbook compilation. + + For any given `foo.sb`, it performs several checks: + - the corresponding tex file is generated; + - the generated tex file matches the `foo.tex.control` control file; + - the compilation (tex, pdf, indexes) works without errors. + + This class does nothing by itself, but its metaclass populates it with test + methods testing parser and renderers. + """ + + maxDiff = None + + @classmethod + def _iter_testmethods(cls): + """Iterate over songbook files to test.""" + for songbook in sorted(glob.glob(os.path.join( + os.path.dirname(__file__), + '*.sb', + ))): + base = songbook[:-len(".sb")] + control = "{}.tex.control".format(base) + if not os.path.exists(control): + continue + yield ( + "test_{}".format(os.path.basename(base)), + [base], + ) + + @classmethod + def _create_test(cls, base): + """Return a function testing that `base` compiles.""" + + def test_compile(self): + """Test that `base` is correctly compiled.""" + if base is None: + return + + songbook = "{}.sb".format(base) + + # Check tex generation + self.assertEqual(0, self.compile_songbook(songbook, "tex")) + + # Check generated tex + control = "{}.tex.control".format(base) + tex = "{}.tex".format(base) + with open(control, 'r', encoding='utf8') as expectfile: + with open(tex, 'r', encoding='utf8') as latexfile: + self.assertMultiLineEqual( + latexfile.read(), + expectfile.read(), + ) + + # Check compilation + self.assertEqual(0, self.compile_songbook(songbook)) + + test_compile.__doc__ = ( + "Test that '{base}' is correctly compiled." + ).format(base=os.path.basename(base)) + return test_compile + + @staticmethod + def compile_songbook(songbook, steps=None): + """Compile songbook, and return the command return code.""" + command = ['python', '-m', 'patacrep.songbook', songbook] + if steps: + command.extend(['--steps', steps]) + + return subprocess.check_call( + command, + stdin=subprocess.DEVNULL, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + cwd=os.path.dirname(songbook), + ) + From 9c715f187e99bb675e75008b58785660ec592a1c Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 13:58:28 +0200 Subject: [PATCH 03/32] Use language code everywhere --- examples/example-crepbook.sb | 2 +- examples/example-layout.sb | 2 +- examples/example-songs.sb | 2 +- examples/example.sb | 2 +- examples/example_encoding.sb | 2 +- patacrep/data/templates/default.tex | 16 +++++------ patacrep/data/templates/patacrep.tex | 24 ++++++++--------- patacrep/data/templates/songs.tex | 40 ++++++++++++++-------------- 8 files changed, 45 insertions(+), 45 deletions(-) diff --git a/examples/example-crepbook.sb b/examples/example-crepbook.sb index dcb27587..9c2a636c 100644 --- a/examples/example-crepbook.sb +++ b/examples/example-crepbook.sb @@ -7,7 +7,7 @@ "pictures" ], "booktype" : "chorded", -"lang" : "french", +"lang" : "fr", "authwords" : { "sep" : ["and", "et"] }, diff --git a/examples/example-layout.sb b/examples/example-layout.sb index e252ed5d..4c486924 100644 --- a/examples/example-layout.sb +++ b/examples/example-layout.sb @@ -7,7 +7,7 @@ "pictures" ], "booktype" : "chorded", -"lang" : "french", +"lang" : "fr", "authwords" : { "sep" : ["and", "et"] }, diff --git a/examples/example-songs.sb b/examples/example-songs.sb index 40ed8ebc..3a46716c 100644 --- a/examples/example-songs.sb +++ b/examples/example-songs.sb @@ -7,7 +7,7 @@ "pictures" ], "booktype" : "chorded", -"lang" : "french", +"lang" : "fr", "authwords" : { "sep" : ["and", "et"] }, diff --git a/examples/example.sb b/examples/example.sb index a003440e..55b489ad 100644 --- a/examples/example.sb +++ b/examples/example.sb @@ -6,7 +6,7 @@ "pictures" ], "booktype" : "chorded", -"lang" : "french", +"lang" : "fr", "authwords" : { "sep" : ["and", "et"] }, diff --git a/examples/example_encoding.sb b/examples/example_encoding.sb index 0519b144..bd3a63d9 100644 --- a/examples/example_encoding.sb +++ b/examples/example_encoding.sb @@ -6,7 +6,7 @@ "pictures" ], "booktype" : "chorded", -"lang" : "french", +"lang" : "fr", "authwords" : { "sep" : ["and", "et", "À"], "ignore" : ["À"], diff --git a/patacrep/data/templates/default.tex b/patacrep/data/templates/default.tex index 65c56c8f..a9504965 100644 --- a/patacrep/data/templates/default.tex +++ b/patacrep/data/templates/default.tex @@ -20,23 +20,23 @@ (* variables *) { -"classoptions": {"description": {"english": "LaTeX class options", "french": "Options de la classe LaTeX"}, +"classoptions": {"description": {"en": "LaTeX class options", "fr": "Options de la classe LaTeX"}, "type": "flag", "join": ",", "mandatory": true, "default": {"default":[]} }, -"title": {"description": {"english": "Title", "french": "Titre"}, - "default": {"english": "Guitar songbook", "french": "Recueil de chansons pour guitare"}, +"title": {"description": {"en": "Title", "fr": "Titre"}, + "default": {"en": "Guitar songbook", "fr": "Recueil de chansons pour guitare"}, "mandatory":true }, -"author": {"description": {"english": "Author", "french": "Auteur"}, - "default": {"english": "The Patacrep Team", "french": "L'équipe Patacrep"}, +"author": {"description": {"en": "Author", "fr": "Auteur"}, + "default": {"en": "The Patacrep Team", "fr": "L'équipe Patacrep"}, "mandatory":true }, -"notenamesout": {"description": {"english": "Note names. Can be 'solfedge' (Do, Re, Mi...) or 'alphascale' (A, B, C...).", - "french": "Nom des notes : 'solfedge' (Do, Ré, Mi...) ou 'alphascale' (A, B, C...)."}, - "default": {"default": "alphascale", "french": "solfedge"} +"notenamesout": {"description": {"en": "Note names. Can be 'solfedge' (Do, Re, Mi...) or 'alphascale' (A, B, C...).", + "fr": "Nom des notes : 'solfedge' (Do, Ré, Mi...) ou 'alphascale' (A, B, C...)."}, + "default": {"default": "alphascale", "fr": "solfedge"} } } (* endvariables -*) diff --git a/patacrep/data/templates/patacrep.tex b/patacrep/data/templates/patacrep.tex index 50dacf5e..b9a01f1e 100644 --- a/patacrep/data/templates/patacrep.tex +++ b/patacrep/data/templates/patacrep.tex @@ -20,42 +20,42 @@ (* variables *) { -"subtitle": {"description": {"english": "Subtitle", "french": "Sous-titre"}, +"subtitle": {"description": {"en": "Subtitle", "fr": "Sous-titre"}, "default": {"default": ""} }, -"version":{ "description": {"english": "Version", "french": "Version"}, +"version":{ "description": {"en": "Version", "fr": "Version"}, "default": {"default": "undefined"} }, -"web": {"description": {"english": "Website", "french": "Site web"}, +"web": {"description": {"en": "Website", "fr": "Site web"}, "default": {"default": "http://www.patacrep.com"} }, -"mail": {"description": {"english": "Email", "french": "Adresse électronique"}, +"mail": {"description": {"en": "Email", "fr": "Adresse électronique"}, "default": {"default": "crep@team-on-fire.com"} }, -"picture": {"description": {"english": "Cover picture", "french": "Image de couverture"}, +"picture": {"description": {"en": "Cover picture", "fr": "Image de couverture"}, "type": "file", "default": {"default": "img/treble_a"} }, -"picturecopyright": {"description": {"english": "Copyright for the cover picture", "french": "Copyright pour l'image de couverture"}, +"picturecopyright": {"description": {"en": "Copyright for the cover picture", "fr": "Copyright pour l'image de couverture"}, "default": {"default": "Dbolton \\url{http://commons.wikimedia.org/wiki/User:Dbolton}"} }, -"footer": {"description": {"english": "Footer", "french": "Pied de page"}, +"footer": {"description": {"en": "Footer", "fr": "Pied de page"}, "default": {"default": "Generated using Songbook (\\url{http://www.patacrep.com})"} }, -"songnumberbgcolor": {"description": {"english": "Number Shade", "french": "Couleur des numéros"}, +"songnumberbgcolor": {"description": {"en": "Number Shade", "fr": "Couleur des numéros"}, "type": "color", "default": {"default": "D1E4AE"} }, -"notebgcolor": {"description": {"english": "Note Shade", "french": "Couleur des notes"}, +"notebgcolor": {"description": {"en": "Note Shade", "fr": "Couleur des notes"}, "type": "color", "default": {"default": "D1E4AE"} }, -"indexbgcolor": {"description": {"english": "Index Shade", "french": "Couleur d'index"}, +"indexbgcolor": {"description": {"en": "Index Shade", "fr": "Couleur d'index"}, "type": "color", "default": {"default": "D1E4AE"} }, -"titleprefixwords": {"description": {"english": "Ignore some words in the beginning of song titles", - "french": "Ignore des mots dans le classement des chansons"}, +"titleprefixwords": {"description": {"en": "Ignore some words in the beginning of song titles", + "fr": "Ignore des mots dans le classement des chansons"}, "default": {"default": ["The", "Le", "La", "L'", "A", "Au", "Ces", "De", "Des", "El", "Les", "Ma", "Mon", "Un"]} } diff --git a/patacrep/data/templates/songs.tex b/patacrep/data/templates/songs.tex index 741b5d39..6a070fe8 100644 --- a/patacrep/data/templates/songs.tex +++ b/patacrep/data/templates/songs.tex @@ -20,46 +20,46 @@ (* variables *) { -"instruments": {"description": {"english": "Instruments", "french": "Instruments"}, +"instruments": {"description": {"en": "Instruments", "fr": "Instruments"}, "type": "flag", - "values": {"guitar": {"english": "Guitare", "french": "Guitare"}, - "ukulele": {"english": "Ukulele", "french": "Ukulele"} + "values": {"guitar": {"en": "Guitare", "fr": "Guitare"}, + "ukulele": {"en": "Ukulele", "fr": "Ukulele"} }, "join": ",", "mandatory": true, "default": {"default":["guitar"]} }, -"bookoptions": {"description": {"english": "Options", "french": "Options"}, +"bookoptions": {"description": {"en": "Options", "fr": "Options"}, "type": "flag", - "values": {"diagram": {"english": "Chords diagrams", "french": "Diagrammes d'accords"}, - "importantdiagramonly": {"english": "Only importants diagrames", "french": "Diagrammes importants uniquement"}, - "lilypond": {"english": "Lilypond music sheets", "french": "Partitions lilypond"}, - "pictures": {"english": "Cover pictures", "french": "Couvertures d'albums"}, - "tabs": {"english": "Tablatures", "french": "Tablatures"}, - "repeatchords": {"english": "Repeat chords", "french": "Répéter les accords"}, - "onesongperpage": {"english": "One song per page", "french": "Une chanson par page"} + "values": {"diagram": {"en": "Chords diagrams", "fr": "Diagrammes d'accords"}, + "importantdiagramonly": {"en": "Only importants diagrames", "fr": "Diagrammes importants uniquement"}, + "lilypond": {"en": "Lilypond music sheets", "fr": "Partitions lilypond"}, + "pictures": {"en": "Cover pictures", "fr": "Couvertures d'albums"}, + "tabs": {"en": "Tablatures", "fr": "Tablatures"}, + "repeatchords": {"en": "Repeat chords", "fr": "Répéter les accords"}, + "onesongperpage": {"en": "One song per page", "fr": "Une chanson par page"} }, "join": ",", "mandatory": true, "default": {"default":["diagram","pictures"]} }, -"booktype": {"description": {"english": "Type", "french": "Type"}, +"booktype": {"description": {"en": "Type", "fr": "Type"}, "type": "enum", - "values": {"chorded": {"english": "With guitar chords", "french": "Avec accords de guitare" }, - "lyric": {"english": "Lyrics only", "french": "Paroles uniquement"} + "values": {"chorded": {"en": "With guitar chords", "fr": "Avec accords de guitare" }, + "lyric": {"en": "Lyrics only", "fr": "Paroles uniquement"} }, "default": {"default":"chorded"}, "mandatory": true }, -"lang": {"description": {"english": "Language", "french": "Langue"}, - "default": {"english": "en", "french": "fr"} +"lang": {"description": {"en": "Language", "fr": "Langue"}, + "default": {"en": "en", "fr": "fr"} }, -"titleprefixwords": {"description": {"english": "Ignore some words in the beginning of song titles", - "french": "Ignore des mots dans le classement des chansons"}, +"titleprefixwords": {"description": {"en": "Ignore some words in the beginning of song titles", + "fr": "Ignore des mots dans le classement des chansons"}, "default": {"default": []} }, -"authwords": {"description": {"english": "Set of options to process author string (LaTeX commands authsepword, authignoreword, authbyword)", - "french": "Options pour traiter les noms d'auteurs (commandes LaTeX authsepword, authignoreword, authbyword)"}, +"authwords": {"description": {"en": "Set of options to process author string (LaTeX commands authsepword, authignoreword, authbyword)", + "fr": "Options pour traiter les noms d'auteurs (commandes LaTeX authsepword, authignoreword, authbyword)"}, "default": {"default": {}} } } From 4f5027ab6e7b3afd22a0c34c6ab73c4cc5663e0c Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 14:02:05 +0200 Subject: [PATCH 04/32] Fix song lang problems --- test/test_compilation/subdir.tex.control | 4 ++-- test/test_compilation/subdir_datadir/songs/datadir2.sgc | 1 + test/test_compilation/subdir_datadir/songs/relative.sgc | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test_compilation/subdir.tex.control b/test/test_compilation/subdir.tex.control index 6d0e308d..ffe1023b 100644 --- a/test/test_compilation/subdir.tex.control +++ b/test/test_compilation/subdir.tex.control @@ -35,8 +35,8 @@ guitar, \usepackage{lmodern} -\PassOptionsToPackage{french}{babel} \PassOptionsToPackage{english}{babel} +\PassOptionsToPackage{french}{babel} \usepackage[english]{babel} \lang{english} @@ -144,7 +144,7 @@ Chordpro}[ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% songs/./datadir.sgc -\selectlanguage{french} +\selectlanguage{english} \beginsong{Image included from datadir\\ Chordpro}[ diff --git a/test/test_compilation/subdir_datadir/songs/datadir2.sgc b/test/test_compilation/subdir_datadir/songs/datadir2.sgc index b83122d4..e9f43eed 100644 --- a/test/test_compilation/subdir_datadir/songs/datadir2.sgc +++ b/test/test_compilation/subdir_datadir/songs/datadir2.sgc @@ -1,6 +1,7 @@ {title : Image included from a different datadir} {subtitle: Chordpro} {cover: datadir2.png} +{lang: fr} {partition: datadir2.ly} {image: datadir2.png} diff --git a/test/test_compilation/subdir_datadir/songs/relative.sgc b/test/test_compilation/subdir_datadir/songs/relative.sgc index 73241352..0d6fddd1 100644 --- a/test/test_compilation/subdir_datadir/songs/relative.sgc +++ b/test/test_compilation/subdir_datadir/songs/relative.sgc @@ -1,6 +1,7 @@ {title : Image included from song directory} {subtitle: Chordpro} {cover: relative.png} +{lang: fr} {partition: relative.ly} {image: relative.png} From b54ea1ea5c7773f8eefc0885c04468dcd7576360 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 14:05:32 +0200 Subject: [PATCH 05/32] Sort the babel languages (to be deterministic) --- patacrep/data/templates/songs.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patacrep/data/templates/songs.tex b/patacrep/data/templates/songs.tex index 6a070fe8..e3562897 100644 --- a/patacrep/data/templates/songs.tex +++ b/patacrep/data/templates/songs.tex @@ -80,7 +80,7 @@ (* block songbookpreambule *) (( super() )) -(* for lang in _langs -*) +(* for lang in _langs|sort -*) \PassOptionsToPackage{(( lang2babel(lang) ))}{babel} (* endfor *) \usepackage[(( lang2babel(lang) ))]{babel} From 88d97971d3cb4766cadf938f58553e468e31417c Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 14:50:49 +0200 Subject: [PATCH 06/32] Force consistent ordering of the datadir --- patacrep/content/song.py | 6 ++- test/test_compilation/subdir.tex.control | 54 ++++++++++++------------ 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/patacrep/content/song.py b/patacrep/content/song.py index 480583fa..b4247918 100755 --- a/patacrep/content/song.py +++ b/patacrep/content/song.py @@ -46,6 +46,10 @@ class SongRenderer(Content): song=self.song.render(output=context['filename']), ) + def __lt__(self, other): + """Order by song path""" + return self.song.fullpath < other.song.fullpath + #pylint: disable=unused-argument def parse(keyword, argument, contentlist, config): """Parse data associated with keyword 'song'. @@ -102,7 +106,7 @@ def parse(keyword, argument, contentlist, config): [item.fullpath for item in config['_songdir']], message='Ignoring "{name}": did not match any file in {paths}.', )) - return songlist + return sorted(songlist) CONTENT_PLUGINS = {'song': parse} diff --git a/test/test_compilation/subdir.tex.control b/test/test_compilation/subdir.tex.control index ffe1023b..cac3f9e5 100644 --- a/test/test_compilation/subdir.tex.control +++ b/test/test_compilation/subdir.tex.control @@ -93,23 +93,28 @@ guitar, \begin{songs}{titleidx,authidx} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./datadir2.sgc +%% songs/./datadir.sg -\selectlanguage{french} +\import{subdir_datadir/songs/}{datadir.sg} -\beginsong{Image included from a different datadir\\ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% songs/./datadir.sgc + +\selectlanguage{english} + +\beginsong{Image included from datadir\\ Chordpro}[ by={ }, - cov={img/datadir2.png}, + cov={img/datadir.png}, ] \cover -\lilypond{scores/datadir2.ly} -\image{img/datadir2.png} +\lilypond{scores/datadir.ly} +\image{img/datadir.png} \endsong @@ -120,59 +125,54 @@ Chordpro}[ \import{subdir_datadir/songs/}{datadir2.sg} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./relative.sgc +%% songs/./datadir2.sgc \selectlanguage{french} -\beginsong{Image included from song directory\\ +\beginsong{Image included from a different datadir\\ Chordpro}[ by={ }, - cov={/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/relative.png}, + cov={img/datadir2.png}, ] \cover -\lilypond{/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/relative.ly} -\image{/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/relative.png} +\lilypond{scores/datadir2.ly} +\image{img/datadir2.png} \endsong %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./datadir.sgc +%% songs/./relative.sg -\selectlanguage{english} +\import{subdir_datadir/songs/}{relative.sg} -\beginsong{Image included from datadir\\ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% songs/./relative.sgc + +\selectlanguage{french} + +\beginsong{Image included from song directory\\ Chordpro}[ by={ }, - cov={img/datadir.png}, + cov={/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/relative.png}, ] \cover -\lilypond{scores/datadir.ly} -\image{img/datadir.png} +\lilypond{/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/relative.ly} +\image{/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/relative.png} \endsong -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./relative.sg - -\import{subdir_datadir/songs/}{relative.sg} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./datadir.sg - -\import{subdir_datadir/songs/}{datadir.sg} - \end{songs} From 5694508dd8d0f890b6f1251f43286d56acdd86d6 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 14:57:05 +0200 Subject: [PATCH 07/32] The 'img' subfolder must be given in the directive --- test/test_compilation/subdir.tex.control | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_compilation/subdir.tex.control b/test/test_compilation/subdir.tex.control index cac3f9e5..6e3a2d90 100644 --- a/test/test_compilation/subdir.tex.control +++ b/test/test_compilation/subdir.tex.control @@ -42,10 +42,10 @@ guitar, \usepackage{graphicx} \graphicspath{ % - {/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/img/} % - {/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir2/img/} % - {/home/louis/projets/patacrep/patacrep/test/test_compilation/img/} % - {/home/louis/projets/patacrep/patacrep/patacrep/data/img/} % + {/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/} % + {/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir2/} % + {/home/louis/projets/patacrep/patacrep/test/test_compilation/} % + {/home/louis/projets/patacrep/patacrep/patacrep/data/} % } From 7438ec6ca1eb2999326d89468673ecb979f3bb5d Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 15:10:23 +0200 Subject: [PATCH 08/32] Add a missing . --- test/test_compilation/subdir.tex.control | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_compilation/subdir.tex.control b/test/test_compilation/subdir.tex.control index 6e3a2d90..c39bd82a 100644 --- a/test/test_compilation/subdir.tex.control +++ b/test/test_compilation/subdir.tex.control @@ -160,15 +160,15 @@ Chordpro}[ Chordpro}[ by={ }, - cov={/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/relative.png}, + cov={/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/./relative.png}, ] \cover -\lilypond{/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/relative.ly} -\image{/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/relative.png} +\lilypond{/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/./relative.ly} +\image{/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/./relative.png} \endsong From b1d7fa7a925b3f36ef3d7305c52b04241b3e9c62 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 15:25:02 +0200 Subject: [PATCH 09/32] Use a placeholder for the test folder --- test/test_compilation/subdir.tex.control | 22 +++++++++++----------- test/test_compilation/test_compilation.py | 6 ++++++ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/test/test_compilation/subdir.tex.control b/test/test_compilation/subdir.tex.control index c39bd82a..f3374e33 100644 --- a/test/test_compilation/subdir.tex.control +++ b/test/test_compilation/subdir.tex.control @@ -13,10 +13,10 @@ \makeatletter \def\input@path{ % - {/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/latex/} % - {/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir2/latex/} % - {/home/louis/projets/patacrep/patacrep/test/test_compilation/latex/} % - {/home/louis/projets/patacrep/patacrep/patacrep/data/latex/} % + {@TEST_FOLDER@/subdir_datadir/latex/} % + {@TEST_FOLDER@/subdir_datadir2/latex/} % + {@TEST_FOLDER@/latex/} % + {/home/travis/build/patacrep/patacrep/patacrep/data/latex/} % } \makeatother @@ -42,10 +42,10 @@ guitar, \usepackage{graphicx} \graphicspath{ % - {/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/} % - {/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir2/} % - {/home/louis/projets/patacrep/patacrep/test/test_compilation/} % - {/home/louis/projets/patacrep/patacrep/patacrep/data/} % + {@TEST_FOLDER@/subdir_datadir/} % + {@TEST_FOLDER@/subdir_datadir2/} % + {@TEST_FOLDER@/} % + {/home/travis/build/patacrep/patacrep/patacrep/data/} % } @@ -160,15 +160,15 @@ Chordpro}[ Chordpro}[ by={ }, - cov={/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/./relative.png}, + cov={@TEST_FOLDER@/subdir_datadir/songs/./relative.png}, ] \cover -\lilypond{/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/./relative.ly} -\image{/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/./relative.png} +\lilypond{@TEST_FOLDER@/subdir_datadir/songs/./relative.ly} +\image{@TEST_FOLDER@/subdir_datadir/songs/./relative.png} \endsong diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py index 9f2fde79..159a821b 100644 --- a/test/test_compilation/test_compilation.py +++ b/test/test_compilation/test_compilation.py @@ -89,3 +89,9 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): cwd=os.path.dirname(songbook), ) + def assertMultiLineEqual(self, result, expected): + """Replace the paths with the local paths""" + placeholder = "@TEST_FOLDER@" + localpath = os.path.dirname(__file__) + expected = expected.replace(placeholder, localpath) + return super().assertMultiLineEqual(result, expected) From 366dbd5d7ab5c1f7fbdde8d98f568af917f54d5c Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 15:30:02 +0200 Subject: [PATCH 10/32] Use a placeholder for the package folder --- test/test_compilation/subdir.tex.control | 4 ++-- test/test_compilation/test_compilation.py | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/test/test_compilation/subdir.tex.control b/test/test_compilation/subdir.tex.control index f3374e33..32656938 100644 --- a/test/test_compilation/subdir.tex.control +++ b/test/test_compilation/subdir.tex.control @@ -16,7 +16,7 @@ {@TEST_FOLDER@/subdir_datadir/latex/} % {@TEST_FOLDER@/subdir_datadir2/latex/} % {@TEST_FOLDER@/latex/} % - {/home/travis/build/patacrep/patacrep/patacrep/data/latex/} % + {@PACKAGE_FOLDER@/data/latex/} % } \makeatother @@ -45,7 +45,7 @@ guitar, {@TEST_FOLDER@/subdir_datadir/} % {@TEST_FOLDER@/subdir_datadir2/} % {@TEST_FOLDER@/} % - {/home/travis/build/patacrep/patacrep/patacrep/data/} % + {@PACKAGE_FOLDER@/data/} % } diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py index 159a821b..8d605c86 100644 --- a/test/test_compilation/test_compilation.py +++ b/test/test_compilation/test_compilation.py @@ -90,8 +90,15 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): ) def assertMultiLineEqual(self, result, expected): - """Replace the paths with the local paths""" + """Replace the placeholder paths with the local paths""" + placeholder = "@TEST_FOLDER@" localpath = os.path.dirname(__file__) expected = expected.replace(placeholder, localpath) + + import patacrep + placeholder = "@PACKAGE_FOLDER@" + localpath = os.path.dirname(patacrep.__file__) + expected = expected.replace(placeholder, localpath) + return super().assertMultiLineEqual(result, expected) From 83ec733d0807067a6abf45533050d5e874e5749d Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 15:38:09 +0200 Subject: [PATCH 11/32] Try to correctly resolve package path --- test/test_compilation/test_compilation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py index 8d605c86..4cdcdc64 100644 --- a/test/test_compilation/test_compilation.py +++ b/test/test_compilation/test_compilation.py @@ -8,6 +8,7 @@ import subprocess import unittest from patacrep.encoding import open_read +from pkg_resources import resource_filename from .. import dynamic # pylint: disable=unused-import @@ -98,7 +99,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): import patacrep placeholder = "@PACKAGE_FOLDER@" - localpath = os.path.dirname(patacrep.__file__) + localpath = os.path.abspath(resource_filename(patacrep.__name__, '')) expected = expected.replace(placeholder, localpath) return super().assertMultiLineEqual(result, expected) From 7fb4a1093c56b2d5fd7835491c38060d0059b80d Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 15:42:37 +0200 Subject: [PATCH 12/32] Lint compliance --- test/test_compilation/test_compilation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py index 4cdcdc64..62c76c09 100644 --- a/test/test_compilation/test_compilation.py +++ b/test/test_compilation/test_compilation.py @@ -90,7 +90,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): cwd=os.path.dirname(songbook), ) - def assertMultiLineEqual(self, result, expected): + def assertMultiLineEqual(self, result, expected, msg=None): """Replace the placeholder paths with the local paths""" placeholder = "@TEST_FOLDER@" @@ -102,4 +102,4 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): localpath = os.path.abspath(resource_filename(patacrep.__name__, '')) expected = expected.replace(placeholder, localpath) - return super().assertMultiLineEqual(result, expected) + return super().assertMultiLineEqual(result, expected, msg) From 1ec5caf788abe9cc2a06a2752ddc129e6d96da2c Mon Sep 17 00:00:00 2001 From: Louis Date: Thu, 22 Oct 2015 17:14:55 +0200 Subject: [PATCH 13/32] [test] Songs are in English --- test/test_compilation/subdir.tex.control | 5 ++--- test/test_compilation/subdir_datadir/songs/datadir.sgc | 1 + test/test_compilation/subdir_datadir/songs/datadir2.sgc | 2 +- test/test_compilation/subdir_datadir/songs/relative.sgc | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test_compilation/subdir.tex.control b/test/test_compilation/subdir.tex.control index 32656938..0f182f9a 100644 --- a/test/test_compilation/subdir.tex.control +++ b/test/test_compilation/subdir.tex.control @@ -36,7 +36,6 @@ guitar, \PassOptionsToPackage{english}{babel} -\PassOptionsToPackage{french}{babel} \usepackage[english]{babel} \lang{english} @@ -127,7 +126,7 @@ Chordpro}[ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% songs/./datadir2.sgc -\selectlanguage{french} +\selectlanguage{english} \beginsong{Image included from a different datadir\\ Chordpro}[ @@ -154,7 +153,7 @@ Chordpro}[ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% songs/./relative.sgc -\selectlanguage{french} +\selectlanguage{english} \beginsong{Image included from song directory\\ Chordpro}[ diff --git a/test/test_compilation/subdir_datadir/songs/datadir.sgc b/test/test_compilation/subdir_datadir/songs/datadir.sgc index a209c229..73a6a15f 100644 --- a/test/test_compilation/subdir_datadir/songs/datadir.sgc +++ b/test/test_compilation/subdir_datadir/songs/datadir.sgc @@ -1,6 +1,7 @@ {title : Image included from datadir} {subtitle: Chordpro} {cover: datadir.png} +{lang: en} {partition: datadir.ly} {image: datadir.png} diff --git a/test/test_compilation/subdir_datadir/songs/datadir2.sgc b/test/test_compilation/subdir_datadir/songs/datadir2.sgc index e9f43eed..ff941a56 100644 --- a/test/test_compilation/subdir_datadir/songs/datadir2.sgc +++ b/test/test_compilation/subdir_datadir/songs/datadir2.sgc @@ -1,7 +1,7 @@ {title : Image included from a different datadir} {subtitle: Chordpro} {cover: datadir2.png} -{lang: fr} +{lang: en} {partition: datadir2.ly} {image: datadir2.png} diff --git a/test/test_compilation/subdir_datadir/songs/relative.sgc b/test/test_compilation/subdir_datadir/songs/relative.sgc index 0d6fddd1..2ee2e38d 100644 --- a/test/test_compilation/subdir_datadir/songs/relative.sgc +++ b/test/test_compilation/subdir_datadir/songs/relative.sgc @@ -1,7 +1,7 @@ {title : Image included from song directory} {subtitle: Chordpro} {cover: relative.png} -{lang: fr} +{lang: en} {partition: relative.ly} {image: relative.png} From ff24e14f5ec4e0349ce2f0ab289a8a0cab94bd80 Mon Sep 17 00:00:00 2001 From: Louis Date: Thu, 22 Oct 2015 17:19:15 +0200 Subject: [PATCH 14/32] [test] New placeholder test. --- test/test_compilation/subdir.tex.control | 4 ++-- test/test_compilation/test_compilation.py | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/test/test_compilation/subdir.tex.control b/test/test_compilation/subdir.tex.control index 0f182f9a..6caaa199 100644 --- a/test/test_compilation/subdir.tex.control +++ b/test/test_compilation/subdir.tex.control @@ -16,7 +16,7 @@ {@TEST_FOLDER@/subdir_datadir/latex/} % {@TEST_FOLDER@/subdir_datadir2/latex/} % {@TEST_FOLDER@/latex/} % - {@PACKAGE_FOLDER@/data/latex/} % + {@DATA_FOLDER@/latex/} % } \makeatother @@ -44,7 +44,7 @@ guitar, {@TEST_FOLDER@/subdir_datadir/} % {@TEST_FOLDER@/subdir_datadir2/} % {@TEST_FOLDER@/} % - {@PACKAGE_FOLDER@/data/} % + {@DATA_FOLDER@/} % } diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py index 62c76c09..07a0857d 100644 --- a/test/test_compilation/test_compilation.py +++ b/test/test_compilation/test_compilation.py @@ -2,13 +2,14 @@ # pylint: disable=too-few-public-methods +from pkg_resources import resource_filename import glob import os import subprocess import unittest from patacrep.encoding import open_read -from pkg_resources import resource_filename +import patacrep from .. import dynamic # pylint: disable=unused-import @@ -93,13 +94,14 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): def assertMultiLineEqual(self, result, expected, msg=None): """Replace the placeholder paths with the local paths""" - placeholder = "@TEST_FOLDER@" - localpath = os.path.dirname(__file__) - expected = expected.replace(placeholder, localpath) + expected = expected.replace( + "@TEST_FOLDER@", + os.path.dirname(__file__), + ) - import patacrep - placeholder = "@PACKAGE_FOLDER@" - localpath = os.path.abspath(resource_filename(patacrep.__name__, '')) - expected = expected.replace(placeholder, localpath) + expected = expected.replace( + "@DATA_FOLDER@", + os.path.abspath(resource_filename(patacrep.__name__, 'data')), + ) return super().assertMultiLineEqual(result, expected, msg) From 5928b8e3838ad784e1376735aae784402ce272f6 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 17:44:03 +0200 Subject: [PATCH 15/32] [test] fix Data folder --- test/test_compilation/test_compilation.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py index 07a0857d..c46844d5 100644 --- a/test/test_compilation/test_compilation.py +++ b/test/test_compilation/test_compilation.py @@ -2,14 +2,13 @@ # pylint: disable=too-few-public-methods -from pkg_resources import resource_filename import glob import os import subprocess import unittest from patacrep.encoding import open_read -import patacrep +from patacrep import __DATADIR__ from .. import dynamic # pylint: disable=unused-import @@ -101,7 +100,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): expected = expected.replace( "@DATA_FOLDER@", - os.path.abspath(resource_filename(patacrep.__name__, 'data')), + __DATADIR__, ) return super().assertMultiLineEqual(result, expected, msg) From b60a32d269cd1d2841755da959ef73d781ed0592 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 18:14:32 +0200 Subject: [PATCH 16/32] [test] fix Data folder via system call --- test/test_compilation/test_compilation.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py index c46844d5..ca94400e 100644 --- a/test/test_compilation/test_compilation.py +++ b/test/test_compilation/test_compilation.py @@ -8,7 +8,6 @@ import subprocess import unittest from patacrep.encoding import open_read -from patacrep import __DATADIR__ from .. import dynamic # pylint: disable=unused-import @@ -98,9 +97,13 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): os.path.dirname(__file__), ) + datadir_command = ['python', '-c', 'from patacrep import __DATADIR__; print(__DATADIR__)'] + stdout = subprocess.check_output(datadir_command) + datadir = stdout.decode("utf-8").strip() + expected = expected.replace( "@DATA_FOLDER@", - __DATADIR__, + datadir, ) return super().assertMultiLineEqual(result, expected, msg) From 2107200e260cf7100b7e9c534e93d2db899d0b33 Mon Sep 17 00:00:00 2001 From: Louis Date: Thu, 22 Oct 2015 18:17:10 +0200 Subject: [PATCH 17/32] [test] Use the right place holder --- test/test_compilation/test_compilation.py | 32 +++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py index 07a0857d..29d475f6 100644 --- a/test/test_compilation/test_compilation.py +++ b/test/test_compilation/test_compilation.py @@ -63,9 +63,24 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): tex = "{}.tex".format(base) with open_read(control) as expectfile: with open_read(tex) as latexfile: + expected = expectfile.read().strip() + expected = expected.replace( + "@TEST_FOLDER@", + 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"))'], + universal_newlines=True, + cwd=os.path.dirname(songbook), + ).strip(), + ) + self.assertMultiLineEqual( latexfile.read().strip(), - expectfile.read().strip(), + expected, ) # Check compilation @@ -90,18 +105,3 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): stderr=subprocess.DEVNULL, cwd=os.path.dirname(songbook), ) - - def assertMultiLineEqual(self, result, expected, msg=None): - """Replace the placeholder paths with the local paths""" - - expected = expected.replace( - "@TEST_FOLDER@", - os.path.dirname(__file__), - ) - - expected = expected.replace( - "@DATA_FOLDER@", - os.path.abspath(resource_filename(patacrep.__name__, 'data')), - ) - - return super().assertMultiLineEqual(result, expected, msg) From d20a0834cd6cc88e0405f0eddc215db0457dbb9a Mon Sep 17 00:00:00 2001 From: Louis Date: Thu, 22 Oct 2015 18:33:02 +0200 Subject: [PATCH 18/32] pylint --- test/test_compilation/test_compilation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py index bfccce4e..9a2e77de 100644 --- a/test/test_compilation/test_compilation.py +++ b/test/test_compilation/test_compilation.py @@ -70,7 +70,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): expected = expected.replace( "@DATA_FOLDER@", subprocess.check_output( - ["python", "-c", 'import patacrep, pkg_resources; print(pkg_resources.resource_filename(patacrep.__name__, "data"))'], + ["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(), From 93805c97f4d4be60357999574f6593f82bc8a9d7 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 18:36:30 +0200 Subject: [PATCH 19/32] Try to use the new Travis infrastructure --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 53282da2..7051b457 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,3 +7,4 @@ install: - pip install tox script: - tox +sudo: false From 3f04f1337e2fc1e086be672911f35745712a3e18 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 18:41:14 +0200 Subject: [PATCH 20/32] [temp] change default debug level --- patacrep/songbook/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patacrep/songbook/__main__.py b/patacrep/songbook/__main__.py index 5713b4a9..e205f5f8 100644 --- a/patacrep/songbook/__main__.py +++ b/patacrep/songbook/__main__.py @@ -14,7 +14,7 @@ from patacrep import errors import patacrep.encoding # Logging configuration -logging.basicConfig(level=logging.INFO) +logging.basicConfig(level=logging.DEBUG) LOGGER = logging.getLogger() # pylint: disable=too-few-public-methods From 320e94cfd86f04426819488299bac88dd9bfda3e Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 18:59:36 +0200 Subject: [PATCH 21/32] Display command output --- test/test_compilation/test_compilation.py | 28 +++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py index 9a2e77de..3aad14eb 100644 --- a/test/test_compilation/test_compilation.py +++ b/test/test_compilation/test_compilation.py @@ -96,10 +96,24 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): if steps: command.extend(['--steps', steps]) - return subprocess.check_call( - command, - stdin=subprocess.DEVNULL, - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - cwd=os.path.dirname(songbook), - ) + return subprocess.check_call( + command, + stdin=subprocess.DEVNULL, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + cwd=os.path.dirname(songbook), + ) + #temp fix for travis tests + try: + val = subprocess.check_output( + command, + stderr=subprocess.STDOUT, + universal_newlines=True, + cwd=os.path.dirname(songbook), + ) + print("###ok") + print(val) + print("ok###") + except subprocess.CalledProcessError as e: + print(e.output) + return 1 \ No newline at end of file From f06ca48307fe732d4b63e627277a11537b15bd77 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 19:01:19 +0200 Subject: [PATCH 22/32] Travis needs latex-base (at least) --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7051b457..336cf80f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,3 +8,7 @@ install: script: - tox sudo: false +addons: + apt: + packages: + - texlive-latex-base From 12dfa0a748f5615f12254c351ff46074345cbf39 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 19:06:49 +0200 Subject: [PATCH 23/32] latex-xcolor is required as well --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 336cf80f..91054fb2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,3 +12,4 @@ addons: apt: packages: - texlive-latex-base + - latex-xcolor From 7be96435374f4f0bddb95e4e7792009ec675e7fb Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 19:08:51 +0200 Subject: [PATCH 24/32] latex-extra is required as well --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 91054fb2..d5f93169 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,3 +13,4 @@ addons: packages: - texlive-latex-base - latex-xcolor + - texlive-latex-extra From 3fb2d58a53d6b2c97ddc156d233ff534814d35be Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 19:11:18 +0200 Subject: [PATCH 25/32] pgf is required as well --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index d5f93169..afd9211b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,3 +14,4 @@ addons: - texlive-latex-base - latex-xcolor - texlive-latex-extra + - pgf From e1ea347459aa0d646433763fb4484528da8abcf1 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 19:13:22 +0200 Subject: [PATCH 26/32] lmodern is required as well --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index afd9211b..b01bcf23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,3 +15,4 @@ addons: - latex-xcolor - texlive-latex-extra - pgf + - lmodern From 406300d1ca72faab453e81ac532b112c8fff4acb Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 19:15:12 +0200 Subject: [PATCH 27/32] lilypond is required as well --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b01bcf23..2b4b68ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,3 +16,4 @@ addons: - texlive-latex-extra - pgf - lmodern + - lilypond From e81d88e95321229b5dbca9affbce4a08196a240b Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 19:28:44 +0200 Subject: [PATCH 28/32] Travis does not allow lilypond (yet) --- test/test_compilation/subdir.sb | 1 - test/test_compilation/subdir.tex.control | 1 - 2 files changed, 2 deletions(-) diff --git a/test/test_compilation/subdir.sb b/test/test_compilation/subdir.sb index 1395ed5c..28132138 100644 --- a/test/test_compilation/subdir.sb +++ b/test/test_compilation/subdir.sb @@ -1,6 +1,5 @@ { "bookoptions" : [ - "lilypond", "pictures" ], "datadir": ["subdir_datadir", "subdir_datadir2"], diff --git a/test/test_compilation/subdir.tex.control b/test/test_compilation/subdir.tex.control index 6caaa199..bd9ac649 100644 --- a/test/test_compilation/subdir.tex.control +++ b/test/test_compilation/subdir.tex.control @@ -25,7 +25,6 @@ \usepackage[ chorded, -lilypond, pictures, guitar, ]{patacrep} From 255788a2d23c203bf8619d0997b69f988ead1161 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 19:39:23 +0200 Subject: [PATCH 29/32] Log the output in case of command failure --- test/test_compilation/test_compilation.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py index 3aad14eb..c4749257 100644 --- a/test/test_compilation/test_compilation.py +++ b/test/test_compilation/test_compilation.py @@ -6,11 +6,13 @@ import glob import os import subprocess import unittest +import logging from patacrep.encoding import open_read from .. import dynamic # pylint: disable=unused-import +LOGGER = logging.getLogger(__name__) class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): """Test of songbook compilation. @@ -96,24 +98,14 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): if steps: command.extend(['--steps', steps]) - return subprocess.check_call( - command, - stdin=subprocess.DEVNULL, - stdout=subprocess.DEVNULL, - stderr=subprocess.DEVNULL, - cwd=os.path.dirname(songbook), - ) - #temp fix for travis tests try: - val = subprocess.check_output( + subprocess.check_output( command, stderr=subprocess.STDOUT, universal_newlines=True, cwd=os.path.dirname(songbook), ) - print("###ok") - print(val) - print("ok###") + return 0 except subprocess.CalledProcessError as e: - print(e.output) - return 1 \ No newline at end of file + LOGGER.warning(e.output) + return e.returncode \ No newline at end of file From c2d44df20a92d1b9a94c1b0a1696824d53b06964 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 19:40:46 +0200 Subject: [PATCH 30/32] Clean code --- patacrep/songbook/__main__.py | 2 +- test/test_compilation/test_compilation.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/patacrep/songbook/__main__.py b/patacrep/songbook/__main__.py index e205f5f8..5713b4a9 100644 --- a/patacrep/songbook/__main__.py +++ b/patacrep/songbook/__main__.py @@ -14,7 +14,7 @@ from patacrep import errors import patacrep.encoding # Logging configuration -logging.basicConfig(level=logging.DEBUG) +logging.basicConfig(level=logging.INFO) LOGGER = logging.getLogger() # pylint: disable=too-few-public-methods diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py index c4749257..94fe810b 100644 --- a/test/test_compilation/test_compilation.py +++ b/test/test_compilation/test_compilation.py @@ -108,4 +108,4 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): return 0 except subprocess.CalledProcessError as e: LOGGER.warning(e.output) - return e.returncode \ No newline at end of file + return e.returncode From c1df24f0c01fdbc98f83b96d28e6af613621ff98 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 19:45:36 +0200 Subject: [PATCH 31/32] pylint compliance --- test/test_compilation/test_compilation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py index 94fe810b..b5ccf3fb 100644 --- a/test/test_compilation/test_compilation.py +++ b/test/test_compilation/test_compilation.py @@ -106,6 +106,6 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): cwd=os.path.dirname(songbook), ) return 0 - except subprocess.CalledProcessError as e: - LOGGER.warning(e.output) - return e.returncode + except subprocess.CalledProcessError as error: + LOGGER.warning(error.output) + return error.returncode From 8dd3f9a9318cdf872e83f9a7508d485c3901d40a Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 19:45:55 +0200 Subject: [PATCH 32/32] Verbose compilation in tests --- test/test_compilation/test_compilation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py index b5ccf3fb..812ba0ac 100644 --- a/test/test_compilation/test_compilation.py +++ b/test/test_compilation/test_compilation.py @@ -94,7 +94,7 @@ 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] + command = ['python', '-m', 'patacrep.songbook', songbook, '-v'] if steps: command.extend(['--steps', steps])