Corentin Wallez | 76b49d5 | 2022-04-12 16:10:41 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Austin Eng | 1cdea90 | 2022-03-24 00:21:55 +0000 | [diff] [blame] | 2 | # |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 3 | # Copyright 2022 The Dawn & Tint Authors |
Austin Eng | 1cdea90 | 2022-03-24 00:21:55 +0000 | [diff] [blame] | 4 | # |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 5 | # Redistribution and use in source and binary forms, with or without |
| 6 | # modification, are permitted provided that the following conditions are met: |
Austin Eng | 1cdea90 | 2022-03-24 00:21:55 +0000 | [diff] [blame] | 7 | # |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 8 | # 1. Redistributions of source code must retain the above copyright notice, this |
| 9 | # list of conditions and the following disclaimer. |
Austin Eng | 1cdea90 | 2022-03-24 00:21:55 +0000 | [diff] [blame] | 10 | # |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 11 | # 2. Redistributions in binary form must reproduce the above copyright notice, |
| 12 | # this list of conditions and the following disclaimer in the documentation |
| 13 | # and/or other materials provided with the distribution. |
| 14 | # |
| 15 | # 3. Neither the name of the copyright holder nor the names of its |
| 16 | # contributors may be used to endorse or promote products derived from |
| 17 | # this software without specific prior written permission. |
| 18 | # |
| 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 22 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 23 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 27 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Austin Eng | 1cdea90 | 2022-03-24 00:21:55 +0000 | [diff] [blame] | 29 | |
| 30 | import argparse |
| 31 | import logging |
| 32 | import os |
| 33 | import shutil |
| 34 | import sys |
| 35 | import tempfile |
| 36 | |
| 37 | from dir_paths import node_dir |
| 38 | |
| 39 | from compile_src import compile_src_for_node |
| 40 | |
| 41 | |
| 42 | def list_testcases(query, js_out_dir=None): |
| 43 | if js_out_dir is None: |
| 44 | js_out_dir = tempfile.mkdtemp() |
| 45 | delete_js_out_dir = True |
| 46 | else: |
| 47 | delete_js_out_dir = False |
| 48 | |
| 49 | try: |
| 50 | logging.info('WebGPU CTS: Transpiling tools...') |
Austin Eng | 552045a | 2022-05-10 18:17:54 +0000 | [diff] [blame] | 51 | # TODO(crbug.com/dawn/1395): Bring back usage of an incremental build to |
| 52 | # speed up this operation. It was disabled due to flakiness. |
| 53 | compile_src_for_node(js_out_dir) |
Austin Eng | 1cdea90 | 2022-03-24 00:21:55 +0000 | [diff] [blame] | 54 | |
| 55 | old_sys_path = sys.path |
| 56 | try: |
| 57 | sys.path = old_sys_path + [node_dir] |
| 58 | from node import RunNode |
| 59 | finally: |
| 60 | sys.path = old_sys_path |
| 61 | |
| 62 | return RunNode([ |
| 63 | os.path.join(js_out_dir, 'common', 'runtime', 'cmdline.js'), query, |
| 64 | '--list' |
| 65 | ]) |
| 66 | finally: |
| 67 | if delete_js_out_dir: |
| 68 | shutil.rmtree(js_out_dir) |
| 69 | |
| 70 | |
| 71 | # List all testcases matching a test query. |
| 72 | if __name__ == '__main__': |
| 73 | parser = argparse.ArgumentParser() |
| 74 | parser.add_argument('--query', default='webgpu:*', help='WebGPU CTS Query') |
| 75 | parser.add_argument( |
| 76 | '--js-out-dir', |
| 77 | default=None, |
| 78 | help='Output directory for intermediate compiled JS sources') |
| 79 | args = parser.parse_args() |
| 80 | |
| 81 | print(list_testcases(args.query, args.js_out_dir)) |