Closed nWidart closed 6 years ago
As stated here, it should now be
http://<domain.dev>/tests-watcher/dashboard
This was added in this commit https://github.com/antonioribeiro/ci/commit/280c0f2cc1d85ae465a8434e49b8eeed7c0ebced
Which wasn't there before.
Yeah, the video was a preview. Version wasn't tagged when the video was tweeted. Sorry about that. But we still have a lot to improve in the docs.
I see.
Since it's an application, would be nice to have an actual full project (compose create-project), with a docker container setup for instance. Instead of having to create the laravel project, require the package etc.
The starter app is here: https://github.com/antonioribeiro/tests-watcher-starter
Nice. 👍 With docker doesn't seem it'll be possible to access other files sadly.
Tried to access another folder
This directory
exists?
And, will you watch only your tests, not the code? Or those tests are your code?
Yes, as you can see I ran ll
on the directory path I copied, with the results.
I'm not sure about what to watch, I'm first trying to make the thing work :D
I suspect however it's because the path is not accessible from within the docker container.
Somehow vendor/symfony/finder/Finder.php
is not being able to find that directory
This is the command related to that error:
$files = Finder::create()->files()->in($suite->testsFullPath);
It could be permissions, does the PHP process has permissions to read all your files?
I suspect however it's because the path is not accessible from within the docker container.
I can confirm it was because of docker. Had to set the project up with mamp.
It's able to show my test files now, however when running, it fails with the message (empty)
, in the modal.
And the output in terminal:
---------------------------------------------------------------------------------------------------------------------------
Executing vendor/bin/phpunit /Users/nicolaswidart/Sites/Asguard/Platform/Modules/Page/Tests/EloquentPageRepositoryTest.php
retrying...
retrying...
FAILED
Had to make some changes to it, enable script
on your phpunit tester and add the bin:
/**
* script
*
*/
'script' => '/usr/bin/script -q %s %s', // sprintf()
/**
* Testers
*
*/
'testers' => [
'phpunit' => [
'command' => 'vendor/bin/phpunit',
'require_script' => true,
],
Thanks. I'm now getting:
script: vendor/bin/phpunit: No such file or directory
In the modal.
I changed the phpunit path to the one in the project:
'phpunit' => [
'command' => '/Users/nicolaswidart/Sites/Asguard/Platform/vendor/bin/phpunit',
'require_script' => true,
],
But still same error.
(Btw it could be nice to specify a phpunit path per project.)
Still on docker, right?
Tester show in terminal the exact command it is executing, could you test it manually, please?
Here's an example:
All paths are relative to projects, including execution
$this->shell->exec($command, $test->suite->project->path, ...
// which calls
public function exec($command, $runDir = null, Closure $callback = null, $timeout = null)
{
$process = new Process($command, $runDir);
...
}
That's why there's no starting slash in
'command' => 'vendor/bin/phpunit',
But, yes, it could also be nice to have it by project, makes sense, thanks!
No, I had to setup with MAMP as mentionned, because inside the docker container, it had no access to local files.
This was the full output:
xecuting /usr/bin/script -q /private/var/folders/y7/ydfs5zlj2d92fk_1gywl_3680000gn/T/tw-Mq5tr5 vendor/bin/phpunit /Users/nicolaswidart/Sites/Asguard/Platform/Modules/Page/Tests/PageContentIsRenderingTest.php
retrying...
retrying...
FAILED
It's still using vendor/bin/phpstorm
still while I set the config to be the full path
'phpunit' => [
'command' => '/Users/nicolaswidart/Sites/Asguard/Platform/vendor/bin/phpunit',
'require_script' => true,
],
script (/usr/bin/script
) is installed, I presume.
works if you run it manually?:
/usr/bin/script -q /private/var/folders/y7/ydfs5zlj2d92fk_1gywl_3680000gn/T/tw-Mq5tr5 vendor/bin/phpunit /Users/nicolaswidart/Sites/Asguard/Platform/Modules/Page/Tests/PageContentIsRenderingTest.php
Hm I don't know what it is, but it exists yes. :P
Indeed, manually it runs:
Please try disabling script:
'require_script' => false,
It will not use script (it grabs everything printed in your terminal and send to a file) anymore, but you'll have to reboot watcher and tester.
I'm pretty sure it will make no difference, but that's already odd, because it's basically executing that line of code. It passes that command (and project path) to http://php.net/manual/en/function.proc-open.php.
It indeed still fails with script: vendor/bin/phpunit: No such file or directory
.
Full terminal output:
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Executing /usr/bin/script -q /private/var/folders/y7/ydfs5zlj2d92fk_1gywl_3680000gn/T/tw-N5GZ7a vendor/bin/phpunit /Users/nicolaswidart/Sites/Asguard/Platform/Modules/Page/Tests/PageContentIsRenderingTest.php
retrying...
retrying...
FAILED
Still executing script
Executing /usr/bin/script -q
Yup, but it's set to false.
I'm assuming that config isn't used, since the path to phpunit isn't read from the config either.
'phpunit' => [
'command' => '/Users/nicolaswidart/Sites/Asguard/Platform/vendor/bin/phpunit',
'require_script' => false,
],
It is stored in a table, but updated on Watcher boot:
So if I change it to
And reboot watcher:
killall php
php artisan ci:watch
It changes here:
Ah I see ok.
Now erroring with
PHPUnit 6.3.1 by Sebastian Bergmann and contributors.
Cannot open file "/Users/nicolaswidart/Sites/Asguard/Platform/Modules/Page/vendor/autoload.php".
This is normal as autoload is not in that folder.
Is it possible for this package to read the phpunit.xml file? For example to set up the test suites: https://github.com/AsgardCms/Platform/blob/3.0/phpunit.xml#L11
Tests are in the folder ./Modules/Page/Tests
(for example) but, run it from the root dir of the project.
Which I already do now with phpunit, reading the config file.
Project must be the root of your project, everything else, if you don't add a starting slash, is (almost a must be) relative to that path.
So if your app root is
/Users/nicolaswidart/Sites/Asguard
Your phpunit is probably at
/Users/nicolaswidart/Sites/Asguard/vendor/bin/phpunit
So your project config could be something like this:
'Asguard' => [
'path' => '/Users/nicolaswidart/Sites/Asguard',
'watch_folders' => [
'Modules/Page/App',
'Modules/Page/Tests'
],
'exclude' => [
'Modules/Page/Tests/console/',
'Modules/Page/Tests/screenshots/',
],
'depends' => [],
'tests_path' => 'Modules/Page/Tests',
'suites' => [
'unit' => [
'tester' => 'phpunit',
'tests_path' => '',
'command_options' => '',
'file_mask' => '*Test.php',
'retries' => 0,
],
'browser' => [
'tester' => 'dusk',
'tests_path' => 'Browser', // relative to the tests path
'command_options' => '',
'file_mask' => '*Test.php',
'retries' => 0,
],
],
],
Of course this is just an example.
And, yes, I think it's possible to read the phpunit.xml and get some information from it.
Yes, but I have more tests path. As you can see from the phpunit config file, there are multiple tests path.
For now I had to duplicate the whole config section you posted, basically 1 project for each folder.
It works, tho not very easy to maintain. :D
Adding more suites could help you with your different tests paths:
'Multiple suites' => [
'path' => $basePath,
'watch_folders' => [
'.',
'resources/assets/js/tests'
],
'exclude' => [
'storage',
'.idea',
],
'depends' => [],
'tests_path' => 'tests/Multiple/',
'suites' => [
'module_page' => [
'tester' => 'phpunit',
'tests_path' => 'Page',
'command_options' => '',
'file_mask' => '*Test.php',
'retries' => 0,
],
'module_media' => [
'tester' => 'phpunit',
'tests_path' => 'Media',
'command_options' => '',
'file_mask' => '*Test.php',
'retries' => 0,
],
],
],
Hm interesting, I can try that.
I tried this, but the watcher stops running w/o error, and dashboard has empty tests
'AsgardCMS' => [
'path' => '/Users/nicolaswidart/Sites/Asguard/Platform',
'watch_folders' => [
'Modules/Page',
],
'tests_path' => 'tests/Something',
'exclude' => [],
'depends' => [],
'suites' => [
'page_module' => [
'tester' => 'phpunit',
'tests_path' => 'Modules/Page/Tests',
'command_options' => '',
'file_mask' => '*Test.php',
'retries' => 0,
],
'core_module' => [
'tester' => 'phpunit',
'tests_path' => 'Modules/Core/Tests',
'command_options' => '',
'file_mask' => '*Test.php',
'retries' => 0,
],
],
],
Oh I see, I can leave the main "tests_path" empty. 👍
It might be better to have multiple projects per folder, so that only the relevant tests are re-run with the watcher.
Ie, only run the tests in Modules/User/Tests
if something in Modules/User
was changed, and so on.
This is my full config:
https://gist.github.com/nWidart/bc029a875ea51e36a0bbbfc372d35ce0
Yes, in this case it's the best option, we could add an option in the suite to not watch for files outside the suite, but I think it could be even more confusing...
Can we close this one already?
Yes. Thanks for your help! 👍
The readme doesn't say anything about which URI to go to.
The routes has a bunch, none worked for me.