Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAFT: make aliases load very late #2043

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ For ``aliases``\ , ``plugins`` and ``completions``\ , the following rules are ap
* Within the common ``enabled`` directories, the files are loaded in alphabetical order, which is based on the item's load priority (see next item).
* When enabling a component, a *load priority* is assigned to the file. The following default priorities are used:

* Aliases: 150
* Aliases: 750
* Plugins: 250
* Completions: 350

Expand All @@ -78,7 +78,7 @@ For ``aliases``\ , ``plugins`` and ``completions``\ , the following rules are ap
# BASH_IT_LOAD_PRIORITY: 225
Having the order based on a numeric priority in a common directory allows for more flexibility. While in general, aliases are loaded first (since their default priority is 150), it's possible to load some aliases after the plugins, or some plugins after completions by setting the items' load priority. This is more flexible than a fixed type-based order or a strict alphabetical order based on name.
Having the order based on a numeric priority in a common directory allows for more flexibility. While in general, aliases are loaded last (since their default priority is 750), it's possible to load some aliases before the plugins, or some plugins after completions by setting the items' load priority. This is more flexible than a fixed type-based order or a strict alphabetical order based on name. Do not schedule aliases earlier than anything else unless you know what you are doing.

These items are subject to change. When making changes to the internal functionality, this page needs to be updated as well.

Expand Down
2 changes: 1 addition & 1 deletion lib/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# A collection of reusable functions.

