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

Resolve programs used in stub() before modifying PATH #13

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jrdavid
Copy link

@jrdavid jrdavid commented May 9, 2018

ln and mkdir can't be stubbed because they are used in stub.bash after modifying PATH. So resolve them while PATH is still intact and use the absolute path thereafter.

Jean-Rene David and others added 3 commits November 2, 2018 11:36
…k-support-of-arguments-wiht-whitespaces to master

* commit '60758e0d3059c9ba04c8b29e347012b27bcb27e6':
  Fix mockers handling of arguments with white spaces
Jean-Rene David added 3 commits May 14, 2019 09:15
Revert "Merge pull request jasonkarns#1 in BB/bats-mocks from feature/fix-mock-support-of-arguments-wiht-whitespaces to master"

This reverts commit f2a1350, reversing
changes made to 53733e7.
mkdir -p "${BATS_MOCK_BINDIR}"
ln -sf "${BASH_SOURCE[0]%stub.bash}binstub" "${BATS_MOCK_BINDIR}/${program}"
"$MKDIR" -p "${BATS_MOCK_BINDIR}"
"$LN" -sf "${BASH_SOURCE[0]%stub.bash}binstub" "${BATS_MOCK_BINDIR}/${program}"

touch "${BATS_MOCK_TMPDIR}/${program}-stub-plan"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about touch?

Copy link

@Flamefire Flamefire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought the same. Would be great if this gets in. Pointed out a few minor issues and would suggest to rebase to master removing the merge and do-revert commits

@@ -58,7 +58,12 @@ while IFS= read -r line; do

case "$argument" in
"$pattern" ) ;;
* ) result=1 ;;
* )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks similar to my PR #20. Can you test that and if that suits you remove this from this PR

@@ -1,6 +1,9 @@
BATS_MOCK_TMPDIR="${BATS_TMPDIR}"
BATS_MOCK_BINDIR="${BATS_MOCK_TMPDIR}/bin"

MKDIR=$(which mkdir)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly prefix commands with BATS_MOCK to avoid name clashes with user variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants