Created
August 7, 2015 12:41
-
-
Save SlyDen/1bcdca4e91dc1a899337 to your computer and use it in GitHub Desktop.
python check in Gradle https://github.com/apache/aurora/blob/master/build.gradle#L118
This file contains hidden or 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
task checkPython << { | |
def python27Executable = ['python2.7', 'python'].find { python -> | |
try { | |
def check = "import sys; sys.exit(0 if sys.version_info >= (2,7) and sys.version_info < (3,) else 1)" | |
return [python, "-c", check].execute().waitFor() == 0 | |
} catch (IOException e) { | |
return false | |
} | |
} | |
if (python27Executable == null) { | |
throw new GradleException('Build requires Python 2.7.') | |
} else { | |
thriftEntities.python = python27Executable | |
} | |
} | |
generateThriftEntitiesJava.dependsOn checkPython |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/captsens/clichart/blob/master/build.gradle#L58
task pythonTests << {
runPythonTests(false)
}
task pythonCoverage << {
runPythonTests(true)
}
def runPythonTests(def includeCoverage) {
def sourceFiles = fileTree(pythonScriptDir).include('/*.py')
def testFiles = fileTree('src/test/python').include('/*Test.py')
def pythonCoverageDir = file("$buildDir/reports/pythonCoverage")
def arguments = []
if (includeCoverage) {
arguments = ['--with-coverage', '--cover-erase', '--cover-html', '--cover-html-dir',
pythonCoverageDir]
delete(pythonCoverageDir)
logger.lifecycle "Coverage report can be found in $pythonCoverageDir"
}
exec {
executable = "nosetests"
args = arguments + testFiles.collect{it.getPath()}
environment = ['PYTHONPATH': pythonScriptDir]
}
}