: "${BASH_IT_LOAD_PRIORITY_ALIAS:=150}"
: "${BASH_IT_LOAD_PRIORITY_ALIAS:=750}"
: "${BASH_IT_LOAD_PRIORITY_PLUGIN:=250}"
: "${BASH_IT_LOAD_PRIORITY_COMPLETION:=350}"
BASH_IT_LOAD_PRIORITY_SEPARATOR="---"
Expand Down
88 changes: 44 additions & 44 deletions test/bash_it/bash_it.bats
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ function local_setup {
ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash
assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash"

ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/150---a.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/150---a.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/150---b.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/150---b.aliases.bash"
ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/750---a.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/750---a.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/750---b.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/750---b.aliases.bash"

# The `test_alias` alias should not exist
run alias test_alias &> /dev/null
Expand All @@ -51,10 +51,10 @@ function local_setup {
ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash
assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash"

ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/175---a.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/175---a.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/150---b.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/150---b.aliases.bash"
ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/755---a.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/755---a.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/750---b.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/750---b.aliases.bash"

# The `test_alias` alias should not exist
run alias test_alias &> /dev/null
Expand All @@ -74,10 +74,10 @@ function local_setup {
ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash
assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash"

ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/150---a.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/150---a.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/150---b.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/150---b.aliases.bash"
ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/750---a.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/750---a.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/750---b.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/750---b.aliases.bash"
ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/plugins/enabled/250---c.plugin.bash
assert_link_exist "$BASH_IT/plugins/enabled/250---c.plugin.bash"

Expand All @@ -100,8 +100,8 @@ function local_setup {
ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash
assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash"

ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/150---a.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/150---a.aliases.bash"
ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/750---a.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/750---a.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/completion/enabled/350---b.completion.bash
assert_link_exist "$BASH_IT/completion/enabled/350---b.completion.bash"
ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/plugins/enabled/250---c.plugin.bash
Expand Down Expand Up @@ -155,8 +155,8 @@ function local_setup {

ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/aliases/enabled/350---a.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/350---a.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/150---b.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/150---b.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/750---b.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/750---b.aliases.bash"
ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/plugins/enabled/250---c.plugin.bash
assert_link_exist "$BASH_IT/plugins/enabled/250---c.plugin.bash"

Expand All @@ -179,10 +179,10 @@ function local_setup {
ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/enabled/250---base.plugin.bash
assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash"

ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/150---a.aliases.bash
assert_link_exist "$BASH_IT/enabled/150---a.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/150---b.aliases.bash
assert_link_exist "$BASH_IT/enabled/150---b.aliases.bash"
ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/750---a.aliases.bash
assert_link_exist "$BASH_IT/enabled/750---a.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/750---b.aliases.bash
assert_link_exist "$BASH_IT/enabled/750---b.aliases.bash"

# The `test_alias` alias should not exist
run alias test_alias &> /dev/null
Expand All @@ -201,10 +201,10 @@ function local_setup {
ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/enabled/250---base.plugin.bash
assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash"

ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/175---a.aliases.bash
assert_link_exist "$BASH_IT/enabled/175---a.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/150---b.aliases.bash
assert_link_exist "$BASH_IT/enabled/150---b.aliases.bash"
ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/755---a.aliases.bash
assert_link_exist "$BASH_IT/enabled/755---a.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/750---b.aliases.bash
assert_link_exist "$BASH_IT/enabled/750---b.aliases.bash"

# The `test_alias` alias should not exist
run alias test_alias &> /dev/null
Expand All @@ -223,12 +223,12 @@ function local_setup {
ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/enabled/250---base.plugin.bash
assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash"

ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/150---a.aliases.bash
assert_link_exist "$BASH_IT/enabled/150---a.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/150---b.aliases.bash
assert_link_exist "$BASH_IT/enabled/150---b.aliases.bash"
ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/enabled/250---c.plugin.bash
assert_link_exist "$BASH_IT/enabled/250---c.plugin.bash"
ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/755---a.aliases.bash
assert_link_exist "$BASH_IT/enabled/755---a.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/750---b.aliases.bash
assert_link_exist "$BASH_IT/enabled/750---b.aliases.bash"
ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/enabled/850---c.plugin.bash
assert_link_exist "$BASH_IT/enabled/850---c.plugin.bash"

# The `test_alias` alias should not exist
run alias test_alias &> /dev/null
Expand All @@ -247,12 +247,12 @@ function local_setup {
ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/enabled/250---base.plugin.bash
assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash"

ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/350---a.aliases.bash
assert_link_exist "$BASH_IT/enabled/350---a.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/150---b.aliases.bash
assert_link_exist "$BASH_IT/enabled/150---b.aliases.bash"
ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/enabled/250---c.plugin.bash
assert_link_exist "$BASH_IT/enabled/250---c.plugin.bash"
ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/950---a.aliases.bash
assert_link_exist "$BASH_IT/enabled/950---a.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/750---b.aliases.bash
assert_link_exist "$BASH_IT/enabled/750---b.aliases.bash"
ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/enabled/850---c.plugin.bash
assert_link_exist "$BASH_IT/enabled/850---c.plugin.bash"

# The `test_alias` alias should not exist
run alias test_alias &> /dev/null
Expand All @@ -276,13 +276,13 @@ function local_setup {

ln -s $BASH_IT/aliases/available/a.aliases.bash $BASH_IT/enabled/350---a.aliases.bash
assert_link_exist "$BASH_IT/enabled/350---a.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/150---b.aliases.bash
assert_link_exist "$BASH_IT/enabled/150---b.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/enabled/750---b.aliases.bash
assert_link_exist "$BASH_IT/enabled/750---b.aliases.bash"
ln -s $BASH_IT/plugins/available/c.plugin.bash $BASH_IT/enabled/250---c.plugin.bash
assert_link_exist "$BASH_IT/enabled/250---c.plugin.bash"
# Add one file in the old directory structure
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/150---b.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/150---b.aliases.bash"
ln -s $BASH_IT/aliases/available/b.aliases.bash $BASH_IT/aliases/enabled/750---b.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/750---b.aliases.bash"

# The `test_alias` alias should not exist
run alias test_alias &> /dev/null
Expand All @@ -299,8 +299,8 @@ function local_setup {

@test "bash-it: load enabled aliases from new structure, priority-based" {
mkdir -p $BASH_IT/enabled
ln -s $BASH_IT/aliases/available/atom.aliases.bash $BASH_IT/enabled/150---atom.aliases.bash
assert_link_exist "$BASH_IT/enabled/150---atom.aliases.bash"
ln -s $BASH_IT/aliases/available/atom.aliases.bash $BASH_IT/enabled/750---atom.aliases.bash
assert_link_exist "$BASH_IT/enabled/750---atom.aliases.bash"
ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/enabled/250---base.plugin.bash
assert_link_exist "$BASH_IT/enabled/250---base.plugin.bash"

Expand All @@ -317,8 +317,8 @@ function local_setup {
@test "bash-it: load enabled aliases from old structure, priority-based" {
mkdir -p $BASH_IT/aliases/enabled
mkdir -p $BASH_IT/plugins/enabled
ln -s $BASH_IT/aliases/available/atom.aliases.bash $BASH_IT/aliases/enabled/150---atom.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/150---atom.aliases.bash"
ln -s $BASH_IT/aliases/available/atom.aliases.bash $BASH_IT/aliases/enabled/750---atom.aliases.bash
assert_link_exist "$BASH_IT/aliases/enabled/750---atom.aliases.bash"
ln -s $BASH_IT/plugins/available/base.plugin.bash $BASH_IT/plugins/enabled/250---base.plugin.bash
assert_link_exist "$BASH_IT/plugins/enabled/250---base.plugin.bash"

Expand Down
Loading