Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(805)

Side by Side Diff: tools/bash-completion

Issue 2435893002: Bash completion support for run-webkit-tests (i.e. for layout tests). (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 # Flag completion rule for bash. 5 # Flag completion rule for bash.
6 # To load in your shell, "source path/to/this/file". 6 # To load in your shell, "source path/to/this/file".
7 7
8 # Usage examples
9 # ==============
10 #
11 # Browser command line switches:
12 # $ out/gn/chrome --site-per-pro<tab>
13 # $ google-chrome --site-per-pro<tab>
14 #
15 # Test switches (i.e. --gtest_* and --test-launcher-* switches):
16 # $ out/gn/unit_tests --gtest_filt<tab>
17 # $ out/gn/unit_tests --test-launcher-j<tab>
18 #
19 # Layout test switches:
20 # $ third_party/WebKit/Tools/Scripts/run-webkit-tests --additional-driver-f<tab>
21 # $ .../run-webkit-tests --additional-driver-flag=--site-per-pro<tab>
22
8 chrome_source=$(cd $(dirname $BASH_SOURCE)/.. && pwd) 23 chrome_source=$(cd $(dirname $BASH_SOURCE)/.. && pwd)
9 24
10 _chrome_flag() { 25 _chrome_flag() {
11 local cur targets 26 local cur targets
12 cur="${COMP_WORDS[COMP_CWORD]}" 27 cur="${COMP_WORDS[COMP_CWORD]}"
13 targets=$(cd $chrome_source; \ 28 targets=$(cd $chrome_source; \
14 git ls-files '*switches*' | \ 29 git ls-files '*switches*' | \
15 xargs sed -ne 's/^[^/]*"\([^" /]\{1,\}\)".*/--\1/p') 30 xargs sed -ne 's/^[^/]*"\([^" /]\{1,\}\)".*/--\1/p')
16 COMPREPLY=($(compgen -W "$targets" -- "$cur")) 31 COMPREPLY=($(compgen -W "$targets" -- "$cur"))
17 return 0 32 return 0
18 } 33 }
19 34
20 _gtest_flag() { 35 _gtest_flag() {
21 local cur gtest_flags launcher_flags 36 local cur gtest_flags launcher_flags
22 cur="${COMP_WORDS[COMP_CWORD]}" 37 cur="${COMP_WORDS[COMP_CWORD]}"
23 gtest_flags=$(sed -ne 's/^.*FromGTestEnv("\([^" /]\+\)".*$/--gtest_\1/p' \ 38 gtest_flags=$(sed -ne 's/^.*FromGTestEnv("\([^" /]\+\)".*$/--gtest_\1/p' \
24 "$chrome_source/testing/gtest/src/gtest.cc") 39 "$chrome_source/testing/gtest/src/gtest.cc")
25 chrome_test_launcher_flags=$(sed -ne 's/^[^/]*"\([^" /]\{1,\}\)".*/--\1/p' \ 40 chrome_test_launcher_flags=$(sed -ne 's/^[^/]*"\([^" /]\{1,\}\)".*/--\1/p' \
26 "$chrome_source/base/test/test_switches.cc") 41 "$chrome_source/base/test/test_switches.cc")
27 COMPREPLY=($( 42 COMPREPLY=($(
28 compgen -W "$gtest_flags $chrome_test_launcher_flags" -- "$cur")) 43 compgen -W "$gtest_flags $chrome_test_launcher_flags" -- "$cur"))
29 return 0 44 return 0
30 } 45 }
31 46
47 _layout_test_flag() {
48 local cur targets webkitpy_dir prev_switch
49 cur="${COMP_WORDS[COMP_CWORD]}"
50
51 # Complete content_shell switches if appropriate.
52 if [ "${COMP_CWORD}" -gt 2 -a "${COMP_WORDS[COMP_CWORD-1]}" = "=" ]
53 then
54 prev_switch="${COMP_WORDS[COMP_CWORD-2]}"
55 if [ "$prev_switch" = "--additional-drt-flag" -o \
56 "$prev_switch" = "--additional-driver-flag" ]
57 then
58 targets=$(cd $chrome_source; \
59 git ls-files 'content/*switches*.cc' | \
60 xargs sed -ne 's/^[^/]*"\([^" /]\{1,\}\)".*/--\1/p')
61 COMPREPLY=($(compgen -W "$targets" -- "$cur"))
62 return 0
63 fi
64 fi
65
66 # Complete run-webkit-tests switches.
67 webkitpy_dir="$chrome_source/third_party/WebKit/Tools/Scripts/webkitpy"
68 targets=$(sed -ne 's/^[[:space:]]*"\(--[a-z-]\+\)",[[:space:]]*$/\1/p' \
69 "$webkitpy_dir/layout_tests/run_webkit_tests.py")
70 COMPREPLY=($(compgen -W "$targets" -- "$cur"))
71 return 0
72 }
73
32 complete -F _chrome_flag google-chrome 74 complete -F _chrome_flag google-chrome
33 complete -F _chrome_flag chrome 75 complete -F _chrome_flag chrome
34 if [ $(uname) = "Darwin" ] 76 if [ $(uname) = "Darwin" ]
35 then 77 then
36 complete -F _chrome_flag Chromium 78 complete -F _chrome_flag Chromium
37 fi 79 fi
38 80
39 for gtest_test_executable in $( 81 for gtest_test_executable in $(
40 cd $chrome_source; 82 cd $chrome_source;
41 git ls-files '*/BUILD.gn' | xargs sed -ne 's/^test("\([^"]\+\)").*$/\1/p' 83 git ls-files '*/BUILD.gn' | xargs sed -ne 's/^test("\([^"]\+\)").*$/\1/p'
42 ); do 84 ); do
43 complete -F _gtest_flag $gtest_test_executable 85 complete -F _gtest_flag $gtest_test_executable
44 done 86 done
87
88 complete -F _layout_test_flag run-webkit-tests
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698