]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
buildman: Permit branch names with an embedded '/'
authorSimon Glass <sjg@chromium.org>
Sat, 6 Sep 2014 01:00:22 +0000 (19:00 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 9 Sep 2014 22:38:31 +0000 (16:38 -0600)
At present buildman naively uses the branch name as part of its directory
path, which causes problems if the name has an embedded '/'.

Replace these with '_' to fix the problem.

Reported-by: Steve Rae <srae@broadcom.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
tools/buildman/control.py
tools/buildman/func_test.py

index ee9637591cd5135b364fbbd64773865985de2993..8146e1caf88aaac6de0b153ca80b656ef24e9506 100644 (file)
@@ -209,7 +209,7 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
 
     # Create a new builder with the selected options
     if options.branch:
 
     # Create a new builder with the selected options
     if options.branch:
-        dirname = options.branch
+        dirname = options.branch.replace('/', '_')
     else:
         dirname = 'current'
     output_dir = os.path.join(options.output_dir, dirname)
     else:
         dirname = 'current'
     output_dir = os.path.join(options.output_dir, dirname)
index 2cb5cf05fc4b4676f68c63ba9721a245d36b41ef..c37f1b62081c4d23e6149d810b9e0e819a5c9156 100644 (file)
@@ -199,6 +199,8 @@ class TestFunctional(unittest.TestCase):
         # Map of [board, commit] to error messages
         self._error = {}
 
         # Map of [board, commit] to error messages
         self._error = {}
 
+        self._test_branch = TEST_BRANCH
+
         # Avoid sending any output and clear all terminal output
         terminal.SetPrintTestMode()
         terminal.GetPrintTestLines()
         # Avoid sending any output and clear all terminal output
         terminal.SetPrintTestMode()
         terminal.GetPrintTestLines()
@@ -252,10 +254,10 @@ class TestFunctional(unittest.TestCase):
     def _HandleCommandGitLog(self, args):
         if '-n0' in args:
             return command.CommandResult(return_code=0)
     def _HandleCommandGitLog(self, args):
         if '-n0' in args:
             return command.CommandResult(return_code=0)
-        elif args[-1] == 'upstream/master..%s' % TEST_BRANCH:
+        elif args[-1] == 'upstream/master..%s' % self._test_branch:
             return command.CommandResult(return_code=0, stdout=commit_shortlog)
         elif args[:3] == ['--no-color', '--no-decorate', '--reverse']:
             return command.CommandResult(return_code=0, stdout=commit_shortlog)
         elif args[:3] == ['--no-color', '--no-decorate', '--reverse']:
-            if args[-1] == TEST_BRANCH:
+            if args[-1] == self._test_branch:
                 count = int(args[3][2:])
                 return command.CommandResult(return_code=0,
                                             stdout=''.join(commit_log[:count]))
                 count = int(args[3][2:])
                 return command.CommandResult(return_code=0,
                                             stdout=''.join(commit_log[:count]))
@@ -270,9 +272,9 @@ class TestFunctional(unittest.TestCase):
             return command.CommandResult(return_code=0)
         elif config.startswith('branch.badbranch'):
             return command.CommandResult(return_code=1)
             return command.CommandResult(return_code=0)
         elif config.startswith('branch.badbranch'):
             return command.CommandResult(return_code=1)
-        elif config == 'branch.%s.remote' % TEST_BRANCH:
+        elif config == 'branch.%s.remote' % self._test_branch:
             return command.CommandResult(return_code=0, stdout='upstream\n')
             return command.CommandResult(return_code=0, stdout='upstream\n')
-        elif config == 'branch.%s.merge' % TEST_BRANCH:
+        elif config == 'branch.%s.merge' % self._test_branch:
             return command.CommandResult(return_code=0,
                                          stdout='refs/heads/master\n')
 
             return command.CommandResult(return_code=0,
                                          stdout='refs/heads/master\n')
 
@@ -505,3 +507,10 @@ class TestFunctional(unittest.TestCase):
         self.assertEqual(self._builder.count, self._total_builds)
         self.assertEqual(self._builder.fail, 0)
         self.assertEqual(self._make_calls, 3)
         self.assertEqual(self._builder.count, self._total_builds)
         self.assertEqual(self._builder.fail, 0)
         self.assertEqual(self._make_calls, 3)
+
+    def testBranchWithSlash(self):
+        """Test building a branch with a '/' in the name"""
+        self._test_branch = '/__dev/__testbranch'
+        self._RunControl('-b', self._test_branch, clean_dir=False)
+        self.assertEqual(self._builder.count, self._total_builds)
+        self.assertEqual(self._builder.fail, 0)