Page MenuHomePhabricator

phpunit.xml.dist: Remove support for both lowercase unit and uppercase Unit directory, as it's unfriendly for case-insensitive OSes
Open, In Progress, Needs TriagePublic

Description

Supporting both tests/phpunit/unit and tests/phpunit/Unit can lead to failures on some systems where the same class is loaded twice. Let's just enforce lowercase unit as the preferred directory by removing tests/phpunit/Unit from phpunit.xml.dist and update relevant documentation, plus also update the handful of extensions that use Unit for that directory.


Original report

I'm trying to update this page:

I'm following instructions from:

Short:

~/Documents/gerrit/integration/quibble$ docker run -it --rm \
  -v "$(pwd)"/cache:/cache \
  -v "$(pwd)"/log:/workspace/log \
  -v "$(pwd)"/ref:/srv/git:ro \
  -v "$(pwd)"/src:/workspace/src \
  docker-registry.wikimedia.org/releng/quibble-stretch-php72:latest
...
INFO:quibble.commands:composer phpunit:unit -- --exclude-group Broken,ParserFuzz,Stub --log-junit /workspace/log/junit-unit.xml
> phpunit --colors=always --testsuite=core:unit,extensions:unit,skins:unit '--exclude-group' 'Broken,ParserFuzz,Stub' '--log-junit' '/workspace/log/junit-unit.xml'
PHP Fatal error:  Cannot declare class Vector\FeatureManagement\Tests\FeatureManagerTest, because the name is already in use in /workspace/src/skins/Vector/tests/phpunit/Unit/FeatureManagement/FeatureManagerTest.php on line 147
Script phpunit --colors=always --testsuite=core:unit,extensions:unit,skins:unit handling the phpunit:unit event returned with error code 255
INFO:quibble.commands:<<< Finish: PHPUnit unit tests, in 4.079 s
...

Long:

