@@ -171,7 +171,7 @@ assert_expansion_function() {
171
171
local ws=${PWD}
172
172
local function=" $1 " displacement=" $2 " type=" $3 " expected=" $4 " current=" $5 "
173
173
disable_errexit
174
- local actual_result=$( eval " _bazel__${function} \" ${ws} \" \" ${displacement} \" \" ${current} \" \" ${type} \" " )
174
+ local actual_result=$( eval " _bazel__${function} \" ${ws} \" \" ${displacement} \" \" ${current} \" \" ${type} \" " | sort )
175
175
enable_errexit
176
176
assert_equals " $( echo -ne " ${expected} " ) " " ${actual_result} "
177
177
}
@@ -196,7 +196,7 @@ test_expand_rules_in_package() {
196
196
197
197
# label should match test and non-test rules
198
198
assert_expansion_function " expand_rules_in_package" " " label \
199
- ' token_bucket_test \ntoken_bucket_binary ' \
199
+ ' token_bucket_binary \ntoken_bucket_test ' \
200
200
' video/streamer2:token_bucket_'
201
201
assert_expansion_function " expand_rules_in_package" " " label \
202
202
' stuff ' ' video/streamer2/stuff:s'
@@ -234,7 +234,7 @@ test_expand_rules_in_package() {
234
234
# with BAZEL_COMPLETION_ALLOW_TESTS_FOR_RUN set.
235
235
BAZEL_COMPLETION_ALLOW_TESTS_FOR_RUN=true \
236
236
assert_expansion_function " expand_rules_in_package" " " label-bin \
237
- ' token_bucket_test \ntoken_bucket_binary ' ' video/streamer2:to'
237
+ ' token_bucket_binary \ntoken_bucket_test ' ' video/streamer2:to'
238
238
239
239
# Test the label-bin expands for test rules, with
240
240
# BAZEL_COMPLETION_ALLOW_TESTS_FOR_RUN set.
@@ -303,7 +303,7 @@ test_expand_package_name() {
303
303
304
304
# label-package
305
305
assert_expansion_function " expand_package_name" " " " label-package" \
306
- " //video/streamer2/stuff/ \n//video/streamer2/stuff " \
306
+ " //video/streamer2/stuff \n//video/streamer2/stuff/ " \
307
307
" //video/streamer2/stu"
308
308
assert_expansion_function " expand_package_name" " " " label-package" \
309
309
" //video/notapackage/" \
@@ -357,7 +357,7 @@ test_complete_pattern() {
357
357
" //video/streamer2/stu"
358
358
359
359
assert_expansion_function " complete_pattern" " " label-package \
360
- " //video/streamer2/stuff/ \n//video/streamer2/stuff " \
360
+ " //video/streamer2/stuff \n//video/streamer2/stuff/ " \
361
361
" //video/streamer2/stu"
362
362
363
363
assert_expansion_function " complete_pattern" " " command \
@@ -392,6 +392,19 @@ test_complete_pattern() {
392
392
' ' ' video/streamer2:ta'
393
393
assert_expansion_function " complete_pattern" " video/" label \
394
394
' with_special+_,=-.@~chars ' ' streamer2:with_s'
395
+
396
+ # Path expansion
397
+ if [[ -z $PACKAGE_PATH_PREFIX ]]; then
398
+ assert_expansion_function " complete_pattern" " " path \
399
+ " video/streamer2/BUILD \nvideo/streamer2/names/\nvideo/streamer2/stuff/\nvideo/streamer2/testing/" \
400
+ " video/streamer2/"
401
+ else
402
+ # When $PACKAGE_PATH_PREFIX is set, the "stuff" directory will not be in
403
+ # the same directory as the others, so we have to omit it.
404
+ assert_expansion_function " complete_pattern" " " path \
405
+ " video/streamer2/BUILD \nvideo/streamer2/names/\nvideo/streamer2/testing/" \
406
+ " video/streamer2/"
407
+ fi
395
408
}
396
409
397
410
# ### TESTS #############################################################
@@ -707,6 +720,22 @@ test_target_expansion_in_package() {
707
720
' build :s'
708
721
}
709
722
723
+ test_filename_expansion_after_double_dash () {
724
+ make_packages
725
+ assert_expansion ' run :target -- vid' \
726
+ ' run :target -- video/'
727
+ assert_expansion ' run :target -- video/st' \
728
+ ' run :target -- video/streamer2/'
729
+ assert_expansion ' run :target -- video/streamer2/B' \
730
+ ' run :target -- video/streamer2/BUILD '
731
+ assert_expansion ' run :target -- video/streamer2/n' \
732
+ ' run :target -- video/streamer2/names/'
733
+
734
+ # Autocomplete arguments as well.
735
+ assert_expansion ' run :target -- --arg=video/streamer2/n' \
736
+ ' run :target -- --arg=video/streamer2/names/'
737
+ }
738
+
710
739
test_help () {
711
740
# "Test that bazel help expands subcommand names"
712
741
assert_expansion ' help qu' \
0 commit comments