-
-
Notifications
You must be signed in to change notification settings - Fork 836
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
[Testing] tmp
location in vendor
causes annoyance for local development
#2544
Comments
Option 5 would mean that you either have And even if we manage to have the For the paths I think we can use the For the database problem, one solution could be the ability to pass an option to the command, for example |
Do you mean having in the extension in addition to vendor or globally, or in replacement of one of those 2? The main problem with having it in the extension via
That'd work, and effectively fix the issue, but we'd need to maintain a copy of My reasoning for going with #5 is that if extension devs want to use one database setup for testing, #5 is the best way to do that. If they want to use different database setups for testing, there won't be a conflict anyway since they'll be using different databases |
After checking the code, that'd indeed be the only way, and I agree we should avoid that.
I was thinking in replacement of vendor, but that's a good point, I understand the concern. But if a dev opts to use a different database for an extension, then the issue of the config file getting wiped still remains. How about this, we go with option 5, but give the ability to specify a path relative to the extension's root directory so that it can be overridden for extension's that use a different database. Instead of directly reading the value of the env variable, we would first do this: $path = str_replace('%CWD%', getcwd(), (string) getenv('FLARUM_TEST_DATA_DIR')); Giving us the ability to do this in <phpunit ...>
...
<php>
<env name="FLARUM_TEST_DATA_DIR" value="%CWD%/tests/integration" force="true" />
</php>
...
</phpunit> Being able to setup the tests with: FLARUM_TEST_DATA_DIR=%CWD%/tests/integration composer test:setup |
@luceos suggested that for the global location, we could use the OS's tmp folder (or https://www.php.net/manual/en/function.sys-get-temp-dir.php). Should we use that by default vs the I think I prefer the following priority: A |
Isn't that more likely to get cleared for cleanups because it literally contains temporary files ? I think I prefer the default location to be |
Yeah I think I agree with using vendor and env vars. |
Bug Report
Current Behavior
I've run into an issue that will be annoying for local development but should not affect automated testing. Currently, the installation setup script stores data from the simulated environment in the
tmp
directory, and more importantly, the cachedconfig.php
, which, as a result of the package's extraction, will now be located invendor
, not with the test source code. So, it will be wiped on every composer update, and as a result, developers will need to re-runcomposer test:setup
whenever they make any composer changes. They will also need to runcomposer test:setup
individually for every flarum extension.This is problematic because if the database used for tests exists when
composer test:setup
is run, the setup script will crash, and testing config (which is necessary to run tests) won't be cached. Right now, developers need to completely delete and recreate the test DB every time they want to configure tests for a new database, which is very annoying.Possible Solution
tmp
directory for each extension in that extension's test code. We would need to somehow provide the path to this tmp directory to bothSetupScript.php
(easy to do through each package'ssetup.php
), and toTestCase
(not as trivial, perhaps possible through$argv
,$argc
)tmp
directory for all tests, but makes it more challenging to use separate dbs for separate packages if that's something the developer wants to do. Also, global requirements can get messy very fast, so I don't like this one at alltest:setup
that would confirm that DB credentials work and write a config.php, but not install anything. This would make rerunningtest:setup
much simpler when a DB already exists, but makes inconsistent state more likely, would prove problematic as core adds migrations, and adds a LOT of unnecessary boilerplate code as we'll need to redo portions ofInstallation
, which also means that if we change that in core, we'll also need to change it in testing.FLARUM_TEST_DATA_DIR
) exists, use that for the path totmp
. This allows developers to use one sharedtmp
directory for all packages, which won't be overriden every time composer is updated. However, it doesn't impose anything, as the defaulttmp
would still be used if that env var isn't provided.My preferred approach is (#)5.
Additional Context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: