You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Ivan Pozdeev a6ea5b3179 Fix rehash преди 7 месеца
..
libexec Revert "Merge pull request #1153 from cmcginty/remove-sbang" преди 7 години
--version.bats use BATS_FILE_TMPDIR in test/plugin test преди 10 месеца
Dockerfile add bats test under docker преди 10 месеца
README.md add test README преди 10 месеца
commands.bats Import tests from rbenv with `sed -e s/rbenv/pyenv/g` преди 12 години
completions.bats Merge remote-tracking branch 'rbenv/master' into rbenv-20151121 преди 10 години
exec.bats upgrade bats to v1.10.0 преди 10 месеца
global.bats Merge remote-tracking branch 'rbenv/master' into rbenv-1.0 преди 10 години
help.bats Import tests from rbenv with `sed -e s/rbenv/pyenv/g` преди 12 години
hooks.bats Merge remote-tracking branch 'rbenv/master' into rbenv-1.0 преди 10 години
init.bats use BATS_FILE_TMPDIR in test/plugin test преди 10 месеца
latest.bats use BATS_FILE_TMPDIR in test/plugin test преди 10 месеца
local.bats use BATS_FILE_TMPDIR in test/plugin test преди 10 месеца
pip-rehash.bats upgrade pip detetcion in pip-rehash to accept multiple variations: (#3330) преди 10 месеца
prefix.bats use BATS_FILE_TMPDIR in test/plugin test преди 10 месеца
pyenv.bats use BATS_FILE_TMPDIR in test/plugin test преди 10 месеца
pyenv_ext.bats Revert "add tests for `PYENV_FILE_ARG`" преди 5 години
rehash.bats Fix rehash преди 7 месеца
run add possibility to filter tests with make преди 10 месеца
shell.bats Make work in nounset (-u) mode преди 5 години
shims.bats Import tests from rbenv with `sed -e s/rbenv/pyenv/g` преди 12 години
test_helper.bash use BATS_FILE_TMPDIR in test/plugin test преди 10 месеца
version-file-read.bats use BATS_FILE_TMPDIR in test/plugin test преди 10 месеца
version-file-write.bats use BATS_FILE_TMPDIR in test/plugin test преди 10 месеца
version-file.bats use BATS_FILE_TMPDIR in test/plugin test преди 10 месеца
version-name.bats use BATS_FILE_TMPDIR in test/plugin test преди 10 месеца
version-origin.bats use BATS_FILE_TMPDIR in test/plugin test преди 10 месеца
version.bats use BATS_FILE_TMPDIR in test/plugin test преди 10 месеца
versions.bats use BATS_FILE_TMPDIR in test/plugin test преди 10 месеца
whence.bats Modify applications and versions for Python преди 12 години
which.bats upgrade bats to v1.10.0 преди 10 месеца

README.md

TEST


Running test suite

Test suite could be launch with make by providing the right target depending what you want to achieve.

Under the hood, pyenv test suites use bats as a test framework and are run on the host or docker depending of the target provided to make.

Targets

  • test
    • Run the whole test suite on the local host
  • test-docker
    • Run the whole test suite on docker
      • Some volumes are used in read-only mode
  • test-unit
    • Run the unit test
  • test-plugin
    • Run the plugin test
  • test-unit-docker-[BASH_VERSION]
    • Run the unit test under official bash docker container (alpine/busybox) with the specified bash version if present is in the Makefile
    • Some volumes are used in read-only mode
  • test-unit-docker-gnu-[BASH_VERSION]
    • Run the unit test under official bash docker container (alpine/busybox), completed by GNU Tools, with the specified bash version if present is in the Makefile
    • Some volumes are used in read-only mode
  • test-plugin-docker-[BASH_VERSION]
    • Run the plugin test under official bash docker container (alpine/busybox), completed by GNU Tools, with the specified bash version if present is in the Makefile
    • Some volumes are used in read-only mode
  • test-plugin-docker-gnu-[BASH_VERSION]
    • Run the plugin test under official bash docker container (alpine/busybox), completed by GNU Tools, with the specified bash version if present is in the Makefile
    • Some volumes are used in read-only mode

Targeting specific test / test file

By setting some environment variables, it is possible to filtering which test and/or test file who will be tested with bats

  • BATS_FILE_FILTER

    • Run test only with the specified file
  • BATS_TEST_FILTER

    • Run test only who corresponding to the filter provided

Examples

    $ BATS_TEST_FILTER=".*installed.*" BATS_FILE_FILTER="build.bats" make test-plugin-docker-gnu-3.2.57
    build.bats
     ✓ yaml is installed for python
     ✓ homebrew is used in Linux if Pyenv is installed with Homebrew
     ✓ homebrew is not used in Linux if Pyenv is not installed with Homebrew
    
    3 tests, 0 failures
    
    $ BATS_TEST_FILTER=".*installed.*" BATS_FILE_FILTER="build.bats" make test-plugin
    build.bats
     ✓ yaml is installed for python
     ✓ homebrew is used in Linux if Pyenv is installed with Homebrew
     ✓ homebrew is not used in Linux if Pyenv is not installed with Homebrew
    
    3 tests, 0 failures

Writing test

To be reproducible, each test use/should use its own TMPDIR .
It's achieved by using the environment variable BATS_TEST_TMPDIR provided by bats that is automatically deleted at the end of each test. More info here

Another variable who could be used to source some file who need to be tested is BATS_TEST_DIRNAME who point to the directory in which the bats test file is located.