Created
April 26, 2022 18:17
-
-
Save ctubbsii/e17bcc9d5a4b71db68b748dd2b6919cf to your computer and use it in GitHub Desktop.
git-diffTests : create a Maven command line with -Dtest= and -Dit.test= for changed tests
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
#! /usr/bin/bash | |
function findTests() { | |
{ | |
echo 'blah' | |
git diff --name-only "$2" | grep "$1[.]java" | xargs -n1 basename 2>/dev/null | cut -f1 -d. | |
} | paste -sd, | |
} | |
if [[ -z $1 ]]; then | |
testarg="-Dtest=$(findTests Test HEAD)" | |
itarg="-Dit.test=$(findTests IT HEAD)" | |
else | |
testarg="-Dtest=$(findTests Test "$1")" | |
itarg="-Dit.test=$(findTests IT "$1")" | |
fi | |
echo "$testarg $itarg" 1>&2 | |
echo "$testarg $itarg" |
It would be helpful to have the option to run all tests that are different from a specified branch.
Already supported. That's what lines 14 and 15 do.
I have made a small maven project that parses a text file that is populated by
git diff --name-status main > diff.txt
and provides an output very similar to this tool.
mvn clean verify $(git-diffTests main)
Whoops, I missed that part. Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would be helpful to have the option to run all tests that are different from a specified branch. I find that I often want to run all tests that differ from main, where the changes have already been committed so wont be picked up by the current state of this util.
I have made a small maven project that parses a text file that is populated by
git diff --name-status main > diff.txt
and provides an output very similar to this tool.