mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 00:04:42 +04:00
Move PrefixedCommandRunner -> Prefix
This commit is contained in:
parent
c751f629a6
commit
7d87da8acd
23 changed files with 270 additions and 372 deletions
|
|
@ -1,39 +1,42 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import os.path
|
||||
import pipes
|
||||
|
||||
from pre_commit.languages.ruby import _install_rbenv
|
||||
from pre_commit.prefix import Prefix
|
||||
from pre_commit.util import cmd_output
|
||||
from testing.util import xfailif_windows_no_ruby
|
||||
|
||||
|
||||
@xfailif_windows_no_ruby
|
||||
def test_install_rbenv(cmd_runner):
|
||||
_install_rbenv(cmd_runner)
|
||||
def test_install_rbenv(tempdir_factory):
|
||||
prefix = Prefix(tempdir_factory.get())
|
||||
_install_rbenv(prefix)
|
||||
# Should have created rbenv directory
|
||||
assert os.path.exists(cmd_runner.path('rbenv-default'))
|
||||
assert os.path.exists(prefix.path('rbenv-default'))
|
||||
# We should have created our `activate` script
|
||||
activate_path = cmd_runner.path('rbenv-default', 'bin', 'activate')
|
||||
activate_path = prefix.path('rbenv-default', 'bin', 'activate')
|
||||
assert os.path.exists(activate_path)
|
||||
|
||||
# Should be able to activate using our script and access rbenv
|
||||
cmd_runner.run(
|
||||
[
|
||||
'bash',
|
||||
'-c',
|
||||
". '{prefix}rbenv-default/bin/activate' && rbenv --help",
|
||||
],
|
||||
cmd_output(
|
||||
'bash', '-c',
|
||||
'. {} && rbenv --help'.format(pipes.quote(prefix.path(
|
||||
'rbenv-default', 'bin', 'activate',
|
||||
))),
|
||||
)
|
||||
|
||||
|
||||
@xfailif_windows_no_ruby
|
||||
def test_install_rbenv_with_version(cmd_runner):
|
||||
_install_rbenv(cmd_runner, version='1.9.3p547')
|
||||
def test_install_rbenv_with_version(tempdir_factory):
|
||||
prefix = Prefix(tempdir_factory.get())
|
||||
_install_rbenv(prefix, version='1.9.3p547')
|
||||
|
||||
# Should be able to activate and use rbenv install
|
||||
cmd_runner.run(
|
||||
[
|
||||
'bash',
|
||||
'-c',
|
||||
". '{prefix}rbenv-1.9.3p547/bin/activate' && rbenv install --help",
|
||||
],
|
||||
cmd_output(
|
||||
'bash', '-c',
|
||||
'. {} && rbenv install --help'.format(pipes.quote(prefix.path(
|
||||
'rbenv-1.9.3p547', 'bin', 'activate',
|
||||
))),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue