-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
236 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
default: bash_interactive | ||
bash_interactive: | ||
docker-compose -f testenv/shellfuncs/bashenv/docker-compose.yaml build | ||
docker-compose -f testenv/shellfuncs/bashenv/docker-compose.yaml run --rm fasttravelcli_bash_interactive | ||
default: all | ||
|
||
all: bash_script | ||
|
||
bash_script_interactive: | ||
docker-compose -f testenv/shellfuncs/docker-compose.yaml build fasttravelcli_bash_script_interactive | ||
docker-compose -f testenv/shellfuncs/docker-compose.yaml run --rm fasttravelcli_bash_script_interactive | ||
|
||
bash_script: | ||
docker-compose -f testenv/shellfuncs/docker-compose.yaml up fasttravelcli_bash_script --build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
|
||
# This test script is designed to test the ftmain.sh file independent of fastTravelCLI's binary. | ||
# Use by calling the simtest function. | ||
# This script will build simulations to run through automatically. | ||
# setup.sh and ftmain.sh need to be sourced prior to execution of these simulations. This step is added to the .bashrc in Docker. | ||
# To manually test specific commands, utilize the testcmd function found in setup.sh. | ||
|
||
|
||
|
||
simtest() { | ||
# User can set number of simulations or use default of 15 | ||
if [[ $# -ne 1 ]]; then | ||
sims=15 | ||
else | ||
if ! [[ "$1" =~ ^[0-9]+$ ]]; then | ||
echo "Argument must be a number! Arg: $1" >&2 | ||
exit 1 | ||
fi | ||
sims=$1 | ||
fi | ||
|
||
# Generate a random simulation | ||
# Setup script will define the commands | ||
generateSim() { | ||
local totalcmds=$1 | ||
# Start the simulation more towards the middle of the history stack | ||
local sim=("[" "[" "[" "[" "[" "[") | ||
for ((i = 0; i < totalcmds; i++)); do | ||
local idx=$(( RANDOM % ${#commands[@]} )) | ||
sim+=("${commands[idx]}") | ||
done | ||
echo "${sim[@]}" | ||
} | ||
|
||
# Create the simulation | ||
simulation=($(generateSim "$sims")) | ||
|
||
# Process the commands | ||
for cmd in "${simulation[@]}"; do | ||
echo -e "--- History stack: \n $(ft__phist)\n-----" | ||
echo -e "--- Currently at directory: $(pwd)\n--->" | ||
|
||
ft "$cmd" | ||
|
||
echo "<---" | ||
|
||
done | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# run docker-compose from root dir | ||
FROM ubuntu:latest | ||
|
||
# Set non-interactive mode for apt-get | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
WORKDIR /testspace | ||
|
||
COPY ../../../shells/tests/bashscripts/ ./ | ||
|
||
COPY ../../../shells/bash/ ./ | ||
|
||
RUN chmod +x ./exe.sh | ||
|
||
# Update/install dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
git \ | ||
curl \ | ||
tree \ | ||
lua5.4 \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Install fzf | ||
RUN git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf && \ | ||
~/.fzf/install --all | ||
|
||
# Set up fzf in the shell | ||
RUN echo 'source ~/.fzf.bash' >> ~/.bashrc | ||
|
||
# Source scripts used to run tests | ||
RUN echo 'source setup.sh' >> ~/.bashrc | ||
|
||
RUN echo 'source ftmain.sh' >> ~/.bashrc | ||
|
||
RUN echo 'source interactive_test.sh' >> ~/.bashrc | ||
|
||
|
||
|
||
CMD ["/bin/bash"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# run from project root dir | ||
services: | ||
|
||
fasttravelcli_bash_script_interactive: | ||
build: | ||
context: ../.. | ||
dockerfile: testenv/shellfuncs/bashenv/interactive/Dockerfile | ||
container_name: fasttravelcli_bash_script_interactive | ||
stdin_open: true | ||
tty: true | ||
|
||
fasttravelcli_bash_script: | ||
build: | ||
context: ../.. | ||
dockerfile: testenv/shellfuncs/bashenv/Dockerfile | ||
container_name: fasttravelcli_bash_script | ||
stdin_open: true | ||
tty: true | ||
|
||
fasttravelcli_ft_command: | ||
build: | ||
context: ../.. | ||
dockerfile: testenv/ft/Dockerfile | ||
container_name: ft_cli_tool | ||
|