import tempfile
import unittest
-import board
-import bsettings
-import cmdline
-import command
-import control
-import gitutil
-import terminal
-import toolchain
-import tools
+from buildman import board
+from buildman import bsettings
+from buildman import cmdline
+from buildman import control
+from buildman import toolchain
+from patman import command
+from patman import gitutil
+from patman import terminal
+from patman import tools
settings_data = '''
# Buildman settings file
# Only sandbox should succeed, the others don't have toolchains
self.assertEqual(self._builder.fail,
self._total_builds - self._commits)
- self.assertEqual(ret_code, 128)
+ self.assertEqual(ret_code, 100)
for commit in range(self._commits):
for board in self._boards.GetList():
self._RunControl('-b', TEST_BRANCH, '-c2', '-o', self._output_dir)
self.assertEqual(self._builder.count, 2 * len(boards))
self.assertEqual(self._builder.fail, 0)
- # Each board has a mrproper, config, and then one make per commit
- self.assertEqual(self._make_calls, len(boards) * (2 + 2))
+ # Each board has a config, and then one make per commit
+ self.assertEqual(self._make_calls, len(boards) * (1 + 2))
def testIncremental(self):
"""Test building a branch twice - the second time should do nothing"""
self._RunControl('-b', TEST_BRANCH, '-o', self._output_dir)
# Each board has a mrproper, config, and then one make per commit
- self.assertEqual(self._make_calls, len(boards) * (self._commits + 2))
+ self.assertEqual(self._make_calls, len(boards) * (self._commits + 1))
self._make_calls = 0
self._RunControl('-b', TEST_BRANCH, '-o', self._output_dir, clean_dir=False)
self.assertEqual(self._make_calls, 0)
self._RunControl('-b', TEST_BRANCH, '-o', self._output_dir)
self._make_calls = 0
self._RunControl('-b', TEST_BRANCH, '-f', '-o', self._output_dir, clean_dir=False)
- # Each board has a mrproper, config, and then one make per commit
- self.assertEqual(self._make_calls, len(boards) * (self._commits + 2))
+ # Each board has a config and one make per commit
+ self.assertEqual(self._make_calls, len(boards) * (self._commits + 1))
+
+ def testForceReconfigure(self):
+ """The -f flag should force a rebuild"""
+ self._RunControl('-b', TEST_BRANCH, '-C', '-o', self._output_dir)
+ # Each commit has a config and make
+ self.assertEqual(self._make_calls, len(boards) * self._commits * 2)
def testForceReconfigure(self):
"""The -f flag should force a rebuild"""
self._RunControl('-b', TEST_BRANCH, '-C', '-o', self._output_dir)
- # Each commit has a mrproper, config and make
- self.assertEqual(self._make_calls, len(boards) * self._commits * 3)
+ # Each commit has a config and make
+ self.assertEqual(self._make_calls, len(boards) * self._commits * 2)
+
+ def testMrproper(self):
+ """The -f flag should force a rebuild"""
+ self._RunControl('-b', TEST_BRANCH, '-m', '-o', self._output_dir)
+ # Each board has a mkproper, config and then one make per commit
+ self.assertEqual(self._make_calls, len(boards) * (self._commits + 2))
def testErrors(self):
"""Test handling of build errors"""
self._RunControl('-b', TEST_BRANCH, '-o', self._output_dir, '-F', clean_dir=False)
self.assertEqual(self._builder.count, self._total_builds)
self.assertEqual(self._builder.fail, 0)
- self.assertEqual(self._make_calls, 3)
+ self.assertEqual(self._make_calls, 2)
def testBranchWithSlash(self):
"""Test building a branch with a '/' in the name"""
self.assertEqual(self._builder.count, self._total_builds)
self.assertEqual(self._builder.fail, 0)
+ def testEnvironment(self):
+ """Test that the done and environment files are written to out-env"""
+ self._RunControl('-o', self._output_dir)
+ board0_dir = os.path.join(self._output_dir, 'current', 'board0')
+ self.assertTrue(os.path.exists(os.path.join(board0_dir, 'done')))
+ self.assertTrue(os.path.exists(os.path.join(board0_dir, 'out-env')))
+
def testWorkInOutput(self):
"""Test the -w option which should write directly to the output dir"""
board_list = board.Boards()
boards=board_list)
self.assertTrue(
os.path.exists(os.path.join(self._output_dir, 'u-boot')))
+ self.assertTrue(
+ os.path.exists(os.path.join(self._output_dir, 'done')))
+ self.assertTrue(
+ os.path.exists(os.path.join(self._output_dir, 'out-env')))
def testWorkInOutputFail(self):
"""Test the -w option failures"""
self._RunControl('-b', self._test_branch, '-o', self._output_dir,
'-w', clean_dir=False, boards=board_list)
self.assertIn("single commit", str(e.exception))
+
+ board_list = board.Boards()
+ board_list.AddBoard(board.Board(*boards[0]))
+ with self.assertRaises(SystemExit) as e:
+ self._RunControl('-w', clean_dir=False)
+ self.assertIn("specify -o", str(e.exception))