Skip to content

Instantly share code, notes, and snippets.

@ctubbsii
Created April 26, 2022 18:17
Show Gist options
  • Save ctubbsii/e17bcc9d5a4b71db68b748dd2b6919cf to your computer and use it in GitHub Desktop.
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
#! /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"
@DomGarguilo
Copy link

Whoops, I missed that part. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment