Skip to content

Commit 1db4ae1

Browse files
committed
refactor(test/fallback): symlink "completions-fallback" on the fly
With the current search order, completions in the test environment will be used instead of the in-tree completions of `bash-completion` even for non-fallback completions. To change the ordering of the completions, one needs to make symbolic links for all completions in `test/fallback/completions`. However, with such a setup, all files are duplicated as hard links in the tarball created by `make dist` (because Autoconf creates a tarball with the symbolic links fully resolved to hard links). Instead, in this patch, we try to set up the symbolic links to `completions-core` and `completions-fallback` on the startup of the test suite.
1 parent 47186ae commit 1db4ae1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+25
-192
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repos:
1313
hooks:
1414
- id: shfmt
1515
types: [text]
16-
files: ^(bash_completion(\.d/[^/]+\.bash)?|completions-core/.+|test/(config/bashrc|fixtures/.+/bin/.+|fallback/update-fallback-links|runLint|update-test-cmd-list)|.+\.sh(\.in)?)$
16+
files: ^(bash_completion(\.d/[^/]+\.bash)?|completions-core/.+|test/(config/bashrc|fixtures/.+/bin/.+|runLint|update-test-cmd-list)|.+\.sh(\.in)?)$
1717
exclude: ^completions-core/(\.gitignore|Makefile.*)$
1818

1919
- repo: https://github.com/shellcheck-py/shellcheck-py
@@ -22,7 +22,7 @@ repos:
2222
- id: shellcheck
2323
args: [-f, gcc]
2424
types: [text]
25-
files: ^(bash_completion(\.d/[^/]+\.bash)?|completions-core/.+|test/(config/bashrc|fixtures/.+/bin/.+|fallback/update-fallback-links|runLint|update-test-cmd-list)|.+\.sh(\.in)?)$
25+
files: ^(bash_completion(\.d/[^/]+\.bash)?|completions-core/.+|test/(config/bashrc|fixtures/.+/bin/.+|runLint|update-test-cmd-list)|.+\.sh(\.in)?)$
2626
exclude: ^completions-core/(\.gitignore|Makefile.*)$
2727
require_serial: false # We disable SC1090 anyway, so parallel is ok
2828

@@ -35,13 +35,6 @@ repos:
3535
files: ^test/t/.+\.py$
3636
pass_filenames: false
3737

38-
- id: update-test-fallback-links
39-
name: update-test-fallback-links
40-
language: script
41-
entry: test/fallback/update-fallback-links
42-
files: ^completions-fallback/
43-
pass_filenames: false
44-
4538
- repo: https://github.com/astral-sh/ruff-pre-commit
4639
rev: v0.14.3
4740
hooks:

configure.ac

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ doc/Makefile
4141
helpers/Makefile
4242
helpers-core/Makefile
4343
test/Makefile
44-
test/fallback/Makefile
45-
test/fallback/completions/Makefile
4644
test/t/Makefile
4745
test/t/unit/Makefile
4846
])

test/Makefile.am

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
SUBDIRS = fallback t
1+
SUBDIRS = t
22

3-
EXTRA_DIST = config \
3+
EXTRA_DIST = config/bashrc \
4+
config/inputrc \
45
fixtures \
56
setup.cfg
67

78
CLEANFILES = \
89
fixtures/make/extra_makefile
10+
11+
clean-local:
12+
-rm -rf config/bash-completion config/bash-completion-fallback
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../completions-fallback
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../completions-core

test/config/bashrc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# bashrc file for bash-completion test suite
22

3+
_comp__test_link()
4+
{
5+
local src=$1 dst=$2
6+
if [[ -L $dst || -e $dst ]]; then
7+
rm -rf "$dst"
8+
fi
9+
mkdir -p "${dst%/*}"
10+
ln -sf "$src" "$dst"
11+
}
12+
313
# Note that we do some initialization that would be too late to do here in
414
# conftest.py.
515

@@ -34,9 +44,11 @@ export BASH_COMPLETION_USER_FILE=/dev/null
3444
# overriding in-tree completions. Setting the user dir would otherwise suffice,
3545
# but simple xspec completions are only installed if a separate one is not
3646
# found in *any* completion dirs, and we want to use our "shadow" completion
37-
# dir with which we cause loading of our in-tree fallback completions
38-
# instead of possibly (system-)installed upstream ones.
39-
export BASH_COMPLETION_USER_DIR="$SRCDIRABS/fallback"
47+
# dir with which we cause loading of our in-tree completions instead of
48+
# possibly (system-)installed upstream ones.
49+
_comp__test_link ../../../completions-core "$SRCDIRABS"/config/bash-completion/completions
50+
_comp__test_link ../../../completions-fallback "$SRCDIRABS"/config/bash-completion-fallback/completions
51+
export BASH_COMPLETION_USER_DIR="$SRCDIRABS/config/bash-completion:$SRCDIRABS/config/bash-completion-fallback"
4052
export BASH_COMPLETION_COMPAT_DIR="$SRCDIRABS/../bash_completion.d"
4153
export XDG_DATA_DIRS=/var/empty
4254

test/fallback/Makefile.am

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/fallback/completions/Makefile.am

Lines changed: 0 additions & 70 deletions
This file was deleted.

test/fallback/completions/README.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/fallback/completions/adb.bash

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)