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

Documentation about 'test_files' is confusing #90

Closed
emilsoman opened this issue Jul 16, 2014 · 7 comments
Closed

Documentation about 'test_files' is confusing #90

emilsoman opened this issue Jul 16, 2014 · 7 comments

Comments

@emilsoman
Copy link

According to the section in the guides that talks about test_files gemspec attribute, test_files is a collection of unit test file which will be loaded as unit tests when the user requests a gem to be unit tested. How does the user request a gem to be unit tested ? Looks like --test option was removed from the gem command. So how is this test_files gemspec attribute useful currently ?

@drbrain
Copy link
Member

drbrain commented Jul 16, 2014

I removed them since they're no longer useful or recommended to set. This will be updated with the next release of RubyGems.

@bf4
Copy link
Contributor

bf4 commented Jul 25, 2014

Perl still runs tests by default when installing cpan modules.. for some reason that never took off in the rubygems world.

epistrephein added a commit to epistrephein/rarbg that referenced this issue Jan 16, 2020
- Remove test_files attribute since it's deprecated and no longer used.
rubygems/guides#90 (comment)
- Use Dir[] instead of git ls-files to specify gem files, in order to improve readability and exclude unnecessary files.
- Don't include development files and RSpec tests in the built gem.
pocke added a commit to pocke/graphiql-rails that referenced this issue Sep 25, 2020
`Gem::Specification#test_files=` is no longer recommended.
rubygems/guides#90

And it increases gem package size because the option adds test files to
the package.

So I think we should avoid using `test_files=` option.

---

It reduces 4.7MB package size on my local.

before

```bash
$ du graphiql-rails-1.7.0/ --summarize
6.7M    graphiql-rails-1.7.0/
```

after

```bash
$ du graphiql-rails-1.7.0/ --summarize
2.0M    graphiql-rails-1.7.0/
```
cben added a commit to cben/kubeclient that referenced this issue May 11, 2021
test_files is deprecated.  It was causing all tests to
be shipped in the .gem file, which is useless bloat:
rubygems/guides#90
cben added a commit to cben/kubeclient that referenced this issue May 11, 2021
test_files is deprecated.  It was causing all tests to
be shipped in the .gem file, which is useless bloat:
rubygems/guides#90
cben added a commit to cben/kubeclient that referenced this issue May 11, 2021
test_files is deprecated.  It was causing all tests to
be shipped in the .gem file, which is useless bloat:
rubygems/guides#90

kubeclient-4.9.1.gem was 78 848 bytes, now down to 33 792.
cben added a commit to cben/kubeclient that referenced this issue May 11, 2021
test_files is deprecated.  It was causing all tests to
be shipped in the .gem file, which is useless bloat:
rubygems/guides#90

Compressed kubeclient-4.9.1.gem was 78KB, now down to 33KB.
Unpacked size 757KB -> 184KB.
cben added a commit to cben/kubeclient that referenced this issue May 11, 2021
test_files is deprecated.  It was causing all tests to
be shipped in the .gem file, which is useless bloat:
rubygems/guides#90

Compressed kubeclient-4.9.1.gem was 78KB, now down to 33KB.
Unpacked size 757KB -> 184KB.
thiagoa added a commit to thoughtbot/suspenders that referenced this issue May 6, 2022
Closes #1055

Changes `suspenders.gemspec` to not depend on git. Additionally, we
can safely remove `s.test_files` since its use is no longer
recommended and was introduced in the Suspenders codebase many years
ago.

References: rubygems/guides#90
thiagoa added a commit to thoughtbot/suspenders that referenced this issue May 6, 2022
Closes #1055

Changes `suspenders.gemspec` to not depend on git. Additionally, we
can safely remove `s.test_files` since its use is no longer
recommended and was introduced in the Suspenders codebase many years
ago.

References: rubygems/guides#90
@postmodern
Copy link
Contributor

Can we get confirmation from someone on the rubygems team? The lack of confirmation is confusing whether test_files will, or wont, or eventually might be deprecated?

@deivid-rodriguez
Copy link
Member

Hi!

It sounds like @drbrain planned to deprecate this, but that never took off in the end. So, no, test_files is not deprecated. I guess you could say it's "softly deprecated", given that the documentation was removed.

As far as I understand, these days test_files is just an informational field, but the list of files you put in there do get added to the list of files in the packaged gem, so it makes gems bigger.

Many people prefer to remove it to make gems smaller and not ship unused files. But I recall also people advocating for using it (mostly OS packagers), because it provides a way to run gem's tests using the gem package exclusively.

If you ask my opinion, it's too much trouble to deprecate this kind of thing that has been there for so many years. I think it would bring little benefit. I would rather re-add some documentation explaining what it does today, but 'm happy to discuss other options and opinions.

lucascaton added a commit to lucascaton/enumerate_it that referenced this issue Sep 3, 2022
Seems that `test_files` attribute has been deprecated. If we can remove it from gemspec file, it would reduce distribute gem package size.

Related:

* [Documentation about 'test_files' is confusing rubygems/guides#90](rubygems/guides#90)
* https://docs.rubocop.org/rubocop/cops_gemspec.html#gemspecdeprecatedattributeassignment
lucascaton added a commit to lucascaton/enumerate_it that referenced this issue Sep 3, 2022
Seems that `test_files` attribute has been deprecated. If we can remove it from gemspec file, it would reduce distribute gem package size.

Related:

* [Documentation about 'test_files' is confusing rubygems/guides#90](rubygems/guides#90)
* https://docs.rubocop.org/rubocop/cops_gemspec.html#gemspecdeprecatedattributeassignment
lucascaton added a commit to lucascaton/enumerate_it that referenced this issue Sep 3, 2022
Seems that `test_files` attribute has been deprecated. If we can remove it from gemspec file, it would reduce distribute gem package size.

Related:

* [Documentation about 'test_files' is confusing rubygems/guides#90](rubygems/guides#90)
* https://docs.rubocop.org/rubocop/cops_gemspec.html#gemspecdeprecatedattributeassignment
dpep added a commit to dpep/meddleware_rb that referenced this issue Oct 3, 2022
slim down gem, given test_files is not used (rubygems/guides#90)
TopDeveloper705 pushed a commit to TopDeveloper705/graphiql-rails that referenced this issue Dec 21, 2022
`Gem::Specification#test_files=` is no longer recommended.
rubygems/guides#90

And it increases gem package size because the option adds test files to
the package.

So I think we should avoid using `test_files=` option.

---

It reduces 4.7MB package size on my local.

before

```bash
$ du graphiql-rails-1.7.0/ --summarize
6.7M    graphiql-rails-1.7.0/
```

after

```bash
$ du graphiql-rails-1.7.0/ --summarize
2.0M    graphiql-rails-1.7.0/
```
Web-Go-To added a commit to Web-Go-To/rails_suspenders that referenced this issue Mar 23, 2023
Closes thoughtbot/suspenders#1055

Changes `suspenders.gemspec` to not depend on git. Additionally, we
can safely remove `s.test_files` since its use is no longer
recommended and was introduced in the Suspenders codebase many years
ago.

References: rubygems/guides#90
lygaret added a commit to guilleiguaran/nancy that referenced this issue May 20, 2023
per standard rubocop rules, the attribute is deprecated, and unused
see: rubygems/guides#90
pboling added a commit to pboling/simplecov_json_formatter that referenced this issue Oct 17, 2023
- No functional purpose since 2014
- See: rubygems/guides#90
@schmijos
Copy link

I removed them since they're no longer useful or recommended to set.

@drbrain I'd like to challenge this in one aspect. I often read very old code. Having the test suite distributed by long term archives like RubyForge or RubyGems is useful because the original source often disappeared from the web.

@postmodern
Copy link
Contributor

postmodern commented Oct 30, 2023

@schmijos older gems will still contain their test/ or spec/ files. Going forward, omitting the test files might make it difficult in the future if certain gem's git repositories disappear. Although, I can see the logic behind omitting the test files from packaged .gems to save disk space.

@simi
Copy link
Member

simi commented Oct 30, 2023

@schmijos currently gem files are intended to keep only runtime files. Test files, configs (like rubocop, ...) and other repo only related files are considered best practice to not be included. It is not intended to preserve whole source code repository in gem packages.

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

No branches or pull requests

7 participants