Commit graph

248 commits

Author SHA1 Message Date
Yamashita, Yuu
83429344ea Rewrite some tests for pyenv which was recently imported from rbenv 2018-04-02 01:52:42 +00:00
Yamashita, Yuu
83f97ef2b3 Merge remote-tracking branch 'rbenv/master' into rbenv-20180402 2018-04-02 01:46:48 +00:00
Victor Lim
9daf81f16e Fix https://github.com/rbenv/rbenv/issues/1065
Command `rbenv version-name > .ruby-version` will create an empty `.ruby-version` file
before running `rbenv-version-file`. This causes `rbenv-version-file` to return empty
string which in turn causes `rbenv-version-name` to return `system`.

Ensure size of `.ruby-version` is non-zero as a workaround.
2018-02-26 16:49:37 +08:00
Marco Hinz
643023d98f
Add tests for shell integration 2017-12-07 02:32:35 +01:00
Daniel Hahler
a9ca72ab8e test/which.bats: do not export PATH
Otherwise `sed` might not be found later in bats/libexec/bats-exec-test,
in case `/usr/bin` gets removed.
2017-11-20 04:22:05 +01:00
Daniel Hahler
3fd23431af Merge remote-tracking branch 'rbenv/master'
Conflicts:
	README.md
	libexec/pyenv---version
	libexec/pyenv-init
	libexec/rbenv
	libexec/rbenv-sh-shell
	libexec/rbenv-which
	test/init.bats
	test/shell.bats
2017-06-05 15:18:44 +02:00
Jeff Kowalski
a81da8d864 Revert quoting change in previous commit; adjust test to match code
Revert back to original quoting style used before previous commit.
Adjust init.bats to reflect changes for successful tests.
2017-05-16 13:36:06 -07:00
Yamashita, Yuu
bec978d0f6 Workaround for CI failures with versions with multiple digits
https://travis-ci.org/pyenv/pyenv/jobs/215777826
2017-03-28 04:43:28 +00:00
Yamashita, Yuu
d01fa09a7d Migrate project URL to https://github.com/pyenv/pyenv 2017-03-06 04:31:48 +00:00
Jason Karns
8eb97549e1
Conforms OLD_RBENV_VERSION to RBENV_* convention
Keeping rbenv-controlled variables to RBENV_* "namespace" helps with
discoverability (and tools like rbenv-env) but also consistency and a
very minor degree of safety/isolation from env impact.
2016-12-19 17:21:45 -05:00
Mislav Marohnić
6ced4e25de Merge pull request #873 from dmerand/patch-1
Fish shell "." is deprecated in favor of "source"
2016-11-25 20:32:54 +01:00
Mislav Marohnić
2207c27cb4 Merge branch 'shell-undo' 2016-11-25 20:26:24 +01:00
Mislav Marohnić
c4d97ad392 Finalize rbenv shell - implementation
This ensures that OLD_RBENV_VERSION is never exported. This makes the
implementation a little bit more complex, since more logic needs to be
pushed down into eval'd code.
2016-11-25 20:24:16 +01:00
Ville Skyttä
725ff0c5dd Spelling fixes 2016-10-11 14:07:48 +03:00
Yamashita, Yuu
7fadd939ad v1.0.0 (fixes #520) 2016-08-15 08:30:01 +00:00
Yamashita, Yuu
a02f5dde4f s/rbenv/pyenv/g 2016-08-15 05:22:59 +00:00
Yamashita, Yuu
cf1beda362 Merge remote-tracking branch 'rbenv/master' into rbenv-20160815 2016-08-15 05:14:24 +00:00
Yamashita, Yuu
93ece2ac16 Rewrite with using here document syntax 2016-08-03 06:31:27 +00:00
Yamashita, Yuu
36138f4901 Rewrite with using here document syntax 2016-08-03 06:29:59 +00:00
Yamashita, Yuu
1b35cfaa2c 1) Remove useless touch 2) Add explicit shebang line to executable for testing 2016-08-03 01:34:42 +00:00
Yamashita, Yuu
83e874a165 Add explicit shebang to executable for testing 2016-08-03 01:33:35 +00:00
Yamashita, Yuu
8eefa41a4d Remove useless touch line 2016-08-03 00:58:05 +00:00
Yamashita, Yuu
b8885e4fe2 Keep using original PATH ordering in test_helper 2016-08-02 00:23:47 +00:00
Yamashita, Yuu
a456528be8 Keep original ordering of PATH configuration 2016-08-02 00:21:28 +00:00
Yamashita, Yuu
2485257424 Add a test to confirm the prefix doesn't work fine with /bin/ruby 2016-08-01 00:31:11 +00:00
Yamashita, Yuu
5c83c4abb7 Add test for /bin/python case 2016-08-01 00:19:04 +00:00
McTavish McArdle
5f20bc258f "." has been deprecated in the fish shell in favor of explicit "source" 2016-05-28 18:29:45 -04:00
Yamashita, Yuu
30538b0672 Fix broken tests for pyenv---version
I need to use release date versioning at least for now until preparing
custom version comparator for brew's formula.
2016-03-04 00:31:04 +00:00
Yamashita, Yuu
fd893ea3b0 Fix broken test for pyenv-version-name 2016-03-04 00:10:48 +00:00
Yamashita, Yuu
41ce3aade2 Merge remote-tracking branch 'rbenv/master' into rbenv-1.0 2016-03-02 01:39:52 +00:00
Donald Merand
8b0b51a166 convert references to '.' to 'source' for fish shell 2016-02-20 10:27:39 -05:00
Aaron Patterson
6a912bf104 add support for rbenv shell -
`rbenv shell -` allows you to switch to the previously activated ruby
version.  Similar to `cd -` or `git checkout -`.

