Skip to content

Commit

Permalink
Create fake executable prior intitiating fake command
Browse files Browse the repository at this point in the history
The change simplifies the analysis of faild tests as the first log lines
always will be a fake executable creation, and other lines will be about
creation of fake commands.
  • Loading branch information
extsoft committed Sep 30, 2019
1 parent eb5fffa commit 5643820
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/addons-fake.bash
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,9 @@ fake() {
FIXTURE_HOME="$PROGRAM_PATH/$(echo "$2" | sed 's/[^0-9a-zA-Z]*//g')"
MOCK="$MOCK_DIR/$BASENAME"

[[ -d "$FIXTURE_HOME" ]] && rm -r "$FIXTURE_HOME"
echo ""
echo "==>> Creating mock: ${FIXTURE_HOME}"
_ex_fake mkdir -p "$FIXTURE_HOME"
echo -e "$3" | tee -i "$FIXTURE_HOME/exit_code"
echo -e "$4" | tee -i "$FIXTURE_HOME/stdout"
echo -e "$5" | tee -i "$FIXTURE_HOME/stderr"

if [[ ! -e "${MOCK}" ]]; then
echo ""
echo "==>> Creating executable: ${MOCK}"
echo "==>> Creating fake executable: ${MOCK}"
ORIGIN_BINARY=$(which ${BASENAME})
cat <<MOCK | tee -i ${MOCK} && _ex_fake chmod +x "$MOCK"
#!/usr/bin/env bash
Expand All @@ -49,6 +41,14 @@ else
fi
MOCK
fi

[[ -d "$FIXTURE_HOME" ]] && rm -r "$FIXTURE_HOME"
echo ""
echo "==>> Creating fake command: ${FIXTURE_HOME}"
_ex_fake mkdir -p "$FIXTURE_HOME"
echo -e "$3" | tee -i "$FIXTURE_HOME/exit_code"
echo -e "$4" | tee -i "$FIXTURE_HOME/stdout"
echo -e "$5" | tee -i "$FIXTURE_HOME/stderr"
}

fake-pass() {
Expand Down

0 comments on commit 5643820

Please sign in to comment.