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

phpcs tests #4355

Open
shelane opened this issue Mar 2, 2021 · 6 comments
Open

phpcs tests #4355

shelane opened this issue Mar 2, 2021 · 6 comments
Labels
Support A support request

Comments

@shelane
Copy link
Contributor

shelane commented Mar 2, 2021

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 shelane added the Support A support request label Mar 2, 2021
@shelane
Copy link
Contributor Author

shelane commented Mar 27, 2021

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.

@justclint
Copy link

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

@shelane
Copy link
Contributor Author

shelane commented Jun 4, 2021

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.

@mikemadison13
Copy link
Contributor

@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.

@shelane
Copy link
Contributor Author

shelane commented Dec 14, 2021

@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
Copy link
Contributor Author

shelane commented Mar 31, 2022

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.

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

No branches or pull requests

3 participants