mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-10 22:31:51 +00:00
Merge 8827d6d14a
into d8713bb2e8
This commit is contained in:
commit
fe0ab34392
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,3 +2,6 @@ HEAD
|
|||||||
src
|
src
|
||||||
v*
|
v*
|
||||||
alias
|
alias
|
||||||
|
|
||||||
|
# For testing
|
||||||
|
bak
|
||||||
|
@ -57,6 +57,30 @@ The above copyright notice and this permission notice shall be included in all c
|
|||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
## Running tests
|
||||||
|
Tests are written in [Urchin](http://www.urchin.sh). Install Urchin like so.
|
||||||
|
|
||||||
|
wget -O /usr/local/bin https://raw.github.com/scraperwiki/urchin/83b0e53536d05a13501a9dc69b1a481158fedb24/urchin
|
||||||
|
chmod +x /usr/local/bin/urchin
|
||||||
|
|
||||||
|
(Or put it some other place in your PATH.)
|
||||||
|
|
||||||
|
There are slow tests and fast tests. The slow tests do things like install node
|
||||||
|
and check that the right versions are used. The fast tests fake this to test
|
||||||
|
things like aliases and uninstalling. From the root of the nvm git repository,
|
||||||
|
run the fast tests like this.
|
||||||
|
|
||||||
|
urchin test/fast
|
||||||
|
|
||||||
|
Run the slow tests like this.
|
||||||
|
|
||||||
|
urchin test/slow
|
||||||
|
|
||||||
|
Run all of the tests like this
|
||||||
|
|
||||||
|
urchin test
|
||||||
|
|
||||||
|
Nota bene: Avoid running nvm while the tests are running.
|
||||||
|
|
||||||
## Bash completion
|
## Bash completion
|
||||||
|
|
||||||
|
5
test/fast/alias_creates_file
Executable file
5
test/fast/alias_creates_file
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
nvm alias test v0.1.2
|
||||||
|
[ $(cat ../../alias/test) = 'v0.1.2' ]
|
6
test/fast/deactivate
Executable file
6
test/fast/deactivate
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
nvm &&
|
||||||
|
nvm deactivate &&
|
||||||
|
! nvm
|
14
test/fast/ls/base should show all versions
Executable file
14
test/fast/ls/base should show all versions
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
mkdir ../../../v0.0.{1,3,9}
|
||||||
|
mkdir ../../../v0.3.{1,3,9}
|
||||||
|
|
||||||
|
# The result should contain the version numbers.
|
||||||
|
nvm ls | grep v0.0.1 &&
|
||||||
|
nvm ls | grep v0.0.3 &&
|
||||||
|
nvm ls | grep v0.0.9 &&
|
||||||
|
nvm ls | grep v0.3.1 &&
|
||||||
|
nvm ls | grep v0.3.3 &&
|
||||||
|
nvm ls | grep v0.3.9
|
10
test/fast/ls/second number version
Executable file
10
test/fast/ls/second number version
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
mkdir ../../../v0.1.3
|
||||||
|
mkdir ../../../v0.2.3
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
|
||||||
|
# The result should contain only the appropriate version numbers.
|
||||||
|
nvm ls 0.2 | grep v0.2.3 &&
|
||||||
|
nvm ls 0.1 | grep -v v0.2.3
|
4
test/fast/multiple_aliases/all
Executable file
4
test/fast/multiple_aliases/all
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
[ $(nvm alias | wc -l) = '10' ]
|
6
test/fast/multiple_aliases/setup_dir
Executable file
6
test/fast/multiple_aliases/setup_dir
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
for i in $(seq 1 10)
|
||||||
|
do
|
||||||
|
echo v0.0.$i > ../../../alias/test$i
|
||||||
|
done
|
4
test/fast/multiple_aliases/some
Executable file
4
test/fast/multiple_aliases/some
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../../nvm.sh
|
||||||
|
[ $(nvm alias test1 | wc -l) = '2' ]
|
9
test/fast/setup
Executable file
9
test/fast/setup
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
(
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Back up
|
||||||
|
rm -Rf v* src alias
|
||||||
|
mkdir src alias
|
||||||
|
)
|
9
test/fast/setup_dir
Executable file
9
test/fast/setup_dir
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
(
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Back up
|
||||||
|
mkdir -p bak
|
||||||
|
mv v* src alias bak || sleep 0s
|
||||||
|
)
|
4
test/fast/source
Executable file
4
test/fast/source
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
. ../../nvm.sh
|
||||||
|
nvm
|
7
test/fast/teardown
Executable file
7
test/fast/teardown
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Remove temporary files
|
||||||
|
(
|
||||||
|
cd ../..
|
||||||
|
rm -fR v* src alias
|
||||||
|
)
|
13
test/fast/teardown_dir
Executable file
13
test/fast/teardown_dir
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
(
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Restore
|
||||||
|
if [ -d bak ]
|
||||||
|
then
|
||||||
|
mv bak/* . || sleep 0s
|
||||||
|
rmdir bak
|
||||||
|
fi
|
||||||
|
mkdir -p src alias
|
||||||
|
)
|
6
test/fast/unalias_removes_file
Executable file
6
test/fast/unalias_removes_file
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo v0.1.2 > ../../alias/test
|
||||||
|
. ../../nvm.sh
|
||||||
|
nvm unalias test
|
||||||
|
! [ -e ../../alias/test ]
|
10
test/fast/uninstall
Executable file
10
test/fast/uninstall
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd ../..
|
||||||
|
mkdir v0.0.1
|
||||||
|
mkdir src/node-v0.0.1
|
||||||
|
|
||||||
|
. ./nvm.sh
|
||||||
|
nvm uninstall v0.0.1
|
||||||
|
|
||||||
|
[ ! -d 'v0.0.1' ] && [ ! -d 'src/node-v0.0.1' ]
|
14
test/slow/install
Executable file
14
test/slow/install
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
. ../../nvm.sh
|
||||||
|
|
||||||
|
# Remove the stuff we're clobbering.
|
||||||
|
[ -e ../../v0.6.14 ] && rm -R ../../v0.6.14
|
||||||
|
|
||||||
|
# Install
|
||||||
|
nvm install 0.6.14
|
||||||
|
|
||||||
|
# Check
|
||||||
|
[ -d ../../v0.6.14 ]
|
||||||
|
nvm run v0.6.14 --version | grep v0.6.14
|
Loading…
Reference in New Issue
Block a user