From e40f1eee6abf0e2ebb8eb07adb6548d431a03a64 Mon Sep 17 00:00:00 2001 From: kennyballou Date: Tue, 2 Apr 2013 19:17:52 -0600 Subject: Add tests for the make module Theses tests are _not_ testing the result of running the actual sub build command; but, rather, the test purely the ability to invoke them at all. --- xnt/tests/maketests.py | 137 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 xnt/tests/maketests.py (limited to 'xnt') 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 . + +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("\n") + build.write("\n") + build.write("\n") + build.write("${test_var}\n") + build.write("\n") + build.write("\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("\n") + default_build.write("\n") + default_build.write("\n") + default_build.write("${test_var}\n") + default_build.write("\n") + default_build.write("") + + 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() -- cgit v1.2.1