1~/Documents/gerrit/integration$ docker pull docker-registry.wikimedia.org/releng/quibble-stretch-php72:latest
2latest: Pulling from releng/quibble-stretch-php72
3Digest: sha256:88ffbd44f4491b3a124c7fff15487f8248d35a911d78f85b34d0f5c2bcd5798a
4Status: Image is up to date for docker-registry.wikimedia.org/releng/quibble-stretch-php72:latest
5docker-registry.wikimedia.org/releng/quibble-stretch-php72:latest
6
7
8
9~/Documents/gerrit/integration$ git clone "https://gerrit.wikimedia.org/r/integration/quibble"
10Cloning into 'quibble'...
11remote: Counting objects: 2015, done
12remote: Finding sources: 100% (2015/2015)
13remote: Getting sizes: 100% (132/132)
14remote: Total 2015 (delta 1488), reused 2015 (delta 1488)
15Receiving objects: 100% (2015/2015), 445.05 KiB | 632.00 KiB/s, done.
16Resolving deltas: 100% (1488/1488), done.
17
18
19
20~/Documents/gerrit/integration$ cd quibble
21
22
23
24~/Documents/gerrit/integration/quibble$ mkdir -p ref/mediawiki/skins
25
26
27
28~/Documents/gerrit/integration/quibble$ git clone --bare https://gerrit.wikimedia.org/r/mediawiki/core ref/mediawiki/core.git
29Cloning into bare repository 'ref/mediawiki/core.git'...
30remote: Counting objects: 19290, done
31remote: Finding sources: 100% (378/378)
32remote: Getting sizes: 100% (290/290)
33remote: Compressing objects: 99% (13575/13576)
34remote: Total 912555 (delta 155), reused 912285 (delta 36)
35Receiving objects: 100% (912555/912555), 284.85 MiB | 1.42 MiB/s, done.
36Resolving deltas: 100% (777156/777156), done.
37
38
39
40~/Documents/gerrit/integration/quibble$ git clone --bare https://gerrit.wikimedia.org/r/mediawiki/vendor ref/mediawiki/vendor.git
41Cloning into bare repository 'ref/mediawiki/vendor.git'...
42remote: Counting objects: 5, done
43remote: Total 41698 (delta 0), reused 41698 (delta 0)
44Receiving objects: 100% (41698/41698), 100.42 MiB | 1.66 MiB/s, done.
45Resolving deltas: 100% (30364/30364), done.
46
47
48
49~/Documents/gerrit/integration/quibble$ git clone --bare https://gerrit.wikimedia.org/r/mediawiki/skins/Vector ref/mediawiki/skins/Vector.git
50Cloning into bare repository 'ref/mediawiki/skins/Vector.git'...
51remote: Counting objects: 5, done
52remote: Total 10802 (delta 0), reused 10802 (delta 0)
53Receiving objects: 100% (10802/10802), 2.97 MiB | 1.33 MiB/s, done.
54Resolving deltas: 100% (8061/8061), done.
55
56
57
58~/Documents/gerrit/integration/quibble$ mkdir cache
59~/Documents/gerrit/integration/quibble$ chmod 777 cache
60
61
62
63~/Documents/gerrit/integration/quibble$ mkdir -p log
64~/Documents/gerrit/integration/quibble$ chmod 777 log
65
66
67
68~/Documents/gerrit/integration/quibble$ mkdir -p src
69~/Documents/gerrit/integration/quibble$ chmod 777 src
70
71
72
73~/Documents/gerrit/integration/quibble$ docker run -it --rm \
74 -v "$(pwd)"/cache:/cache \
75 -v "$(pwd)"/log:/workspace/log \
76 -v "$(pwd)"/ref:/srv/git:ro \
77 -v "$(pwd)"/src:/workspace/src \
78 docker-registry.wikimedia.org/releng/quibble-stretch-php72:latest
79WARNING:quibble.cmd:ZUUL_PROJECT not set. Assuming mediawiki/core
80INFO:quibble.cmd:Adding mediawiki/vendor
81INFO:quibble.cmd:Projects: mediawiki/core, mediawiki/skins/Vector, mediawiki/vendor
82INFO:zuul.CloneMapper:Workspace path set to: ./
83INFO:zuul.CloneMapper:Mapping projects to workspace...
84INFO:zuul.CloneMapper: mediawiki/core -> .
85INFO:zuul.CloneMapper:Expansion completed.
86DEBUG:quibble.cmd:Running stages: phpunit-unit, phpunit, phpunit-standalone, npm-test, composer-test, qunit, selenium, api-testing
87DEBUG:quibble.cmd:Execution plan:
88DEBUG:quibble.cmd:Report package versions
89DEBUG:quibble.cmd:Ensure we have the directory '/workspace/log'
90DEBUG:quibble.cmd:Zuul clone with parameters {"cache_dir": "/srv/git", "projects": ["mediawiki/core", "mediawiki/skins/Vector", "mediawiki/vendor"], "workers": 4, "workspace": "/workspace/src"}
91DEBUG:quibble.cmd:Extension and skin submodule update under MediaWiki root /workspace/src
92DEBUG:quibble.cmd:Install composer dev-requires for vendor.git
93DEBUG:quibble.cmd:PHPUnit unit tests
94DEBUG:quibble.cmd:Start backends, <mysql (no socket)>
95DEBUG:quibble.cmd:Install MediaWiki, db=<mysql (no socket)> vendor=True
96DEBUG:quibble.cmd:npm install in /workspace/src
97DEBUG:quibble.cmd:PHPUnit default suite (without database or standalone)
98DEBUG:quibble.cmd:Run tests in mediawiki/core: composer, npm
99DEBUG:quibble.cmd:Start backends, <PhpWebserver http://127.0.0.1:9412 /workspace/src> <Xvfb :94> <ChromeWebDriver :94>
100DEBUG:quibble.cmd:Run Qunit tests
101DEBUG:quibble.cmd:Browser tests for projects mediawiki/core, mediawiki/skins/Vector, mediawiki/vendor
102DEBUG:quibble.cmd:Run API-Testing
103DEBUG:quibble.cmd:PHPUnit default suite (with database)
104INFO:quibble.commands:>>> Start: Report package versions
105INFO:quibble.commands:Python version: 3.5.3 (default, Nov 18 2020, 21:09:16)
106[GCC 6.3.0 20170516]
107INFO:quibble.commands:chromedriver --version: ChromeDriver 73.0.3683.75
108INFO:quibble.commands:chromium --version: Chromium 73.0.3683.75 built on Debian 9.8, running on Debian 9.13
109INFO:quibble.commands:composer --version: Composer version 1.10.17 2020-10-30 22:31:58
110INFO:quibble.commands:mysql --version: mysql Ver 15.1 Distrib 10.1.48-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
111INFO:quibble.commands:psql --version: psql (PostgreSQL) 9.6.20
112INFO:quibble.commands:node --version: v10.15.2
113INFO:quibble.commands:npm --version: 6.14.5
114INFO:quibble.commands:php --version: PHP 7.2.31-1+0~20200514.41+debian9~1.gbpe2a56b+wmf1 (cli) (built: May 29 2020 08:36:37) ( NTS )
115INFO:quibble.commands:Copyright (c) 1997-2018 The PHP Group
116INFO:quibble.commands:Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
117INFO:quibble.commands: with Zend OPcache v7.2.31-1+0~20200514.41+debian9~1.gbpe2a56b+wmf1, Copyright (c) 1999-2018, by Zend Technologies
118INFO:quibble.commands:<<< Finish: Report package versions, in 0.963 s
119INFO:quibble.commands:>>> Start: Ensure we have the directory '/workspace/log'
120INFO:quibble.commands:<<< Finish: Ensure we have the directory '/workspace/log', in 0.001 s
121INFO:quibble.commands:>>> Start: Zuul clone with parameters {"cache_dir": "/srv/git", "projects": ["mediawiki/core", "mediawiki/skins/Vector", "mediawiki/vendor"], "workers": 4, "workspace": "/workspace/src"}
122INFO:zuul.CloneMapper:Workspace path set to: /workspace/src
123INFO:zuul.CloneMapper:Mapping projects to workspace...
124INFO:zuul.CloneMapper: mediawiki/core -> /workspace/src
125INFO:zuul.CloneMapper: mediawiki/skins/Vector -> /workspace/src/skins/Vector
126INFO:zuul.CloneMapper: mediawiki/vendor -> /workspace/src/vendor
127INFO:zuul.CloneMapper:Expansion completed.
128INFO:quibble.zuul.clone:Preparing 3 repositories with 4 workers
129INFO:quibble.zuul.clone:Cloning mediawiki/core first
130INFO:zuul.Cloner:Creating repo mediawiki/core from cache /srv/git/mediawiki/core.git
131INFO:zuul.Cloner:Updating origin remote in repo mediawiki/core to https://gerrit.wikimedia.org/r/mediawiki/core
132INFO:zuul.Cloner:Falling back to branch master
133INFO:zuul.Cloner:Prepared mediawiki/core repo with branch master at commit e623a91aab596b0c1fe7f9bfcfb47e2cd7e001cd
134INFO:zuul.Cloner.mediawiki/vendor:Creating repo mediawiki/vendor from cache /srv/git/mediawiki/vendor.git
135INFO:zuul.Cloner.mediawiki/skins/Vector:Creating repo mediawiki/skins/Vector from cache /srv/git/mediawiki/skins/Vector.git
136INFO:zuul.Cloner.mediawiki/skins/Vector:Updating origin remote in repo mediawiki/skins/Vector to https://gerrit.wikimedia.org/r/mediawiki/skins/Vector
137INFO:zuul.Cloner.mediawiki/skins/Vector:Falling back to branch master
138INFO:zuul.Cloner.mediawiki/skins/Vector:Prepared mediawiki/skins/Vector repo with branch master at commit c1a6d14fe92936fc7544164e68cdd83fe595e7f4
139INFO:zuul.Cloner.mediawiki/vendor:Updating origin remote in repo mediawiki/vendor to https://gerrit.wikimedia.org/r/mediawiki/vendor
140INFO:zuul.Cloner.mediawiki/vendor:Falling back to branch master
141INFO:zuul.Cloner.mediawiki/vendor:Prepared mediawiki/vendor repo with branch master at commit 89b69fb9b2f9eff1e6d1f29eb24f8516adbeb71d
142INFO:quibble.zuul.clone:Prepared all repositories
143INFO:quibble.commands:<<< Finish: Zuul clone with parameters {"cache_dir": "/srv/git", "projects": ["mediawiki/core", "mediawiki/skins/Vector", "mediawiki/vendor"], "workers": 4, "workspace": "/workspace/src"}, in 148.844 s
144INFO:quibble.commands:>>> Start: Extension and skin submodule update under MediaWiki root /workspace/src
145INFO:quibble.commands:Updating git submodules of extensions and skins
146INFO:quibble.commands:<<< Finish: Extension and skin submodule update under MediaWiki root /workspace/src, in 0.003 s
147INFO:quibble.commands:>>> Start: Install composer dev-requires for vendor.git
148INFO:quibble.commands:vendor.git used. Requiring composer dev dependencies
149DEBUG:quibble.commands:composer require doctrine/sql-formatter=1.1.1 composer/spdx-licenses=1.5.4 giorgiosironi/eris=^0.10.0 pimple/pimple=3.3.1 johnkary/phpunit-speedtrap=^3.1 monolog/monolog=~2.2.0 mediawiki/mediawiki-codesniffer=35.0.0 wmde/hamcrest-html-matchers=^0.1.0 symfony/yaml=~3.4|~5.1 seld/jsonlint=1.8.3 hamcrest/hamcrest-php=^2.0 wikimedia/testing-access-wrapper=~2.0 justinrainbow/json-schema=~5.2 nikic/php-parser=4.10.2 doctrine/dbal=2.10.4||3.0.0 mediawiki/mediawiki-phan-config=0.10.6 nmred/kafka-php=0.1.5 psy/psysh=0.10.5 phpunit/phpunit=^8.5 php-parallel-lint/php-parallel-lint=1.2.0 php-parallel-lint/php-console-highlighter=0.5
150Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
151./composer.json has been updated
152Loading composer repositories with package information
153Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
154Updating dependencies (including require-dev)
155Dependency resolution completed in 0.019 seconds
156Analyzed 9887 packages to resolve dependencies
157Analyzed 9948 rules to resolve dependencies
158Dependency resolution completed in 0.001 seconds
159Package operations: 55 installs, 0 updates, 0 removals
160Installs: doctrine/sql-formatter:1.1.1, giorgiosironi/eris:0.10.0, squizlabs/php_codesniffer:3.5.8, composer/spdx-licenses:1.5.4, mediawiki/mediawiki-codesniffer:v35.0.0, sabre/event:5.1.2, netresearch/jsonmapper:v2.1.0, microsoft/tolerant-php-parser:v0.0.23, phpdocumentor/reflection-common:2.2.0, webmozart/assert:1.10.0, phpdocumentor/type-resolver:1.4.0, phpdocumentor/reflection-docblock:5.2.2, felixfbecker/advanced-json-rpc:v3.2.0, composer/xdebug-handler:1.4.6, phan/phan:3.2.6, mediawiki/phan-taint-check-plugin:3.2.1, mediawiki/mediawiki-phan-config:0.10.6, php-parallel-lint/php-console-color:v0.3, php-parallel-lint/php-console-highlighter:v0.5, seld/jsonlint:1.8.3, doctrine/event-manager:1.1.1, doctrine/cache:1.10.2, doctrine/dbal:2.10.4, sebastian/version:2.0.1, sebastian/type:1.1.4, sebastian/resource-operations:2.0.2, sebastian/recursion-context:3.0.1, sebastian/object-reflector:1.1.2, sebastian/object-enumerator:3.0.4, sebastian/global-state:3.0.1, sebastian/exporter:3.1.3, sebastian/environment:4.2.4, sebastian/diff:3.0.3, sebastian/comparator:3.0.3, phpunit/php-timer:2.1.3, phpunit/php-text-template:1.2.1, phpunit/php-file-iterator:2.0.3, theseer/tokenizer:1.2.0, sebastian/code-unit-reverse-lookup:1.0.2, phpunit/php-token-stream:3.1.2, phpunit/php-code-coverage:7.0.14, doctrine/instantiator:1.4.0, phpspec/prophecy:1.13.0, myclabs/deep-copy:1.10.2, phar-io/version:3.1.0, phar-io/manifest:2.0.1, phpunit/phpunit:8.5.15, johnkary/phpunit-speedtrap:v3.3.0, php-parallel-lint/php-parallel-lint:v1.2.0, swaggest/json-diff:v3.8.1, phplang/scope-exit:1.0.0, swaggest/json-schema:v0.12.29, symfony/yaml:v5.2.5, hamcrest/hamcrest-php:v2.0.1, wmde/hamcrest-html-matchers:v0.1.1
161 - Installing doctrine/sql-formatter (1.1.1): Downloading (100%)
162 Extracting archive - Installing giorgiosironi/eris (0.10.0): Downloading (100%)
163 Extracting archive - Installing squizlabs/php_codesniffer (3.5.8): Downloading (100%)
164 Extracting archive - Installing composer/spdx-licenses (1.5.4): Downloading (100%)
165 Extracting archive - Installing mediawiki/mediawiki-codesniffer (v35.0.0): Downloading (100%)
166 Extracting archive - Installing sabre/event (5.1.2): Downloading (100%)
167 Extracting archive - Installing netresearch/jsonmapper (v2.1.0): Downloading (100%)
168 Extracting archive - Installing microsoft/tolerant-php-parser (v0.0.23): Downloading (100%)
169 Extracting archive - Installing phpdocumentor/reflection-common (2.2.0): Downloading (100%)
170 Extracting archive - Installing webmozart/assert (1.10.0): Downloading (100%)
171 Extracting archive - Installing phpdocumentor/type-resolver (1.4.0): Downloading (100%)
172 Extracting archive - Installing phpdocumentor/reflection-docblock (5.2.2): Downloading (100%)
173 Extracting archive - Installing felixfbecker/advanced-json-rpc (v3.2.0): Downloading (100%)
174 Extracting archive - Installing composer/xdebug-handler (1.4.6): Downloading (100%)
175 Extracting archive - Installing phan/phan (3.2.6): Downloading (100%)
176 Extracting archive - Installing mediawiki/phan-taint-check-plugin (3.2.1): Downloading (100%)
177 Extracting archive - Installing mediawiki/mediawiki-phan-config (0.10.6): Downloading (100%)
178 Extracting archive - Installing php-parallel-lint/php-console-color (v0.3): Downloading (100%)
179 Extracting archive - Installing php-parallel-lint/php-console-highlighter (v0.5): Downloading (100%)
180 Extracting archive - Installing seld/jsonlint (1.8.3): Downloading (100%)
181 Extracting archive - Installing doctrine/event-manager (1.1.1): Downloading (100%)
182 Extracting archive - Installing doctrine/cache (1.10.2): Downloading (100%)
183 Extracting archive - Installing doctrine/dbal (2.10.4): Downloading (100%)
184 Extracting archive - Installing sebastian/version (2.0.1): Downloading (100%)
185 Extracting archive - Installing sebastian/type (1.1.4): Downloading (100%)
186 Extracting archive - Installing sebastian/resource-operations (2.0.2): Downloading (100%)
187 Extracting archive - Installing sebastian/recursion-context (3.0.1): Downloading (100%)
188 Extracting archive - Installing sebastian/object-reflector (1.1.2): Downloading (100%)
189 Extracting archive - Installing sebastian/object-enumerator (3.0.4): Downloading (100%)
190 Extracting archive - Installing sebastian/global-state (3.0.1): Downloading (100%)
191 Extracting archive - Installing sebastian/exporter (3.1.3): Downloading (100%)
192 Extracting archive - Installing sebastian/environment (4.2.4): Downloading (100%)
193 Extracting archive - Installing sebastian/diff (3.0.3): Downloading (100%)
194 Extracting archive - Installing sebastian/comparator (3.0.3): Downloading (100%)
195 Extracting archive - Installing phpunit/php-timer (2.1.3): Downloading (100%)
196 Extracting archive - Installing phpunit/php-text-template (1.2.1): Downloading (100%)
197 Extracting archive - Installing phpunit/php-file-iterator (2.0.3): Downloading (100%)
198 Extracting archive - Installing theseer/tokenizer (1.2.0): Downloading (100%)
199 Extracting archive - Installing sebastian/code-unit-reverse-lookup (1.0.2): Downloading (100%)
200 Extracting archive - Installing phpunit/php-token-stream (3.1.2): Downloading (100%)
201 Extracting archive - Installing phpunit/php-code-coverage (7.0.14): Downloading (100%)
202 Extracting archive - Installing doctrine/instantiator (1.4.0): Downloading (100%)
203 Extracting archive - Installing phpspec/prophecy (1.13.0): Downloading (100%)
204 Extracting archive - Installing myclabs/deep-copy (1.10.2): Downloading (100%)
205 Extracting archive - Installing phar-io/version (3.1.0): Downloading (100%)
206 Extracting archive - Installing phar-io/manifest (2.0.1): Downloading (100%)
207 Extracting archive - Installing phpunit/phpunit (8.5.15): Downloading (100%)
208 Extracting archive - Installing johnkary/phpunit-speedtrap (v3.3.0): Downloading (100%)
209 Extracting archive - Installing php-parallel-lint/php-parallel-lint (v1.2.0): Downloading (100%)
210 Extracting archive - Installing swaggest/json-diff (v3.8.1): Downloading (100%)
211 Extracting archive - Installing phplang/scope-exit (1.0.0): Downloading (100%)
212 Extracting archive - Installing swaggest/json-schema (v0.12.29): Downloading (100%)
213 Extracting archive - Installing symfony/yaml (v5.2.5): Downloading (100%)
214 Extracting archive - Installing hamcrest/hamcrest-php (v2.0.1): Downloading (100%)
215 Extracting archive - Installing wmde/hamcrest-html-matchers (v0.1.1): Downloading (100%)
216 Extracting archivegiorgiosironi/eris suggests installing icomefromthenet/reverse-regex (v0.0.6.3 for the regex() Generator)
217phan/phan suggests installing ext-ast (Needed for parsing ASTs (unless --use-fallback-parser is used). 1.0.1+ is needed, 1.0.8+ is recommended.)
218phan/phan suggests installing ext-igbinary (Improves performance of polyfill when ext-ast is unavailable)
219doctrine/cache suggests installing alcaeus/mongo-php-adapter (Required to use legacy MongoDB driver)
220sebastian/global-state suggests installing ext-uopz (*)
221phpunit/php-code-coverage suggests installing ext-xdebug (^2.7.2)
222phpunit/phpunit suggests installing phpunit/php-invoker (^2.0.0)
223phpunit/phpunit suggests installing ext-soap (*)
224phpunit/phpunit suggests installing ext-xdebug (*)
225Package guzzlehttp/ringphp is abandoned, you should avoid using it. No replacement was suggested.
226Package guzzlehttp/streams is abandoned, you should avoid using it. No replacement was suggested.
227Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
228Writing lock file
229Generating optimized autoload files
23050 packages you are using are looking for funding.
231Use the `composer fund` command to find out more!
232Generating optimized autoload files (authoritative)
233Generated optimized autoload files (authoritative) containing 5576 classes
234INFO:quibble.util:Copying /workspace/src/composer.json to /workspace/log/composer.core.json.txt
235INFO:quibble.util:Copying /workspace/src/vendor/composer.json to /workspace/log/composer.vendor.json.txt
236INFO:quibble.util:Copying /workspace/src/vendor/composer/autoload_files.php to /workspace/log/composer.autoload_files.php.txt
237INFO:quibble.commands:<<< Finish: Install composer dev-requires for vendor.git, in 160.131 s
238INFO:quibble.commands:>>> Start: PHPUnit unit tests
239INFO:quibble.commands:PHPUnit unit tests
240INFO:quibble.commands:composer phpunit:unit -- --exclude-group Broken,ParserFuzz,Stub --log-junit /workspace/log/junit-unit.xml
241> phpunit --colors=always --testsuite=core:unit,extensions:unit,skins:unit '--exclude-group' 'Broken,ParserFuzz,Stub' '--log-junit' '/workspace/log/junit-unit.xml'
242PHP Fatal error: Cannot declare class Vector\FeatureManagement\Tests\FeatureManagerTest, because the name is already in use in /workspace/src/skins/Vector/tests/phpunit/Unit/FeatureManagement/FeatureManagerTest.php on line 147
243Script phpunit --colors=always --testsuite=core:unit,extensions:unit,skins:unit handling the phpunit:unit event returned with error code 255
244INFO:quibble.commands:<<< Finish: PHPUnit unit tests, in 4.464 s
245Traceback (most recent call last):
246 File "/usr/local/bin/quibble", line 11, in <module>
247 load_entry_point('quibble==0.0.46', 'console_scripts', 'quibble')()
248 File "/usr/local/lib/python3.5/dist-packages/quibble/cmd.py", line 639, in main
249 cmd.execute(plan, dry_run=args.dry_run)
250 File "/usr/local/lib/python3.5/dist-packages/quibble/cmd.py", line 402, in execute
251 quibble.commands.execute_command(command)
252 File "/usr/local/lib/python3.5/dist-packages/quibble/commands.py", line 22, in execute_command
253 command.execute()
254 File "/usr/local/lib/python3.5/dist-packages/quibble/commands.py", line 694, in execute
255 self._run_phpunit(cmd=['composer', 'phpunit:unit', '--'])
256 File "/usr/local/lib/python3.5/dist-packages/quibble/commands.py", line 641, in _run_phpunit
257 subprocess.check_call(cmd, cwd=self.mw_install_path, env=phpunit_env)
258 File "/usr/lib/python3.5/subprocess.py", line 271, in check_call
259 raise CalledProcessError(retcode, cmd)
260subprocess.CalledProcessError: Command '['composer', 'phpunit:unit', '--', '--exclude-group', 'Broken,ParserFuzz,Stub', '--log-junit', '/workspace/log/junit-unit.xml']' returned non-zero exit status 255

