I'm trying to write a git hook which would allow me to collect unit testing reports post commit.
I'm on a windows machine but using bash for the hook itself. It seems to run fine. Here's what I have so far:
#!/bin/sh
test_summary=$(pytest -v | grep -E ".+\.py::.+[A-Z]+")
commit_id=$(git rev-parse HEAD)
The issue is that the variable test_summary retains only the last line from the grep match. I know my piped pytest/grep is fine since running it on an interactive msys terminal gives the correct output with all the matches:
$ pytest -v | grep -E ".+.py::.+[A-Z]+"
test_main.py::test_main PASSED [ 33%]
test_main.py::test2 FAILED [ 66%]
test_main.py::test3 PASSED [100%]
test_summary contains the following:
$ echo $test_summary
test_main.py::test3 PASSED [100%]3%]
Why does it only retain the last line plus some mumbo jumbo from the first line?
I don't get it....