File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
main/groovy/ru/vyarus/gradle/plugin/python/cmd
test/groovy/ru/vyarus/gradle/plugin/python/cmd Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -115,12 +115,14 @@ class Pip {
115115 Matcher matcher = VERSION . matcher(versionLine)
116116 if (matcher. find()) {
117117 // note: this will drop beta postfix (e.g. for 10.0.0b2 version will be 10.0.0)
118- return matcher. group(1 )
118+ String ver = matcher. group(1 )
119+ if (ver) {
120+ return ver
121+ }
119122 }
120123 // if can't recognize version, ask directly
121124 return python. withHiddenLog {
122125 python. readOutput(' -c \" import pip; print(pip.__version__)\" ' )
123- .readLines()
124126 }
125127 }
126128
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ import org.gradle.api.Project
44import org.gradle.testfixtures.ProjectBuilder
55import ru.vyarus.gradle.plugin.python.AbstractTest
66
7+ import java.util.regex.Pattern
8+
79/**
810 * @author Vyacheslav Rusakov
911 * @since 20.11.2017
@@ -40,4 +42,26 @@ class PipCliTest extends AbstractTest {
4042 pip. version =~ / \d +\.\d +\.\d +/
4143 pip. versionLine =~ / pip \d +\.\d +\.\d + from/
4244 }
45+
46+ def " Check version parse fail" () {
47+
48+ when : " prepare pip"
49+ Project project = project()
50+ Pip pip = new FooPip (project)
51+ then : " ok"
52+ pip. version =~ / \d +\.\d +\.\d +/
53+
54+ }
55+
56+ class FooPip extends Pip {
57+
58+ FooPip (Project project ) {
59+ super (project)
60+ }
61+
62+ @Override
63+ String getVersionLine () {
64+ return ' you will not parse it'
65+ }
66+ }
4367}
You can’t perform that action at this time.
0 commit comments