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

Reverting the removal of the tests via .gitattributes #6605

Closed
fabpot opened this issue Jan 7, 2013 · 19 comments
Closed

Reverting the removal of the tests via .gitattributes #6605

fabpot opened this issue Jan 7, 2013 · 19 comments

Comments

@fabpot
Copy link
Member

fabpot commented Jan 7, 2013

I think that it is not worth removing the tests classes from archives via the .gitattributes file. The more I think about it, the more I think that the benefits are really small and the drawbacks quite huge:

  • people use some of our test classes in their own tests (we have already moved some of them to a Test/ directory and that helps bu I fear that many more will need to be moved -- see https://twitter.com/huizendveld/status/288331330998116352 for an example);
  • people like to have a look at the tests to understand how the code works;
  • when working on a patch locally on a project, there is no way to run the unit tests to check that everything still work as expected.

I would like to revert this change. Opinions?

@fabpot
Copy link
Member Author

fabpot commented Jan 7, 2013

Original pull request: #5674

@fabpot
Copy link
Member Author

fabpot commented Jan 7, 2013

And the issue that started it: #6047

@clemherreman
Copy link
Contributor

Same as @marijn, tests are part of the documentation, and have proved more than useful to understand how internals are working. Also I like to run the tests when putting my application on production, just to ensure that my server environnement doesn't break them.

@marekkalnik
Copy link
Contributor

I totally support this. Moreover I think that the test base of symfony is great and we need to encourage people to learn from it rather than hiding it. 👍

@igorw
Copy link
Contributor

igorw commented Jan 7, 2013

To clarify the intent of the original PR: The idea is make the stable, zipped packages optimized for deployment. That means stripping out things like docs and tests that are not needed in production. When this is applied on a large scale, the savings are significant.

Of course stable packages are also used in development, and as such having the documentation present can be very useful.

For the record, I have no problem reverting this. Stable packages != production; stripping out useless things in the deployment process is a sane approach. The fact that composer caches packages locally also helps for speed and bandwidth.

👍

@Seldaek
Copy link
Member

Seldaek commented Jan 7, 2013

I tend to agree it probably causes more pain than good. I fixed composer docs to avoid promoting the practice, because I have seen it spread quite a bit lately composer/composer@bf32869

@ghost
Copy link

ghost commented Jan 7, 2013

@fabpot - I think it's all about the target audience. If you are deploying a project, the tests are not necessary. if you are working in a development environment, then you certainly want the tests but you'd get them anyway with Composer which you'd sure be using when developing a project...

@ghost
Copy link

ghost commented Jan 7, 2013

Thinking some more, when you have to package a large project it's usually necessary do some assembly and packaging tasks anyhow, so it probably doesn't matter either way.

If tests are considered part of the documentation, then +1 for keeping them. What consumers do downstream when packaging their final products is their own prerogative.

+1 for reverting the PR.

@acasademont
Copy link
Contributor

+1 for reverting this, I look a lot at the tests to see how the code works, not everything is in the docs!

@Seldaek
Copy link
Member

Seldaek commented Jan 7, 2013

One thing worth noting is that test helper classes and such that are
meant to be used by other people should really be moved to a Test/
namespace ideally, to clearly separate public API from internal tests.

@igorw
Copy link
Contributor

igorw commented Jan 7, 2013

I strongly agree with @Seldaek, the tests are not a public API and should not be depended on.

@fabpot
Copy link
Member Author

fabpot commented Jan 7, 2013

I agree too with Seldaek and I won't revert the move of some test classes. If some others need to be moved, let's do it.

@fabpot
Copy link
Member Author

fabpot commented Jan 9, 2013

done

@fabpot fabpot closed this as completed Jan 9, 2013
Seldaek pushed a commit to Seldaek/symfony that referenced this issue Jan 9, 2013
fabpot added a commit that referenced this issue Jan 17, 2013
* 2.1:
  [Yaml] fixed default value
  Added Yaml\Dumper::setIndentation() method to allow a custom indentation level of nested nodes.
  added a way to enable/disable object support when parsing/dumping
  added a way to enable/disable PHP support when parsing a YAML input via Yaml::parse()
  fixed CS
  [Process] Fix docblocks, remove `return` from `PhpProcess#start()` as parent returns nothing, cleaned up `ExecutableFinder`
  fixes a bug when output/error output contains a % character
  [Console] fixed input bug when the value of an option is empty (closes #6649, closes #6689)
  [Profiler] [Redis] Fix sort of profiler rows.
  Fix version_compare() calls for PHP 5.5.
  Removed underscores from test method names to be consistent with other components.
  [Process] In edge cases `getcwd()` can return `false`, then `proc_open()` should get `null` to use default value (the working dir of the current PHP process)
  Fix version_compare() calls for PHP 5.5.
  Handle the deprecation of IntlDateFormatter::setTimeZoneId() in PHP 5.5.
  removed the .gitattributes files (closes #6605, reverts #5674)
  [HttpKernel] Clarify misleading comment in ExceptionListener

Conflicts:
	src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_style.html.twig
	src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php
	src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php
	src/Symfony/Component/Form/Tests/Util/PropertyPathTest.php
	src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php
	src/Symfony/Component/Process/Process.php
@Tobion
Copy link
Contributor

Tobion commented Oct 23, 2014

If people intend to run tests/look at tests when developing, they can also install vendors locally with --prefer-source and when deploying on servers with --prefer-dist.
So this way they got both advantages. Low bandwitdth when deploying and flexibility when developing.

@jdufresne
Copy link
Contributor

I agree with @Tobion

If the gitattributes are restored, you get the best of both options. Use --prefer-dist if you do not want test and doc files, use --prefer-source if you do.

This seems like it would solve both side elegantly, so why not do it?

In my opinion, if you want the code is a deploy-able/library state, that is what composer is for. If you want the code in a develop-able state, that is what git clone is for.

@tgr
Copy link

tgr commented Feb 27, 2017

I don't understand how the benefits and drawbacks were weighted here; ignoring parts of the package which are not required to use it seems like a no-brainer to me. People using them for development/CI should use --prefer-source (and people working on patches especially so; how would you even submit them otherwise?). Really the only drawback that I can see is that you have to remember to type --prefer-source for every composer install command, which is not exactly hard. On the other side, beyond the bandwidth savings and reducing exposure of the production environment, it would also help with issues like #21750.

@cordoval
Copy link
Contributor

having tests to understand code argument: Tests are not going anywhere, it is only for -prefer-dist
test classes being used argument: That is a bad practice that should be discouraged, you also don't run tests on production with how current deploys are being made (docker, kubernetes etc). Environment is the same as in production than on testing environment.
developing symfony argument: People that develops symfony --prefer-source because contribs are done on git.

Besides the little probability of changing minds here i want to leave a trace to accomplish no tests on deployments one has to write a script to rm -rf Tests folder on every first level component provided one is not requiring symfony/symfony and is requiring symfony/framework-bundle instead with the use of composer replace key.

@mvrhov
Copy link

mvrhov commented Jul 17, 2017

I'm removing tests and docs as part of a deploy procedure.

@nicolas-grekas
Copy link
Member

This discussion already happened in #17749

ostrolucky pushed a commit to ostrolucky/symfony that referenced this issue Mar 25, 2018
ostrolucky pushed a commit to ostrolucky/symfony that referenced this issue Mar 25, 2018
* 2.1:
  [Yaml] fixed default value
  Added Yaml\Dumper::setIndentation() method to allow a custom indentation level of nested nodes.
  added a way to enable/disable object support when parsing/dumping
  added a way to enable/disable PHP support when parsing a YAML input via Yaml::parse()
  fixed CS
  [Process] Fix docblocks, remove `return` from `PhpProcess#start()` as parent returns nothing, cleaned up `ExecutableFinder`
  fixes a bug when output/error output contains a % character
  [Console] fixed input bug when the value of an option is empty (closes symfony#6649, closes symfony#6689)
  [Profiler] [Redis] Fix sort of profiler rows.
  Fix version_compare() calls for PHP 5.5.
  Removed underscores from test method names to be consistent with other components.
  [Process] In edge cases `getcwd()` can return `false`, then `proc_open()` should get `null` to use default value (the working dir of the current PHP process)
  Fix version_compare() calls for PHP 5.5.
  Handle the deprecation of IntlDateFormatter::setTimeZoneId() in PHP 5.5.
  removed the .gitattributes files (closes symfony#6605, reverts symfony#5674)
  [HttpKernel] Clarify misleading comment in ExceptionListener

Conflicts:
	src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_style.html.twig
	src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php
	src/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php
	src/Symfony/Component/Form/Tests/Util/PropertyPathTest.php
	src/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php
	src/Symfony/Component/Process/Process.php
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