Tests depend on the system setup #95

Closed
tmatilai opened this Issue Feb 9, 2013 · 5 comments

Projects

None yet

2 participants

@tmatilai
tmatilai commented Feb 9, 2013

There are at a couple of undocumented requirements to run the tests. At least:

  1. A fixed version of ruby must be found in /opt/rubies/ruby-x.y.z-pNNN*.
  2. chruby-exec tests requre that chruby is loaded in user's zsh and bash sessions, for example in ~/.zshrc and ~/.bash_profile. And then it actually uses the chruby function loaded from there, but that is not so important as long as it works. =)
  3. auto-switching tests require that there is no .ruby-version found in any parent directory of the ./test/project/ (or at $HOME after #85).

We could maybe create a directory in ./test/ with shell rc files that load our version of chruby, and point HOME there. chruby_auto would still escape to parent directories to search for .ruby-version.

Then maybe the TEST_RUBY_ROOT could be configurable and other TEST_RUBY_* variable parsed from it. And maybe even use a fake ruby executable that only prints the output needed by chruby_use? Unfortunately then it would be difficult to catch regressions in chruby_use.

Overall it would be nice to modify the test setup more independent and maybe have even automatic Travis tests.

@postmodern
Owner

I like the idea of setting up a mock home. We would have to test against a live install of Ruby. We could manually download/build MRI in our mock directory?

@postmodern
Owner

We could even setup make tasks to create the mock homedir and install a Ruby into it.

@tmatilai

Good idea. The whole test dir tree could be generated. We could also add a test that fails if .ruby-version is found on some parent directory.
Using a tempdir would be nice but compiling and installing the ruby on each run is not an option.

@postmodern
Owner

Tests now run the shell without loading the shell rc files.

@postmodern
Owner

Tests are now fully isolated from the system. test/setup will download a precompiled Ruby and extract it into test/rubies/. We also set HOME to test/home/ so that it's .bashrc/.zsh is loaded when chruby-exec executes the sub-shell.

@postmodern postmodern closed this Jun 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment