diff options
author | borenet <borenet@chromium.org> | 2016-06-15 12:07:42 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-15 12:07:42 -0700 |
commit | 0f1469bcdad11cf8bfe79ace33d28052418ecb48 (patch) | |
tree | 5411db3cc9fecf963821f2d5a904565617d25ed0 /infra/bots/zip_utils_test.py | |
parent | 115e925dc85f3c6dbb140a2c1be3309ff72d3d8b (diff) |
Add asset management scripts
These provide an easy way to create assets to be used by bots,
eg. Android SDK.
To create an asset:
$ infra/bots/assets/assets.py add android_sdk
(adds scripts in infra/bots/assets/android_sdk)
To upload a new version of an asset:
$ infra/bots/assets/android_sdk/upload.py -t $ANDROID_SDK_ROOT
(uploads Android SDK to GS, writes a version file)
$ git commit
$ git cl upload
To download the current version of the asset:
$ infra/bots/assets/android_sdk/download.py -t ../tmp
BUG=skia:5427
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2069543002
Review-Url: https://codereview.chromium.org/2069543002
Diffstat (limited to 'infra/bots/zip_utils_test.py')
-rw-r--r-- | infra/bots/zip_utils_test.py | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/infra/bots/zip_utils_test.py b/infra/bots/zip_utils_test.py new file mode 100644 index 0000000000..4f88a115df --- /dev/null +++ b/infra/bots/zip_utils_test.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python +# +# Copyright 2016 Google Inc. +# +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +"""Tests for zip_utils.""" + + +import filecmp +import os +import test_utils +import unittest +import utils +import uuid +import zip_utils + + +class ZipUtilsTest(unittest.TestCase): + def test_zip_unzip(self): + with utils.tmp_dir(): + fw = test_utils.FileWriter(os.path.join(os.getcwd(), 'input')) + # Create input files and directories. + fw.mkdir('mydir') + fw.mkdir('anotherdir', 0666) + fw.mkdir('dir3', 0600) + fw.mkdir('subdir') + fw.write('a.txt', 0777) + fw.write('b.txt', 0751) + fw.write('c.txt', 0640) + fw.write(os.path.join('subdir', 'd.txt'), 0640) + + # Zip, unzip. + zip_utils.zip('input', 'test.zip') + zip_utils.unzip('test.zip', 'output') + + # Compare the inputs and outputs. + test_utils.compare_trees(self, 'input', 'output') + + def test_blacklist(self): + with utils.tmp_dir(): + # Create input files and directories. + fw = test_utils.FileWriter(os.path.join(os.getcwd(), 'input')) + fw.mkdir('.git') + fw.write(os.path.join('.git', 'index')) + fw.write('somefile') + fw.write('.DS_STORE') + fw.write('leftover.pyc') + fw.write('.pycfile') + + # Zip, unzip. + zip_utils.zip('input', 'test.zip', blacklist=['.git', '.DS*', '*.pyc']) + zip_utils.unzip('test.zip', 'output') + + # Remove the files/dirs we don't expect to see in output, so that we can + # use self._compare_trees to check the results. + fw.remove(os.path.join('.git', 'index')) + fw.remove('.git') + fw.remove('.DS_STORE') + fw.remove('leftover.pyc') + + # Compare results. + test_utils.compare_trees(self, 'input', 'output') + + def test_nonexistent_dir(self): + with utils.tmp_dir(): + with self.assertRaises(IOError): + zip_utils.zip('input', 'test.zip') + + +if __name__ == '__main__': + unittest.main() |