OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 from recipe_engine.types import freeze | 5 from recipe_engine.types import freeze |
6 | 6 |
7 | 7 |
8 DEPS = [ | 8 DEPS = [ |
9 'path', | 9 'path', |
10 'shutil', | 10 'shutil', |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 actual_content = api.shutil.read( | 44 actual_content = api.shutil.read( |
45 'read_%s' % name, 'tmp_file.txt', | 45 'read_%s' % name, 'tmp_file.txt', |
46 test_data=content | 46 test_data=content |
47 ) | 47 ) |
48 msg = 'expected %s but got %s' % (content, actual_content) | 48 msg = 'expected %s but got %s' % (content, actual_content) |
49 assert actual_content == content, msg | 49 assert actual_content == content, msg |
50 | 50 |
51 try: | 51 try: |
52 # copytree | 52 # copytree |
53 content = 'some file content' | 53 content = 'some file content' |
54 tmp_dir = api.path['slave_build'].join('copytree_example_tmp') | 54 tmp_dir = api.path['tmp'].join('copytree_example_tmp') |
55 api.shutil.makedirs('makedirs', tmp_dir) | 55 api.shutil.makedirs('makedirs', tmp_dir) |
56 path = tmp_dir.join('dummy_file') | 56 path = tmp_dir.join('dummy_file') |
57 api.shutil.write('write %s' % path, path, content) | 57 api.shutil.write('write %s' % path, path, content) |
58 new_tmp = api.path['slave_build'].join('copytree_example_tmp2') | 58 new_tmp = api.path['tmp'].join('copytree_example_tmp2') |
59 new_path = new_tmp.join('dummy_file') | 59 new_path = new_tmp.join('dummy_file') |
60 api.shutil.copytree('copytree', tmp_dir, new_tmp) | 60 api.shutil.copytree('copytree', tmp_dir, new_tmp) |
61 actual_content = api.shutil.read('read %s' % new_path, new_path, | 61 actual_content = api.shutil.read('read %s' % new_path, new_path, |
62 test_data=content) | 62 test_data=content) |
63 assert actual_content == content | 63 assert actual_content == content |
64 | 64 |
65 # glob. | 65 # glob. |
66 files = api.shutil.glob( | 66 files = api.shutil.glob( |
67 'glob', tmp_dir.join('*'), | 67 'glob', tmp_dir.join('*'), |
68 test_data=[tmp_dir.join('dummy_file')]) | 68 test_data=[tmp_dir.join('dummy_file')]) |
69 assert files == [str(tmp_dir.join('dummy_file'))], files | 69 assert files == [str(tmp_dir.join('dummy_file'))], files |
70 | 70 |
71 finally: | 71 finally: |
72 api.shutil.rmtree(tmp_dir, name='cleanup') | 72 api.shutil.rmtree(tmp_dir, name='cleanup') |
73 api.shutil.rmtree(new_tmp, name='cleanup2') | 73 api.shutil.rmtree(new_tmp, name='cleanup2') |
74 | 74 |
75 | 75 |
76 def GenTests(api): | 76 def GenTests(api): |
77 yield api.test('basic') | 77 yield api.test('basic') |
OLD | NEW |