Event Timeline

Yeah, I don't think this is Quibble's fault exactly. In my local environment just running composer phpunit:unit I get:

> phpunit --colors=always --testsuite=core:unit,extensions:unit,skins:unit
PHP Fatal error:  Cannot declare class AbuseFilterVariableGeneratorTest, because the name is already in use in /Users/kostajh/src/mediawiki/w/extensions/AbuseFilter/tests/phpunit/Unit/AbuseFilterVariableGeneratorTest.php on line 24

Fatal error: Cannot declare class AbuseFilterVariableGeneratorTest, because the name is already in use in /Users/kostajh/src/mediawiki/w/extensions/AbuseFilter/tests/phpunit/Unit/AbuseFilterVariableGeneratorTest.php on line 24

I haven't tried to track this down yet. (cc @Daimona in case you've got any ideas)

The Unit subdirectory looks suspicious.

Same in Zeljko paste:

/workspace/src/skins/Vector/tests/phpunit/Unit/FeatureManagement/FeatureManagerTest.php
                                          ^^^^

Can it depends on the case sensitiveness of the underlying filesystem? I can't reproduce.

Can it depends on the case sensitiveness of the underlying filesystem? I can't reproduce.

I was sure I've mentioned it in the task, but I didn't. 🤦‍♂️ I was running this on a Mac.