This tries to implement `rbenv shell -` as proposed in #854.  However,
adding support seemed to break the "shell change version" test.  I'm not
very good at Bash programming, can someone tell me what is wrong with
what I'm doing?  I'd like to add a bit more functionality to this, but
I'm really just cargo cult programming Bash.

Thank you!

fix tests
2016-01-12 15:32:59 -08:00
Jason Karns
565798d617 Test IFS handling in version-name/version-origin hooks 2016-01-04 09:14:28 -05:00
Jason Karns
0f7a2cad8d Use create_hook helper
Use extracted create_hook helper in tests for:

- exec
- hooks
- rehash
- version-name
- version-origin
- which
2016-01-04 09:14:25 -05:00
Jason Karns
5ccba5d7cc Extract common create_hook helper 2016-01-04 09:14:04 -05:00
Jason Karns
2cc2ec160e Remove redundant test
Spaces in hook path is tested in test/hooks.bats
2016-01-04 09:13:58 -05:00
Mislav Marohnić
e199a3d8f7 Merge pull request #850 from jasonkarns/remove-legacy-global-version-file
Remove support for legacy global version files
2015-12-29 14:40:37 +01:00
Jason Karns
fe809ea90d Remove support for legacy global version files
`default` was made legacy back in 2011 with
5be66da9f4 (the command was renamed from
`rbenv-default` to `rbenv-global`, and so the global file was renamed
from `$RBENV_ROOT/default` to `$RBENV_ROOT/global` (the latter taking
precedence)

`global` was then made legacy about a month later in Sep 2011 when the
preferred filename was changed to `$RBENV_ROOT/version`.
2015-12-28 22:05:00 -05:00
Jason Karns
f880dc6d6f Remove support for legacy version file 2015-12-28 21:34:07 -05:00
Jason Karns
3c9674453f fix local --unset test 2015-12-28 21:33:50 -05:00
Mislav Marohnić
e554cd86c3 Strip leading : from RBENV_HOOK_PATH 2015-12-24 19:12:47 +01:00
Mislav Marohnić
f9d8b551dc Add test for detecting shell when rbenv init is called from script
References #730
2015-12-24 13:20:49 +01:00
Mislav Marohnić
1a0be6f0ad Improve git --version git revision lookup
It doesn't try to chdir into RBENV_ROOT anymore because that might be
a location of an unrelated rbenv install that might have a different
version than the current one that is installed e.g. via a package
manager such as Homebrew.

Now just tries the repo where the source files (`libexec/*`) are
located, and if that isn't a valid rbenv repo, bail out early.
2015-12-24 03:52:33 +01:00
Mislav Marohnić
6481cbb172 Merge branch 'version-hooks'
Closes #739
2015-12-23 17:42:44 +01:00
Mislav Marohnić
6e30032278 Simplify version-name, version-origin hook tests
No need for helper function that's gonna be used just once.
2015-12-23 17:39:14 +01:00
Mislav Marohnić
4fde4ecbaf Ensure RBENV_VERSION_ORIGIN is not inherited from environment
It's only supposed to be set from `version-origin` hooks, but not
inherited from environment in case it was set.
2015-12-23 17:26:53 +01:00
Mislav Marohnić
40c1d27445 Merge remote-tracking branch 'origin/master' into version-hooks 2015-12-23 17:22:43 +01:00
Jason Karns
c3a5f91ed0 create hook: version-origin
Expose a `version-origin` hook.

It is invoked *before* the traditional `rbenv-version-file` lookup. Because `version-origin` is traditionally run immediately after `version-name`, then any plugin hooks that alter `version-name` would have done so. Thus, running `version-origin` prior to printing the origin gives those plugins a chance to alter the `version-origin` to match.

If any of the hooks set `$RBENV_VERSION_ORIGIN`, then it is used as the return value. Otherwise, the existing logic continues to return "environment variable" or "filename" as appropriate.

This change, in conjunction with the `version-name` hook, makes a clean seam by which plugins can inject their own ruby version setting logic. Using this seam, as opposed to altering `$RBENV_COMMAND_PATH` from the `which` hook, means that the version name and origin are set more reliably and so `version`, `version-name`, `version-origin` and `which` all work as expected. Indeed, even PS1 works now.
2015-12-23 17:22:31 +01:00
Jason Karns
258e4413b1 create hook: version-name
Expose a `version-name` hook.

It is invoked *after* the traditional `RBENV_VERSION` lookup. Which means hook scripts can interrogate `$RBENV_VERSION_FILE` and/or `$RBENV_VERSION` (or use the executables).

The hooks are then run, giving plugins a chance to alter `RBENV_VERSION`. Once the hooks have run, we now have (in `$RBENV_VERSION`) the actual version we want to use (or it's empty which defaults to `system` per normal). Lastly, the same logic remains for checking if the version exists, or trimming the `ruby-` prefix.

Prime example: the ruby-bundler-ruby-version plugin can select a ruby by using the `ruby` directive from the `Gemfile` if a local `.ruby-version` doesn't exist.
2015-12-23 17:22:30 +01:00
Mislav Marohnić
ba072adcb9 Have rbenv local read version from parent directories as well
Fixes #807
2015-12-23 15:21:24 +01:00
Mislav Marohnić
ca25259900 Allow explicit target directory argument to rbenv-version-file
Can be used for `.ruby-version` file lookup in the ancestry of a
specific directory. In this mode of operation, global version files
aren't taken into consideration, and the command fails unless a local
version file was found.
2015-12-23 15:19:54 +01:00
Yamashita, Yuu
3031cb9750 Add workaround for test failure on Arch Linux (#480) 2015-12-20 12:29:30 +00:00
Daniel Hahler
03ece82197 Merge remote-tracking branch 'rbenv/master'
Using `git merge rbenv/master -s recursive -X rename-threshold=5%`.

Conflicts:
	README.md
	bin/python-local-exec
	libexec/pyenv
	libexec/pyenv-help
	test/--version.bats
2015-12-14 13:47:11 +01:00
Mislav Marohnić
90373d78b9 Add test for not including current directory in PATH search
Confirms #836
2015-12-14 11:59:01 +01:00
Chulki Lee
df4c16ecb4 update urls to rbenv 2015-12-07 11:03:07 -08:00
Yamashita, Yuu
8da3749648 Merge remote-tracking branch 'rbenv/master' into rbenv-20151121 2015-11-21 04:21:14 +00:00
Jason Karns
a3ff3adc39 create local .ruby-version file in test dir
This new test was creating an (intentionally invalid) .ruby-version file
in current working directory; typically the rbenv project dir.
Immediately after test runs, I had a leftover .ruby-version file.

The version-file tests create and cd into the RBENV_TEST_DIR as part of
setup(). I'm using the same directory for this test fix, but am only
using it for this particular test. None of the other exec tests seem to
need to be in a temp test dir, so no use putting it in setup().
2015-11-20 09:51:44 -05:00
Jason Karns
d7ca2aba2a add --help to subcommand completions
ensure subcommand exists, then include --help in its completion output
2015-11-19 12:05:19 -05:00
Mislav Marohnić
825de5d2e3 Fix argument handling in main rbenv command
- Explicitly asking for help with `-h` or `--help` exits with 0 status
  and displays help on stdout.

- Not providing any arguments to rbenv results in failure status and
  displays version and help on stderr.
2015-11-19 01:52:48 +01:00
Mislav Marohnić
8f87f43e22 Fix broken version-dependent test
Broken in dcca61c0bc
2015-11-14 12:21:16 +00:00
Mislav Marohnić
c30e096a54 Merge branch 'which-fixes' 2015-11-14 10:42:41 +00:00
Mislav Marohnić
3405c4d03c Fix error message when command is not found for "system" version
If `foo` didn't exist and `RBENV_VERSION=system rbenv which foo` was
called, the error message used to be misleading:

    rbenv: version `system' is not installed

Instead, have the error message simply say that the command was not found.

Fixes #770
2015-11-13 23:10:09 -05:00
Mislav Marohnić
09b18cf6f5 Add test for version-origin when version not found in rbenv-exec 2015-11-13 23:09:12 -05:00
Daniel Hahler
6296bf3f8b tests: fix path_without to handle /bin properly
I was seeing /bin being left.  This patch fixes it by anchoring the search
pattern with ':' on both sides.
2015-11-12 21:20:00 +01:00
Yamashita, Yuu
9163c46568 v20151105 2015-11-05 09:21:08 +00:00
Yamashita, Yuu
0daf04a71b v20151103 2015-11-03 13:31:28 +00:00
Mislav Marohnić
e80886e9be Add rbenv versions --skip-aliases option
Useful in combination with `--bare` to list just the unique version
numbers without the extra directory entries that are symlinks to other
version numbers in the same directory.
2015-10-27 21:05:10 +01:00
Mislav Marohnić
7026e529c7 Fix realpath fallback in rbenv hooks
The symlinks weren't correctly resolved if they were pointing to a
single path component, such as `ln -s foo bar`.
2015-10-27 21:05:10 +01:00
Mislav Marohnić
dcca61c0bc Improve rbenv --version git checkout discovery
When `rbenv --version` is called, this now happens:

1. It changes into the directory where `libexec/rbenv--version` resides
   and checks if it's a checkout of the rbenv repo (as opposed to
   Homebrew checkout or something else). Then it reads the git revision.

2. If that failed, change to `$RBENV_ROOT` directory and repeat step 1.
2015-10-25 16:54:38 +01:00
Mislav Marohnić
efb187f26f Merge pull request #663 from kevinburke/use-command
Use `command` to run rbenv rehash
2015-10-11 04:04:46 +02:00
Mislav Marohnić
8a0555f8ef Init RBENV_TEST_DIR properly and only once during test setup 2015-10-10 19:02:11 +02:00
Mislav Marohnić
55f692ba9c Merge commit 'refs/pull/562/head' of https://github.com/sstephenson/rbenv 2015-10-10 18:42:36 +02:00
Mislav Marohnić
3a265c1af9 Unset XDG_CONFIG_HOME and related variables during tests
If set by the user's environment, `git config --global` writes will go
to that destination instead of temporary $HOME. We definitely don't want
that.

Fixes #742
2015-10-10 18:39:23 +02:00
Yamashita, Yuu
19c02bf39c v20151006 2015-10-06 14:12:04 +00:00
Yamashita, Yuu
948d1f4ca7 Merge branch 'blueyed-pyenv-rehash-python-glub' (fixes #379, #404) 2015-09-22 15:28:15 +09:00
Yamashita, Yuu
438e828eb5 add tests for PYENV_FILE_ARG 2015-09-22 15:28:00 +09:00
Josh Friend
c452da8084 v20150913 2015-09-13 11:03:52 -04:00
Josh Friend
193e64b6b2 v20150901 2015-09-01 13:59:13 -04:00
Yamashita, Yuu
7f32e96c28 v20150719 2015-07-19 13:07:24 +09:00
Daniel Hahler
e3982fae38 Display version origin with non-installed versions
This is useful as an indicator where it is coming from.
2015-07-17 17:10:33 +02:00
Yamashita Yuu
114063495f pyenv-prefix should return proper prefix of system version (fixes #391) 2015-06-27 01:07:18 +09:00
Josh Friend
5cb9c9af2e v20150601 2015-06-01 21:48:44 -04:00
Yamashita Yuu
9aee57d965 Fix test for adding shims in fish 2015-05-27 00:54:19 +09:00
Yamashita Yuu
1b066598ce v20150524 2015-05-24 10:53:17 +09:00
Yamashita, Yuu
46ffb0c8df Merge pull request #290 from blueyed/version-handle-missing-better
Improve `pyenv version`, if there is one missing
2015-05-17 12:05:03 +09:00
Josh Friend
1d31529b46 v20150404 2015-05-04 08:25:25 -04:00
Daniel Hahler
10d5d9a24f tests: fix desc for "can add shims to PATH more than once"
This seems to have not been merged properly.

A similar issue is with the test for fish, which has been submitted as a
PR for rbenv: https://github.com/sstephenson/rbenv/pull/722.
2015-04-20 00:00:04 +02:00
Daniel Hahler
06c1959e78 Fix test for adding shims in fish
Commit e2173df4 (for issue #369) did not handle the fish test properly.

This renames it and fixes the assertion.
2015-04-19 23:53:19 +02:00
Kevin Burke
0cd078bae6 Merge branch 'master' into use-command 2015-03-31 18:57:44 -07:00
Yamashita Yuu
ab2aa6d13b v20150326 2015-03-26 23:13:55 +09:00
Yamashita Yuu
f48a5b11d7 Import recent changes from rbenv 4d72eefffc 2015-03-07 01:01:32 +09:00
Yamashita Yuu
efe461d2b4 v20150226 (#323) 2015-02-26 11:35:10 +09:00
Yamashita Yuu
9146f44db1 v20150204 2015-02-04 10:33:21 +09:00
Mislav Marohnić
6820704c91 Remove warning about extraneous "ruby-" prefix in .ruby-version
When we started to support reading `.ruby-version` files, we made a
commitment to not support fuzzy version matching. Treating "ruby-2.1.5"
as "2.1.5" is a sort of fuzzy matching, so we put in place a warning
telling you to remove the extraneous "ruby-" prefix popularly used by
other Ruby version managers to denote MRI. (Their logic is that MRI is
"ruby" and other rubies are not "ruby", apparently.)

However, people are often not able to remove the prefix in their
projects because they want to support other coworkers and tools that
sadly still require the prefix, like RubyMine.

So to restore sanity for a big portion of our users, the warning is gone.
2015-01-29 01:55:58 -08:00
Yamashita Yuu
8abefe1fcb v20150124 2015-01-24 00:45:03 +09:00
Daniel Hahler
e8433cfeb3 Use exitcode from pyenv-version-name in pyenv-version, do not halt 2014-12-11 20:37:03 +01:00
Daniel Hahler
7f88eabd0b Improve pyenv version, if there is one missing
Display the other available ones still.

Fixes https://github.com/yyuu/pyenv/issues/291
2014-12-11 18:49:38 +01:00
Yamashita Yuu
d320d74a07 v20141211 (fixes #288) 2014-12-11 22:39:38 +09:00
Yamashita Yuu
5ca423c9f3 Revert a fix for #101 to fix broken tests relating to PYENV_NATIVE_EXT 2014-12-01 20:34:12 +09:00
Yamashita Yuu
f0e852553a Import rbenv changes at 7e0e85bdda 2014-12-01 00:29:26 +09:00