diff --git a/src/com/ableton/Pyenv.groovy b/src/com/ableton/Pyenv.groovy index 1e387a1..fb17bf1 100644 --- a/src/com/ableton/Pyenv.groovy +++ b/src/com/ableton/Pyenv.groovy @@ -120,8 +120,8 @@ class Pyenv implements Serializable { protected void assertPyenvRoot() { assert pyenvRoot - if (!script.fileExists(pyenvRoot)) { - script.error "pyenv root path '${pyenvRoot}' does not exist" + if (script.sh(returnStatus: true, script: "${pyenvRoot}/bin/pyenv --version")) { + script.error "pyenv executable not found in '${pyenvRoot}'" } } } diff --git a/test/com/ableton/PyenvTest.groovy b/test/com/ableton/PyenvTest.groovy index df3b212..d984774 100644 --- a/test/com/ableton/PyenvTest.groovy +++ b/test/com/ableton/PyenvTest.groovy @@ -35,8 +35,8 @@ class PyenvTest extends BasePipelineTest { @Test void assertPyenvRootInvalidRoot() { String pyenvRoot = '/mock/pyenv/root' - helper.registerAllowedMethod('fileExists', [String]) { return false } helper.registerAllowedMethod('isUnix', []) { return true } + helper.addShMock("${pyenvRoot}/bin/pyenv --version", '1.2.3', 0) assertThrows(Exception) { new Pyenv(script, '1.2.3', pyenvRoot).createVirtualEnv() } } @@ -52,8 +52,8 @@ class PyenvTest extends BasePipelineTest { void createVirtualEnv() { String pythonVersion = '1.2.3' String pyenvRoot = '/mock/pyenv/root' - helper.registerAllowedMethod('fileExists', [String]) { return true } helper.registerAllowedMethod('isUnix', []) { return true } + helper.addShMock("${pyenvRoot}/bin/pyenv --version", '1.2.3', 0) helper.addShMock(installCommands(pyenvRoot, pythonVersion), '', 0) Object venv = new Pyenv(script, pyenvRoot).createVirtualEnv(pythonVersion, 1) @@ -74,7 +74,6 @@ class PyenvTest extends BasePipelineTest { String pyenvRoot = '/mock/pyenv/root' boolean errorCalled = false helper.registerAllowedMethod('error', [String]) { errorCalled = true } - helper.registerAllowedMethod('fileExists', [String]) { return true } helper.registerAllowedMethod('isUnix', []) { return true } helper.addShMock("${pyenvRoot}/bin/pyenv --version", '1.2.3', 0) helper.addShMock(installCommands(pyenvRoot, pythonVersion), '', 1) @@ -93,8 +92,8 @@ class PyenvTest extends BasePipelineTest { 2.3.7 ''' String pyenvRoot = '/pyenv' + helper.addShMock("${pyenvRoot}/bin/pyenv --version", '1.2.3', 0) helper.addShMock("${pyenvRoot}/bin/pyenv install --list", mockPyenvVersions, 0) - helper.registerAllowedMethod('fileExists', [String]) { return true } helper.registerAllowedMethod('isUnix', []) { return true } assertTrue(new Pyenv(script, pyenvRoot).versionSupported('2.1.3'))