Skip to content

Commit

Permalink
✨ add a feature to execute tests within the executioner script
Browse files Browse the repository at this point in the history
  • Loading branch information
rayanramoul committed Dec 28, 2023
1 parent be28c2d commit 4629153
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/Neovim.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ In File
| Visual mode : g c | COMMENT |
| ]m | Jump to next Function/Method |
| Space + r | Run main python file or main bash file at the root |
| Space + t | Run tests with pytest |

TERMINAL :
| Keybinding | Description |
Expand Down
4 changes: 3 additions & 1 deletion dotfiles/.config/nvim/lua/ray/remap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true })
-- vim.cmd("so")
-- end)

-- Execute current file
-- Execute main project file
vim.keymap.set("n", "<leader>r", "<cmd>silent !tmux split-window -v executioner<CR>")
-- Execute tests of actual project
vim.keymap.set("n", "<leader>t", "<cmd>silent !tmux split-window -v executioner -t<CR>")
-- Disable arrows movement
vim.keymap.set('', '<Up>', '<Nop>')
vim.keymap.set('', '<Down>', '<Nop>')
Expand Down
19 changes: 18 additions & 1 deletion dotfiles/scripts/executioner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,21 @@ run_project() {
read -n 1 -s -r -p "Press any key to exit."
}

run_project
run_tests() {
if [ -f "test.sh" ]; then
bash test.sh
# check if there is a tests folder if so pytest it
elif [ -d "tests" ]; then
pytest tests
else
echo "No recognized test script found in the project directory."
fi
# Keep the tmux pane open after the command has finished
read -n 1 -s -r -p "Press any key to exit."
}
# check for presence of -t flag
if [ "$1" == "-t" ]; then
run_tests
else
run_project
fi

0 comments on commit 4629153

Please sign in to comment.