Index: mojo/public/interfaces/bindings/tests/gen_data_files_list.py |
diff --git a/mojo/public/interfaces/bindings/tests/gen_data_files_list.py b/mojo/public/interfaces/bindings/tests/gen_data_files_list.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..24666f6b5c8265c5f8e7e9458fa8460a97afa831 |
--- /dev/null |
+++ b/mojo/public/interfaces/bindings/tests/gen_data_files_list.py |
@@ -0,0 +1,27 @@ |
+# Copyright 2017 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. |
+"""Generates the data file directory to run validation tests. |
+ |
+This script finds all of the files in the resources/data/validaiton folder |
yzshen1
2017/03/23 17:46:20
A few ideas:
- This script could be a generic tool
damargulis
2017/03/24 19:44:48
I moved this file into mojo/public/tools/bindings,
|
+and generates a file listing all of those files. That file is then consumed |
+by the validation test so that it can locate and fetch all data files. |
+""" |
+ |
+from os import listdir, makedirs, path |
+from shutil import copy |
+import sys |
+ |
+def gen_files(): |
+ files = [ f[:-5] for f in listdir(sys.argv[1]) if f.endswith('.data') ] |
yzshen1
2017/03/23 17:46:20
Does listdir() return absolute path or relative pa
damargulis
2017/03/24 19:44:48
listdir() takes in a relative path, and returns on
|
+ out = file(sys.argv[2], 'w') |
+ output_dir = sys.argv[2].rsplit('/', 1)[0] + '/data' |
+ if not path.exists(output_dir): |
+ makedirs(output_dir) |
+ with out: |
+ for f in files: |
+ copy(sys.argv[1] + '/' + f + '.data', output_dir) |
+ copy(sys.argv[1] + '/' + f + '.expected', output_dir) |
+ out.write(f + '\n') |
+ |
+gen_files() |