I am pretty sure it is not related to Quibble so flagging with the generic MediaWiki-Core-Tests instead.

The only thing I can find related to the upper case Unit is:

phpunit.xml.dist
<testsuite name="extensions:unit">
    <directory>extensions/**/tests/phpunit/unit</directory>  
    <directory>extensions/**/tests/phpunit/Unit</directory>  
</testsuite>
<testsuite name="skins:unit">
    <directory>skins/**/tests/phpunit/unit</directory>       
    <directory>skins/**/tests/phpunit/Unit</directory>       
</testsuite>

So I can imagine that when PHPUnit crawls through Vector using the lower case skins/**/tests/phpunit/unit it finds the test class and load it. Then PHPUnit crawls the path having an upper case (skins/**/tests/phpunit/Unit) and assuming the filesystem is case insensitive that yields the same PHP class which is loaded a second time. Duplicate class, failure.

That has been introduced back in 2019 apparently, I imagine to support unit tests being placed by Windows developers (the OS would use an upper case first name when creating a directory).

The only case we have would be four extensions for which we can rename Unit to unit:

$ ls -1d {extensions,skins}/*/tests/phpunit/Unit

ls: cannot access 'skins/*/tests/phpunit/Unit': No such file or directory

extensions/ChessBrowser/tests/phpunit/Unit/
extensions/DumpsOnDemand/tests/phpunit/Unit/
extensions/Lingo/tests/phpunit/Unit/
extensions/WikibaseQualityConstraints/tests/phpunit/Unit/

