blt icon indicating copy to clipboard operation
blt copied to clipboard

phpcs tests

Open shelane opened this issue 4 years ago • 6 comments

I want to... Run phpcs/phpcbf validation on my project files.

It's not working because... Running the commands results in an error.

Detailed error output If I run blt validate:phpcs I get the error message:

ERROR: The file "tests" does not exist.
Run "phpcbf --help" for usage information

I do have the acquia/blt-phpcs package.

BLT doctor output

+---------------------------+--------------------------------------------+
| Property                  | Value                                      |
+---------------------------+--------------------------------------------+
| %paths.%root              | /var/www/docroot                           |
| %paths.%site              | sites/default                              |
| %paths.%modules           | sites/all/modules                          |
| %paths.%themes            | sites/all/themes                           |
| %paths.%config-sync       | /var/www/config/default                    |
| %paths.%files             | sites/default/files                        |
| %paths.%temp              | /tmp                                       |
| %paths.%private           | /var/www/files-private/default             |
| admin-theme               | claro                                      |
| base-profile              |                                            |
| blt-version               | 12.8.0.0                                   |
| bootstrap                 | Successful                                 |
| composer-version          | Composer version 2.0.8 2020-12-03 17:20:38 |
| config-sync               | /var/www/config/default                    |
| db-driver                 | mysql                                      |
| db-hostname               | db                                         |
| db-name                   | default                                    |
| db-password               | user                                       |
| db-port                   | 3306                                       |
| db-status                 | Connected                                  |
| db-username               | user                                       |
| drupal-settings-file      | sites/default/settings.php                 |
| drupal-version            | 9.1.4                                      |
| drush-cache-directory     | /home/docker/.drush/cache                  |
| drush-conf.0              | /var/www/vendor/drush/drush/drush.yml      |
| drush-script              | /var/www/vendor/drush/drush/drush          |
| drush-temp                | /tmp                                       |
| drush-version             | 10.4.0                                     |
| files                     | sites/default/files                        |
| install-profile           | lightning                                  |
| modules                   | sites/all/modules                          |
| php-bin                   | /usr/local/bin/php                         |
| php-conf.1                | false                                      |
| php-os                    | Linux                                      |
| private                   | /var/www/files-private/default             |
| root                      | /var/www/docroot                           |
| site                      | sites/default                              |
| stacks.drupal-vm.inited   | false                                      |
| stacks.dev-desktop.inited | false                                      |
| temp                      | /tmp                                       |
| theme                     | listed                                     |
| themes                    | sites/all/themes                           |
| uri                       | http://housing.docksal                     |
+---------------------------+--------------------------------------------+
+---------------------------------------+------------------------------------------------------------+
| Check                                 | Problem                                                    |
+---------------------------------------+------------------------------------------------------------+
| NodeCheck:checkNodeVersionFileExists  | Neither .nvmrc nor .node-version file found in repo root.  |
| SimpleSamlPhpCheck:checkSimpleSamlPhp | Access to /var/www/docroot/simplesaml is blocked by        |
|                                       | .htaccess                                                  |
|                                       |   Add the snippet in simplesamlphp-setup.md readme to your |
|                                       | .htaccess file.                                            |
+---------------------------------------+------------------------------------------------------------+

System information

  • Operating system type: Docker: Linux
  • BLT version: 12.8.0

shelane avatar Mar 02 '21 18:03 shelane

So, there needs to be a directory tests at the root level of the project. I'm not sure what is supposed to put it there as there is no documentation about it. I found one project where it was working, so I copied that directory to the project that wasn't and then the command worked.

shelane avatar Mar 27 '21 23:03 shelane

Not sure if you go this figured out already but heres some docs on the tests directory.

https://docs.acquia.com/blt/developer/testing/#test-directory-structure

justclint avatar Jun 04 '21 02:06 justclint

The directory shouldn’t be required for a phpcs test. If it is, the install of the plug-in should check for it and add it if it doesn’t exist.

shelane avatar Jun 04 '21 02:06 shelane

@shelane is this still an issue? phpcs seems to be working fine in BLT 13 for me with the https://github.com/acquia/blt-phpcs plugin installed.

mikemadison13 avatar Dec 14 '21 20:12 mikemadison13

@mikemadison13 I can try on a clean install and see if it's still an issue. My work around was to create a tests directory back when I first discovered this issue. I'll put it on my list to look at this week.

shelane avatar Dec 14 '21 20:12 shelane

This took longer to get to than I expected, but I had a chance today to recreate it again. I did a fresh install. I ran blt validate:phpcs. It first gave this error:

 [ExecStack] '/var/www/vendor/bin/phpcs'
ERROR: The file "docroot/themes/custom" does not exist.

Run "phpcs --help" for usage information

 [ExecStack]  Exit code 3 
 Attempt to fix violations automatically via PHPCBF? (y/n) y
> source:fix:php-standards
Fixing and beautifying code...
 [Exec] Running /var/www/vendor/bin/phpcbf in /var/www
ERROR: The file "docroot/themes/custom" does not exist.

Run "phpcbf --help" for usage information

 [Exec]  Exit code 3  Time 0.302s
 [error]  PHPCBF failed.
For troubleshooting guidance and support, see https://docs.acquia.com/blt/support/ 
The command failed. This often indicates a problem with your configuration. Review the command output above for more detailed errors, and consider re-running with verbose output for more information.
 [error]  Command `source:fix:php-standards ` exited with code 1.
For troubleshooting guidance and support, see https://docs.acquia.com/blt/support/ 

It did not "fix" the issue. So I created that directory manually and ran the command again and got this error:

 [ExecStack] '/var/www/vendor/bin/phpcs'
ERROR: The file "tests" does not exist.

Run "phpcs --help" for usage information

 [ExecStack]  Exit code 3 
 Attempt to fix violations automatically via PHPCBF? (y/n) y
> source:fix:php-standards
Fixing and beautifying code...
 [Exec] Running /var/www/vendor/bin/phpcbf in /var/www
ERROR: The file "tests" does not exist.

Run "phpcbf --help" for usage information

 [Exec]  Exit code 3  Time 0.298s
 [error]  PHPCBF failed.
For troubleshooting guidance and support, see https://docs.acquia.com/blt/support/ 
The command failed. This often indicates a problem with your configuration. Review the command output above for more detailed errors, and consider re-running with verbose output for more information.
 [error]  Command `source:fix:php-standards ` exited with code 1.
For troubleshooting guidance and support, see https://docs.acquia.com/blt/support/ 

This does not indicate what the "tests file" is. However, since I know it's actually a root tests directory, I created the directory and reran the command and it works fine.

shelane avatar Mar 31 '22 16:03 shelane