Skip to content

Commit

Permalink
feat: add possible testing framework for harpoon
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaitanyabsprip committed Jun 12, 2024
1 parent b5011e3 commit 172df24
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
13 changes: 13 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,16 @@ install: ./harpoon

uninstall:
@rm $(INSTALL_PATH)

test: docker
@docker run -h harpoon-test --name harpoon-test harpoon-test

docker: test/Dockerfile harpoon test/driver.sh --clean
@docker build -t harpoon-test -f test/Dockerfile .

--clean:
@docker ps -a --format '{{.Image}}' | grep -w "harpoon-test" \
| xargs -I {} docker rm {} >/dev/null 2>&1 || :;
@docker images -a --format '{{.Repository}}' | grep -w "harpoon-test" \
| xargs -I {} docker rmi {} >/dev/null 2>&1 || :;

15 changes: 15 additions & 0 deletions test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ubuntu:latest

WORKDIR /root

RUN apt update -yq && apt install -yq tmux curl wget git && cd \
&& git clone https://github.com/junegunn/fzf.git --depth 1
RUN cd /root/fzf && ./install --all
RUN apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/log/dmesg.* && \
cat /dev/null > /var/log/dmesg

COPY ./harpoon /bin/harpoon
COPY ./test/driver.sh /bin/driver

ENTRYPOINT [ "driver" ]
29 changes: 29 additions & 0 deletions test/driver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

! type harpoon >/dev/null && echo "Could not find harpoon" && exit 1

setup() {
mkdir /root/.cache
TERM="${TERM:-screen256color}"
tmux new -ds home
cachefile=/root/.cache/.tmux-harpoon-sessions
harpoon -h >/dev/null
}

failed() {
echo "$LINENO Failed"
exit 1
}

setup

! [ "$(cat "$cachefile")" = "" ] && failed
echo pass

tmux ls
tmux -V
tmux send-keys -t "home" Enter "harpoon -a" Enter
sleep 1

! [ "$(cat "$cachefile")" = "home=/root" ] && failed
echo "pass"

0 comments on commit 172df24

Please sign in to comment.