Once they got renamed, we can remove the wildcard in mediawiki/core phpunit.xml.dist pasted above, update whatever documentation we have as to how an extension or skin should be structured and I think that will resolve the task.

I am pretty sure it is not related to Quibble so flagging with the generic MediaWiki-Core-Tests instead.

It would probably make sense to rename the task too. I'm not sure what the problem is, so I'm hesitant to rename it myself.

I am pretty sure it is not related to Quibble so flagging with the generic MediaWiki-Core-Tests instead.

The only thing I can find related to the upper case Unit is:

phpunit.xml.dist
<testsuite name="extensions:unit">
    <directory>extensions/**/tests/phpunit/unit</directory>  
    <directory>extensions/**/tests/phpunit/Unit</directory>  
</testsuite>
<testsuite name="skins:unit">
    <directory>skins/**/tests/phpunit/unit</directory>       
    <directory>skins/**/tests/phpunit/Unit</directory>       
</testsuite>

So I can imagine that when PHPUnit crawls through Vector using the lower case skins/**/tests/phpunit/unit it finds the test class and load it. Then PHPUnit crawls the path having an upper case (skins/**/tests/phpunit/Unit) and assuming the filesystem is case insensitive that yields the same PHP class which is loaded a second time. Duplicate class, failure.

That has been introduced back in 2019 apparently, I imagine to support unit tests being placed by Windows developers (the OS would use an upper case first name when creating a directory).

The only case we have would be four extensions for which we can rename Unit to unit:

$ ls -1d {extensions,skins}/*/tests/phpunit/Unit

ls: cannot access 'skins/*/tests/phpunit/Unit': No such file or directory

extensions/ChessBrowser/tests/phpunit/Unit/
extensions/DumpsOnDemand/tests/phpunit/Unit/
extensions/Lingo/tests/phpunit/Unit/
extensions/WikibaseQualityConstraints/tests/phpunit/Unit/

Once they got renamed, we can remove the wildcard in mediawiki/core phpunit.xml.dist pasted above, update whatever documentation we have as to how an extension or skin should be structured and I think that will resolve the task.

Well spotted @hashar!

kostajh renamed this task from Local quibble run fails with `PHP Fatal error` to phpunit.xml.dist: Remove support for uppercase Unit directory discovery.Mar 30 2021, 2:04 PM
kostajh updated the task description. (Show Details)

@zeljkofilipin can you prepare patches for the affected repositories and to drop Unit from phpunit.xml.dist please? I will be happy to review / guide / approve such patches :]

@hashar gladly, but I'm very busy with other things. I'll move it to my backlog and work on it when I have the time.

Change 740259 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/core@master] Revert \"Discover unit tests in \"Unit\" directory\"

https://gerrit.wikimedia.org/r/740259

