| Index: tests/patch_test.py
|
| diff --git a/tests/patch_test.py b/tests/patch_test.py
|
| new file mode 100755
|
| index 0000000000000000000000000000000000000000..36fb6879432415667caf4c77c5b5947589f4e07f
|
| --- /dev/null
|
| +++ b/tests/patch_test.py
|
| @@ -0,0 +1,146 @@
|
| +#!/usr/bin/env python
|
| +# Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +"""Unit tests for patch.py."""
|
| +
|
| +import os
|
| +import sys
|
| +import unittest
|
| +
|
| +ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
| +sys.path.append(os.path.join(ROOT_DIR, '..'))
|
| +
|
| +import patch
|
| +
|
| +
|
| +class PatchTest(unittest.TestCase):
|
| + def testUnsupportedMerge(self):
|
| + data = (
|
| + '\n'
|
| + 'Property changes on: .\n'
|
| + '\n'
|
| + '___________________________________________________________________\n'
|
| + 'Modified: svn:mergeinfo\n'
|
| + ' Merged /trunk:r635-639\n'
|
| + '\n')
|
| + self.assertEquals(
|
| + 'Can\'t apply svn property svn:mergeinfo', patch.verify_patch(data))
|
| +
|
| + def testUnsupportedEmptyfileSvn1(self):
|
| + data = (
|
| + 'Index: foo.py\n'
|
| + '===================================================================\n'
|
| + '\n'
|
| + 'Property changes on: foo.py\n'
|
| + '___________________________________________________________________\n'
|
| + 'Added: svn:eol-style\n'
|
| + ' + LF\n'
|
| + '\n')
|
| + self.assertEquals(
|
| + 'Can\'t patch empty file (svn)', patch.verify_patch(data))
|
| +
|
| + def testUnsupportedEmptyfileSvn2(self):
|
| + data = (
|
| + 'Index: foo.py\n'
|
| + '===================================================================\n')
|
| + self.assertEquals(
|
| + 'Can\'t patch empty file (svn)', patch.verify_patch(data))
|
| +
|
| + def testUnsupportedEmptyfileGit(self):
|
| + data = (
|
| + 'diff --git a/git_cl/git-cl b/git_cl/git-cl\n')
|
| + self.assertEquals(
|
| + 'Can\'t patch empty file (git)', patch.verify_patch(data))
|
| +
|
| + def testUnsupportedGitMode1(self):
|
| + data = (
|
| + 'diff --git a/git_cl/git-cl b/git_cl/git-cl\n'
|
| + 'old mode 100644\n'
|
| + 'new mode 100755\n')
|
| + self.assertEquals(
|
| + 'Unsupported git file mode change', patch.verify_patch(data))
|
| +
|
| + def testUnsupportedGitMode2(self):
|
| + data = (
|
| + 'diff --git a/git_cl/git-cl b/git_cl/git-cl\n'
|
| + 'old mode 100644\n'
|
| + 'new mode 100755\n'
|
| + 'index 449c6e0..b035565\n'
|
| + '--- a/git_cl/git-cl\n'
|
| + '+++ b/git_cl/git-cl\n'
|
| + '@@ -3,7 +3,7 @@\n'
|
| + ' # Copyright (C) 2008 Evan Martin <martine@danga.com>\n'
|
| + '\n'
|
| + ' import sys\n'
|
| + '-\n'
|
| + '+foo\n'
|
| + ' import git_cl\n'
|
| + '\n'
|
| + ' if __name__ == \'__main__\':\n')
|
| + self.assertEquals(
|
| + 'Unsupported git file mode change', patch.verify_patch(data))
|
| +
|
| + def testSupported1(self):
|
| + data = (
|
| + 'Index: foo\n'
|
| + '===================================================================\n'
|
| + '--- foo (revision 639)\n'
|
| + '+++ foo (working copy)\n'
|
| + '@@ -1,6 +1,6 @@\n'
|
| + ' Welcome to Rietveld\n'
|
| + ' -------------------\n'
|
| + '-\n'
|
| + '+2\n'
|
| + ' This project shows how to create a somewhat substantial web '
|
| + 'application\n'
|
| + ' using Django on Google App Engine. It requires Django version 1.1.\n'
|
| + '\n'
|
| + '\n'
|
| + 'Property changes on: foo\n'
|
| + '___________________________________________________________________\n'
|
| + 'Modified: svn:eol-style\n'
|
| + ' - native\n'
|
| + ' + LF\n'
|
| + '\n')
|
| + self.assertEquals(None, patch.verify_patch(data))
|
| +
|
| + def testSupported2(self):
|
| + data = (
|
| + 'Index: patch.py\n'
|
| + 'diff --git a/patch.py b/patch.py\n'
|
| + 'index af18ee43e212583815d27d138d1fc426883eb663..8433a962e8586c7a84413'
|
| + '6dc1e43d10e0a542d13 100644\n'
|
| + '--- a/patch.py\n'
|
| + '+++ b/patch.py\n'
|
| + '@@ -1,8 +1,10 @@\n'
|
| + '+# coding=utf8\n'
|
| + ' # Copyright (c) 2010 The Chromium Authors. All rights reserved.\n'
|
| + ' # Use of this source code is governed by a BSD-style license that can'
|
| + ' be\n'
|
| + ' # found in the LICENSE file.\n'
|
| + ' """Utility functions to handle patches."""\n'
|
| + ' \n'
|
| + '+import logging\n'
|
| + ' import re\n'
|
| + ' import subprocess2\n'
|
| + ' \n')
|
| + self.assertEquals(None, patch.verify_patch(data))
|
| +
|
| + def testSupported3(self):
|
| + data = (
|
| + 'Index: tests/patch_test.py\n'
|
| + 'diff --git a/tests/patch_test.py b/tests/patch_test.py\n'
|
| + 'new file mode 100755\n'
|
| + 'index 0000000000000000000000000000000000000000..a9dc5827926d57bc5dc8'
|
| + 'f5106a0a63c891cce38c\n'
|
| + '--- /dev/null\n'
|
| + '+++ b/tests/patch_test.py\n'
|
| + '@@ -0,0 +1,1 @@\n'
|
| + '+#!/usr/bin/env python\n')
|
| + self.assertEquals(None, patch.verify_patch(data))
|
| +
|
| +
|
| +if __name__ == '__main__':
|
| + unittest.main()
|
|
|