| OLD | NEW |
| 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 | 8 # Usage examples |
| 9 # ============== | 9 # ============== |
| 10 # | 10 # |
| 11 # Browser command line switches: | 11 # Browser command line switches: |
| 12 # $ out/gn/chrome --site-per-pro<tab> | 12 # $ out/gn/chrome --site-per-pro<tab> |
| 13 # $ google-chrome --site-per-pro<tab> | 13 # $ google-chrome --site-per-pro<tab> |
| 14 # | 14 # |
| 15 # Test switches (i.e. --gtest_* and --test-launcher-* switches): | 15 # Test switches (i.e. --gtest_* and --test-launcher-* switches): |
| 16 # $ out/gn/unit_tests --gtest_filt<tab> | 16 # $ out/gn/unit_tests --gtest_filt<tab> |
| 17 # $ out/gn/unit_tests --test-launcher-j<tab> | 17 # $ out/gn/unit_tests --test-launcher-j<tab> |
| 18 # | 18 # |
| 19 # Layout test switches: | 19 # Layout test switches: |
| 20 # $ third_party/WebKit/Tools/Scripts/run-webkit-tests --additional-driver-f<tab> | 20 # $ third_party/WebKit/Tools/Scripts/run-webkit-tests --additional-driver-f<tab> |
| 21 # $ .../run-webkit-tests --additional-driver-flag=--site-per-pro<tab> | 21 # $ .../run-webkit-tests --additional-driver-flag=--site-per-pro<tab> |
| 22 # |
| 23 # Blink webkit-patch sub-commands: |
| 24 # $ third_party/WebKit/Tools/Scripts/webkit-patch reb<tab> |
| 22 | 25 |
| 23 chrome_source=$(cd $(dirname $BASH_SOURCE)/.. && pwd) | 26 if [ -n "$BASH_SOURCE" ]; then |
| 27 # The $BASH_SOURCE variable returns path of current script in bash. |
| 28 chrome_source=$(cd $(dirname $BASH_SOURCE)/.. && pwd) |
| 29 else |
| 30 # This is here for other similar shells, e.g. zsh. |
| 31 chrome_source=$(cd $(dirname $0)/.. && pwd) |
| 32 fi |
| 24 | 33 |
| 25 _chrome_flag() { | 34 _chrome_flag() { |
| 26 local cur targets | 35 local cur targets |
| 27 cur="${COMP_WORDS[COMP_CWORD]}" | 36 cur="${COMP_WORDS[COMP_CWORD]}" |
| 28 targets=$(cd $chrome_source; \ | 37 targets=$(cd $chrome_source; \ |
| 29 git ls-files '*switches*' | \ | 38 git ls-files '*switches*' | \ |
| 30 xargs sed -ne 's/^[^/]*"\([^" /]\{1,\}\)".*/--\1/p') | 39 xargs sed -ne 's/^[^/]*"\([^" /]\{1,\}\)".*/--\1/p') |
| 31 COMPREPLY=($(compgen -W "$targets" -- "$cur")) | 40 COMPREPLY=($(compgen -W "$targets" -- "$cur")) |
| 32 return 0 | 41 return 0 |
| 33 } | 42 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 64 fi | 73 fi |
| 65 | 74 |
| 66 # Complete run-webkit-tests switches. | 75 # Complete run-webkit-tests switches. |
| 67 webkitpy_dir="$chrome_source/third_party/WebKit/Tools/Scripts/webkitpy" | 76 webkitpy_dir="$chrome_source/third_party/WebKit/Tools/Scripts/webkitpy" |
| 68 targets=$(sed -ne 's/^[[:space:]]*"\(--[a-z-]\+\)",[[:space:]]*$/\1/p' \ | 77 targets=$(sed -ne 's/^[[:space:]]*"\(--[a-z-]\+\)",[[:space:]]*$/\1/p' \ |
| 69 "$webkitpy_dir/layout_tests/run_webkit_tests.py") | 78 "$webkitpy_dir/layout_tests/run_webkit_tests.py") |
| 70 COMPREPLY=($(compgen -W "$targets" -- "$cur")) | 79 COMPREPLY=($(compgen -W "$targets" -- "$cur")) |
| 71 return 0 | 80 return 0 |
| 72 } | 81 } |
| 73 | 82 |
| 83 _webkit_patch_flag() { |
| 84 local cur targets webkit_scripts_dir |
| 85 cur="${COMP_WORDS[COMP_CWORD]}" |
| 86 webkit_scripts_dir=$chrome_source/third_party/WebKit/Tools/Scripts |
| 87 targets=$($webkit_scripts_dir/webkit-patch help | grep '^ [a-z]' | \ |
| 88 awk '{ print $1 }') |
| 89 COMPREPLY=($(compgen -W "$targets" -- "$cur")) |
| 90 return 0 |
| 91 } |
| 92 |
| 74 complete -F _chrome_flag google-chrome | 93 complete -F _chrome_flag google-chrome |
| 75 complete -F _chrome_flag chrome | 94 complete -F _chrome_flag chrome |
| 76 if [ $(uname) = "Darwin" ] | 95 if [ $(uname) = "Darwin" ] |
| 77 then | 96 then |
| 78 complete -F _chrome_flag Chromium | 97 complete -F _chrome_flag Chromium |
| 79 fi | 98 fi |
| 80 | 99 |
| 81 for gtest_test_executable in $( | 100 for gtest_test_executable in $( |
| 82 cd $chrome_source; | 101 cd $chrome_source; |
| 83 git ls-files '*/BUILD.gn' | xargs sed -ne 's/^.*test("\([^"]\+\)").*$/\1/p' | 102 git ls-files '*/BUILD.gn' | xargs sed -ne 's/^.*test("\([^"]\+\)").*$/\1/p' |
| 84 ); do | 103 ); do |
| 85 complete -F _gtest_flag $gtest_test_executable | 104 complete -F _gtest_flag $gtest_test_executable |
| 86 done | 105 done |
| 87 | 106 |
| 88 complete -F _layout_test_flag run-webkit-tests | 107 complete -F _layout_test_flag run-webkit-tests |
| 108 complete -F _webkit_patch_flag webkit-patch |
| OLD | NEW |