Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Unified Diff: tools/isolate/run_test_from_archive_test.py

Issue 10880009: Enforces strict manifest content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Implemented lower-overhead straight forward technique Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/isolate/run_test_from_archive_test.py
diff --git a/tools/isolate/run_test_from_archive_test.py b/tools/isolate/run_test_from_archive_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..0a6f5c9ac261810f4ddbeb1b2a7deeb0274d059b
--- /dev/null
+++ b/tools/isolate/run_test_from_archive_test.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 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.
+
+import json
+import logging
+import sys
+import unittest
+
+import run_test_from_archive
+
+
+class RunTestFromArchiveTest(unittest.TestCase):
+ def test_load_manifest_empty(self):
+ m = run_test_from_archive.load_manifest('{}')
+ self.assertEquals({}, m)
+
+ def test_load_manifest_good(self):
+ data = {
+ u'command': [u'foo', u'bar'],
+ u'files': {
+ u'a': {
+ u'link': u'somewhere',
+ u'mode': 123,
+ u'timestamp': 456,
+ },
+ u'b': {
+ u'mode': 123,
+ u'sha-1': u'0123456789abcdef0123456789abcdef01234567'
+ }
+ },
+ u'read_only': False,
+ u'relative_cwd': u'somewhere_else'
+ }
+ m = run_test_from_archive.load_manifest(json.dumps(data))
+ self.assertEquals(data, m)
+
+ def test_load_manifest_bad(self):
+ data = {
+ u'files': {
+ u'a': {
+ u'link': u'somewhere',
+ u'sha-1': u'0123456789abcdef0123456789abcdef01234567'
+ }
+ },
+ }
+ try:
+ run_test_from_archive.load_manifest(json.dumps(data))
+ self.fail()
+ except run_test_from_archive.ConfigError:
+ pass
+
+
+
+if __name__ == '__main__':
+ logging.basicConfig(
+ level=(logging.DEBUG if '-v' in sys.argv else logging.ERROR))
+ unittest.main()
« tools/isolate/run_test_from_archive.py ('K') | « tools/isolate/run_test_from_archive.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698