blob: 08bf469b7896876dd6e04536beef74156dd36eb7 [file] [log] [blame]
Corentin Wallez76b49d52022-04-12 16:10:41 +00001#!/usr/bin/env python3
Austin Eng1cdea902022-03-24 00:21:55 +00002#
Austin Engcc2516a2023-10-17 20:57:54 +00003# Copyright 2022 The Dawn & Tint Authors
Austin Eng1cdea902022-03-24 00:21:55 +00004#
Austin Engcc2516a2023-10-17 20:57:54 +00005# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are met:
Austin Eng1cdea902022-03-24 00:21:55 +00007#
Austin Engcc2516a2023-10-17 20:57:54 +00008# 1. Redistributions of source code must retain the above copyright notice, this
9# list of conditions and the following disclaimer.
Austin Eng1cdea902022-03-24 00:21:55 +000010#
Austin Engcc2516a2023-10-17 20:57:54 +000011# 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 Eng1cdea902022-03-24 00:21:55 +000029
30import argparse
31import logging
32import os
33import shutil
34import sys
35import tempfile
36
37from dir_paths import node_dir
38
39from compile_src import compile_src_for_node
40
41
42def 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 Eng552045a2022-05-10 18:17:54 +000051 # 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 Eng1cdea902022-03-24 00:21:55 +000054
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.
72if __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))