| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2017 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. |
| 4 |
| 5 DEPS = [ |
| 6 "file", |
| 7 "path", |
| 8 ] |
| 9 |
| 10 |
| 11 def RunSteps(api): |
| 12 file_names = ['a', 'aa', 'b', 'bb', 'c', 'cc'] |
| 13 |
| 14 dest = api.path['start_dir'].join('some dir') |
| 15 api.file.ensure_directory('ensure "some dir"', dest) |
| 16 for fname in file_names: |
| 17 api.file.write_text('write %s' % fname, dest.join(fname), fname) |
| 18 |
| 19 dest2 = api.path['start_dir'].join('some other dir') |
| 20 api.file.rmtree('make sure dest is gone', dest2) |
| 21 api.file.copytree('copy it', dest, dest2) |
| 22 |
| 23 expect_paths = [dest2.join(n) for n in file_names] |
| 24 paths = api.file.listdir('list new dir', dest2, expect_paths) |
| 25 assert paths == expect_paths, paths |
| 26 |
| 27 paths = api.file.glob_paths('glob *a', dest2.join('*a'), |
| 28 [dest2.join(x) for x in ('a', 'aa')]) |
| 29 assert paths == [dest2.join('a'), dest2.join('aa')], paths |
| 30 |
| 31 for pth in paths: |
| 32 assert api.file.read_text('read %s' % pth, pth, api.path.basename(pth)) |
| 33 |
| 34 api.file.remove('rm a', dest2.join('a')) |
| 35 paths = api.file.glob_paths('glob *a', dest2.join('*a'), [dest2.join('aa')]) |
| 36 assert paths == [dest2.join('aa')], paths |
| 37 |
| 38 api.file.rmglob('rm b*', dest2, 'b*') |
| 39 new_paths = [dest2.join(p) for p in ['aa', 'c', 'cc']] |
| 40 paths = api.file.listdir('list new dir', dest2, new_paths) |
| 41 assert paths == new_paths, paths |
| 42 |
| 43 api.file.rmcontents('remove "some other dir/*"', dest2) |
| 44 assert api.path.exists(dest2), dest2 |
| 45 |
| 46 |
| 47 |
| 48 def GenTests(api): |
| 49 yield api.test('basic') |
| 50 |
| OLD | NEW |