Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to run tests from a gem at install time #730

Closed
anatol opened this issue Dec 5, 2013 · 4 comments
Closed

Provide a way to run tests from a gem at install time #730

anatol opened this issue Dec 5, 2013 · 4 comments

Comments

@anatol
Copy link

anatol commented Dec 5, 2013

I work on a Rubygems-Arch bridge that adds tighter integration between ArchLinux system package manager and rubygems.

I see that many rubygems include tests. But I do not see how to run these tests. It would be great if rubygems had a flag (something like gem install --runtests) that will verify that gem works fine on this system.

A related note - I think rubygems should not install test files on the system (at least by default). Test are needed only at build/install time. At run-time tests are useless for users.

@anatol
Copy link
Author

anatol commented Dec 5, 2013

For example let's look at tzinfo gem. To run its test I need to unpack the content of gem and then

cd $gemdir/gems/tzinfo-$version && rake test.

The problem is that different gemfiles have different test, some of them have rake spec some other do not have tests and/or Rakefile.

If gem creator was able to specify test_cmd then gem can use it to run tests.

As of the second issue, gemspec already has test_files gem should skip these files during the installation.

@drbrain
Copy link
Member

drbrain commented Dec 6, 2013

RubyGems used to have this feature but it was removed due to the proliferation of ruby test tools. The large amount of tools and varying ways to run them causes a heavy maintenance burden on RubyGems, so I don't want to reintroduce this feature without the community coming up with some unified way of running tests.

At the time of removal hooks were added to RubyGems to enable running tests at install time. See the rubygems-test gem for one example, but it currently is not being maintained.

@drbrain drbrain closed this as completed Dec 6, 2013
@anatol
Copy link
Author

anatol commented Dec 8, 2013

I see your points. In fact variety of test tool is the reason why I cannot run tests in my rubygems-pacman bridge (pacman - the package manager at Linux Arch).

But I still think that having a way to test gemfile at the end-user machine would be useful. Like in my case with transparent bridge between two packaging systems. Or it can be useful for rubygems itself - when a user uploads gemfile, the server can run gem tests and reject those with broken tests. It case prevent you from situation when developers upload broken packages (e.g. forgot to add file to gemfile).

One way to make 'gem test' more generic is to add new gemspec properties, e.g.
test_cmd: rake test
test_dependencies: rake foogem bargem

Also gem should show a warning for gems that have "test_files" but do not have "test_cmd"

In any case if you decide to add 'gem test' back sometime I'll be the first who will vote for this.

@darix
Copy link

darix commented Nov 24, 2014

I think in most cases you need all the development dependencies at install time for running the tests. also how do you want to handle things like "needs a running postgresql" for the testsuite.

At openSUSE we just move the test files into a subpackage which is not installed by default. That way the files are available for the interested user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants