diff options
author | kennyballou <kballou@onyx.boisestate.edu> | 2013-04-02 19:20:34 -0600 |
---|---|---|
committer | kennyballou <kballou@onyx.boisestate.edu> | 2013-04-02 19:20:34 -0600 |
commit | e24249b51439724cc8fafe91dbcc99fe442ff7e0 (patch) | |
tree | 18d06c351aaa360f2c68031ecf07c2f0f21aac9c | |
parent | 3def2a1aab22a9e97c456770346d16ad6308dd94 (diff) | |
parent | e40f1eee6abf0e2ebb8eb07adb6548d431a03a64 (diff) | |
download | xnt-e24249b51439724cc8fafe91dbcc99fe442ff7e0.tar.gz xnt-e24249b51439724cc8fafe91dbcc99fe442ff7e0.tar.xz |
Merge 'add_build_make_tex_tests' into develop
-rw-r--r-- | xnt/tests/maketests.py | 137 | ||||
-rw-r--r-- | xnt/tests/textests.py | 110 |
2 files changed, 247 insertions, 0 deletions
diff --git a/xnt/tests/maketests.py b/xnt/tests/maketests.py new file mode 100644 index 0000000..ab7fa52 --- /dev/null +++ b/xnt/tests/maketests.py @@ -0,0 +1,137 @@ +#!/usr/bin/env python +"""Make (make/ant/nant) Tests Module""" + +# Xnt -- A Wrapper Build Tool +# Copyright (C) 2013 Kenny Ballou + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +import os +import unittest +import xnt +import xnt.build.make +import xnt.tests + +@unittest.skipUnless(xnt.in_path("ant"), "Apache ant is not in your path") +class AntTests(unittest.TestCase): + """Test Case for Ant Build""" + def setUp(self): + """Test Setup""" + xnt.tests.set_up() + with open("temp/build.xml", "w") as build: + build.write("<?xml version=\"1.0\" ?>\n") + build.write("<project name=\"test\" default=\"test\">\n") + build.write("<target name=\"test\">\n") + build.write("<echo>${test_var}</echo>\n") + build.write("</target>\n") + build.write("</project>\n") + + def tearDown(self): + """Test Teardown""" + xnt.tests.tear_down() + + def test_default_build(self): + """Test the default target of ant""" + result = xnt.build.make.ant(target="test", path="temp") + self.assertEqual(result, 0) + + def test_passing_flags(self): + """Test ant with passing flags""" + result = xnt.build.make.ant(target="test", path="temp", flags=["-verbose"]) + self.assertEqual(result, 0) + + def test_pass_var(self): + """Test passing variables to ant""" + result = xnt.build.make.ant(target="test", path="temp", + pkeys=["test_var"], + pvalues=["testing"]) + self.assertEqual(result, 0) + +@unittest.skipUnless(xnt.in_path("make"), "make is not in your path") +class MakeTests(unittest.TestCase): + """GNU Make Tests""" + + def setUp(self): + """Test Setup""" + xnt.tests.set_up() + with open("temp/Makefile", "w") as makefile: + makefile.write("build:\n") + makefile.write("\techo 'testing'\n") + + def tearDown(self): + """Test Teardown""" + xnt.tests.tear_down() + + def test_default_make(self): + """Test Default make""" + result = xnt.build.make.make(target="build", path="temp") + self.assertEqual(result, 0) + + def test_passing_vars(self): + """Test Parameter Passing with Make""" + result = xnt.build.make.make(target="build", + path="temp", + pkeys=["test_var"], + pvalues=["testing"]) + self.assertEqual(result, 0) + + def test_passing_flags(self): + """Test Flag Passing with Make""" + result = xnt.build.make.make(target="build", + path="temp", + flags=["-B"]) + self.assertEqual(result, 0) + +@unittest.skipUnless(xnt.in_path("nant"), "nant is not in your path") +class NAntTests(unittest.TestCase): + """.NET Ant Tests""" + + def setUp(self): + """Test Setup""" + xnt.tests.set_up() + with open("temp/default.config", "w") as default_build: + default_build.write("<?xml version=\"1.0\"?>\n") + default_build.write("<probject name=\"test\">\n") + default_build.write("<target name=\"test\">\n") + default_build.write("<echo>${test_var}</echo>\n") + default_build.write("</target>\n") + default_build.write("</project>") + + def tearDown(self): + """Test Teardown""" + xnt.tests.tear_down() + + def test_default_nant(self): + """Test Deault nant""" + result = xnt.build.make.nant(target="test", path="temp") + self.assertEqual(result, 0) + + def test_parameters_passing(self): + """Test Parameter Passing with NAnt""" + result = xnt.build.make.nant(target="test", + path="temp", + pkeys=["test_var"], + pvalues=["testing"]) + self.assertEqual(result, 0) + + def test_flag_passing(self): + """Test Flag Passing with NAnt""" + result = xnt.build.make.nant(target="test", + path="temp", + flags=["-v"]) + self.assertEqual(result, 0) + + +if __name__ == '__main__': + unittest.main() diff --git a/xnt/tests/textests.py b/xnt/tests/textests.py new file mode 100644 index 0000000..d3f8f01 --- /dev/null +++ b/xnt/tests/textests.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python +"""Tex Tests Module""" + +# Xnt -- A Wrapper Build Tool +# Copyright (C) 2013 Kenny Ballou + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +import os +import unittest +import xnt +import xnt.build.tex +import xnt.tests + +@unittest.skipUnless(xnt.in_path("pdflatex"), "pdflatex is not in your path") +class TexTests(unittest.TestCase): + """Test Case for TeX Document Building""" + + def setUp(self): + """Test Setup""" + xnt.tests.set_up() + with open("temp/test.tex", "w") as test_tex: + test_tex.write('\\documentclass{article}\n') + test_tex.write('\\usepackage{glossaries}\n') + test_tex.write('\\author{python test}\n') + test_tex.write('\\date{\\today}\n') + test_tex.write('\\makeglossaries\n') + test_tex.write('\\begin{document}\n') + test_tex.write('\\nocite{*}\n') + test_tex.write('\\newglossaryentry{test}\n') + test_tex.write('{name={test},description={this}}\n') + test_tex.write('This is a \\gls{test} \\LaTeX document.\n') + test_tex.write('\\printglossaries\n') + test_tex.write('\\begin{thebibliography}{1}\n') + test_tex.write('\\bibitem{test_bib_item}\n') + test_tex.write('Leslie Lamport,\n') + test_tex.write('\\emph{\\LaTeX: A Document Preperation System}.\n') + test_tex.write('Addison Wesley, Massachusetts,\n') + test_tex.write('2nd Edition,\n') + test_tex.write('1994.\n') + test_tex.write('\\end{thebibliography}\n') + test_tex.write('\\bibliography{1}\n') + test_tex.write('\\end{document}\n') + + def tearDown(self): + """Test Teardown""" + xnt.tests.tear_down() + + def test_pdflatex_build(self): + """Test default pdflatex build""" + xnt.build.tex.pdflatex("test.tex", + path="temp") + self.assertTrue(os.path.exists("temp/test.pdf")) + self.assertTrue(os.path.exists("temp/test.aux")) + self.assertTrue(os.path.exists("temp/test.log")) + + def test_pdflatex_build_with_bibtex(self): + """Test pdflatex with bibtex""" + xnt.build.tex.pdflatex("test.tex", + path="temp", + bibtex=True) + self.assertTrue(os.path.exists("temp/test.pdf")) + self.assertTrue(os.path.exists("temp/test.bbl")) + self.assertTrue(os.path.exists("temp/test.blg")) + + def test_pdflatex_build_with_glossary(self): + """Test pdflatex with glossary output""" + xnt.build.tex.pdflatex("test.tex", + path="temp", + makeglossary=True) + self.assertTrue(os.path.exists("temp/test.pdf")) + self.assertTrue(os.path.exists("temp/test.glo")) + self.assertTrue(os.path.exists("temp/test.glg")) + self.assertTrue(os.path.exists("temp/test.gls")) + + def test_tex_clean(self): + """Test the default clean method removes generated files except pdf""" + xnt.build.tex.pdflatex("test.tex", + path="temp", + bibtex=True, + makeglossary=True) + xnt.build.tex.clean(path="temp") + self.assertTrue(os.path.exists("temp/test.pdf")) + self.assertFalse(os.path.exists("temp/test.aux")) + self.assertFalse(os.path.exists("temp/test.log")) + + def test_tex_clean_include_pdf(self): + """Test Clean; including PDF""" + xnt.build.tex.pdflatex("test.tex", + path="temp", + bibtex=True, + makeglossary=True) + xnt.build.tex.clean(path="temp", remove_pdf=True) + self.assertFalse(os.path.exists("temp/test.pdf")) + self.assertFalse(os.path.exists("temp/test.aux")) + self.assertFalse(os.path.exists("temp/test.log")) + +if __name__ == '__main__': + unittest.main() |