servo: Merge #10775 - Test for tidy.check_lock function #9152 (from mskrzypkows:tidy_tests); r=Wafflespeanut
authorMaciej Skrzypkowski <m.skrzypkows@samsung.com>
Mon, 25 Apr 2016 00:19:33 -0700
changeset 338611 414a4169f2ef52fcd290b8ae031c483ca3551207
parent 338610 259414a1a4cfce6536fd7fcd9fb56b0084b0245b
child 338612 58e8f053297a5d0dadcdbab27c27207876671899
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWafflespeanut
servo: Merge #10775 - Test for tidy.check_lock function #9152 (from mskrzypkows:tidy_tests); r=Wafflespeanut Source-Repo: https://github.com/servo/servo Source-Revision: edb58040c82c9c333e0c0a04051e17ed6fb17bd7
servo/python/tidy/servo_tidy_tests/duplicated_package.lock
servo/python/tidy/servo_tidy_tests/test_tidy.py
new file mode 100644
--- /dev/null
+++ b/servo/python/tidy/servo_tidy_tests/duplicated_package.lock
@@ -0,0 +1,21 @@
+[root]
+name = "servo"
+version = "0.0.1"
+
+[[package]]
+name = "test"
+version = "0.4.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "test"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "test2"
+version = "0.1.0"
+source = "git+https://github.com/"
+dependencies = [
+ "test 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)",
+]
--- a/servo/python/tidy/servo_tidy_tests/test_tidy.py
+++ b/servo/python/tidy/servo_tidy_tests/test_tidy.py
@@ -91,13 +91,25 @@ class CheckTidiness(unittest.TestCase):
 
     def test_modeline(self):
         errors = tidy.collect_errors_for_files(iterFile('modeline.txt'), [], [tidy.check_modeline])
         self.assertEqual('vi modeline present', errors.next()[2])
         self.assertEqual('vi modeline present', errors.next()[2])
         self.assertEqual('vi modeline present', errors.next()[2])
         self.assertEqual('emacs file variables present', errors.next()[2])
         self.assertEqual('emacs file variables present', errors.next()[2])
+        self.assertNoMoreErrors(errors)
+
+    def test_lock(self):
+        errors = tidy.collect_errors_for_files(iterFile('duplicated_package.lock'), [tidy.check_lock], [])
+        msg = """duplicate versions for package "test"
+\t\033[93mfound dependency on version 0.4.9\033[0m
+\t\033[91mbut highest version is 0.5.1\033[0m
+\t\033[93mtry upgrading with\033[0m \033[96m./mach cargo-update -p test:0.4.9\033[0m
+\tThe following packages depend on version 0.4.9:
+\t\ttest2"""
+        self.assertEqual(msg, errors.next()[2])
+        self.assertNoMoreErrors(errors)
 
 
 def do_tests():
     suite = unittest.TestLoader().loadTestsFromTestCase(CheckTidiness)
     unittest.TextTestRunner(verbosity=2).run(suite)