Change 740326 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/WikibaseQualityConstraints@master] Rename Unit directory to unit

https://gerrit.wikimedia.org/r/740326

Change 740327 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/DumpsOnDemand@master] phpunit: Rename Unit directory to unit

https://gerrit.wikimedia.org/r/740327

Change 740328 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/Lingo@master] phpunit: Rename Unit directory to unit

https://gerrit.wikimedia.org/r/740328

kostajh changed the task status from Open to In Progress.Nov 21 2021, 1:27 PM
kostajh moved this task from Backlog to In progress on the User-kostajh board.

Change 740259 merged by jenkins-bot:

[mediawiki/core@master] Revert \"Discover unit tests in \"Unit\" directory\"

https://gerrit.wikimedia.org/r/740259

Change 740326 merged by jenkins-bot:

[mediawiki/extensions/WikibaseQualityConstraints@master] Rename Unit directory to unit

https://gerrit.wikimedia.org/r/740326

My understanding is that uppercase Unit is supported for better PSR-4 compliance: for example, WikibaseQualityConstraints configures

"TestAutoloadNamespaces": {
    "WikibaseQuality\\ConstraintReport\\Tests\\": "tests/phpunit/"
},

and therefore the correct path for the class WikibaseQuality\ConstraintReport\Tests\Unit\ItemIdSnakValueTest is tests/phpunit/Unit/ItemIdSnakValueTest.php, with uppercase Unit, not lowercase unit.

I can see some value in standardizing on one capitalization, but why does it have to be the lowercase one? Uppercase is better for PSR-4 (unless we want to start having lowercased namespace names, in deviation from our usual practice); does lowercase have any advantages?

My understanding is that uppercase Unit is supported for better PSR-4 compliance: for example, WikibaseQualityConstraints configures

"TestAutoloadNamespaces": {
    "WikibaseQuality\\ConstraintReport\\Tests\\": "tests/phpunit/"
},

and therefore the correct path for the class WikibaseQuality\ConstraintReport\Tests\Unit\ItemIdSnakValueTest is tests/phpunit/Unit/ItemIdSnakValueTest.php, with uppercase Unit, not lowercase unit.

I agree that "Unit" is more correct than "unit".

I can see some value in standardizing on one capitalization, but why does it have to be the lowercase one? Uppercase is better for PSR-4 (unless we want to start having lowercased namespace names, in deviation from our usual practice); does lowercase have any advantages?

Because we'd have to mass rename a lot of directories from "unit" to "Unit", I suspect, whereas replacing Unit -> unit was three patches. We could go the way you propose, though. The lowercase is also consistent with how subdirectories exist in core, but that could be changed as well.

T166010: The Great Namespaceization Effort also seems relevant.

I can see some value in standardizing on one capitalization, but why does it have to be the lowercase one? Uppercase is better for PSR-4 (unless we want to start having lowercased namespace names, in deviation from our usual practice); does lowercase have any advantages?

I was going to write the exact same thing yesterday, then didn't find the time to finish my comment.

Because we'd have to mass rename a lot of directories from "unit" to "Unit", I suspect, whereas replacing Unit -> unit was three patches. We could go the way you propose, though.

I was going to say that we could have LibUp mass-rename the directories all around the place.

I can see some value in standardizing on one capitalization, but why does it have to be the lowercase one? Uppercase is better for PSR-4 (unless we want to start having lowercased namespace names, in deviation from our usual practice); does lowercase have any advantages?

I was going to write the exact same thing yesterday, then didn't find the time to finish my comment.

Because we'd have to mass rename a lot of directories from "unit" to "Unit", I suspect, whereas replacing Unit -> unit was three patches. We could go the way you propose, though.

I was going to say that we could have LibUp mass-rename the directories all around the place.

OK. I suppose we should do that for the "integration" directory that exists in core and some extensions, and rename that to "Integration".

I hadn’t thought of Integration, but that seems fair enough; FWIW, several codesearch-indexed extensions already have an Integration directory (Lingo, DumpsOnDemand, Gravatar, and ProfessionalWiki’s GND and ExternalContent).

Jdforrester-WMF renamed this task from phpunit.xml.dist: Remove support for uppercase Unit directory discovery to phpunit.xml.dist: Remove support for both lowercase unit and uppercase Unit directory, as it's unfriendly for case-insensitive OSes.Nov 22 2021, 3:29 PM
Jdforrester-WMF subscribed.

Re-titled to reflect that we're not specific pro-unit and anti-Unit.

Change 740327 abandoned by Kosta Harlan:

[mediawiki/extensions/DumpsOnDemand@master] phpunit: Rename Unit directory to unit

Reason:

Per discussion in T278707#7520022, we want to keep this as is

https://gerrit.wikimedia.org/r/740327

Change 740328 abandoned by Kosta Harlan:

[mediawiki/extensions/Lingo@master] phpunit: Rename Unit directory to unit

Reason:

Per discussion in T278707#7520022, we want to keep this as is

https://gerrit.wikimedia.org/r/740328