Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F29676426
raw.txt
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
Ladsgroup
Jul 2 2019, 4:50 PM
2019-07-02 16:50:01 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
raw.txt
View Options
# Run it on root of your mediawiki (e.g /var/lib/mediawiki)
# like python ~/workspace/foo.py extensions/Wikibase/lib/tests/phpunit
import os
import sys
import re
import subprocess
from subprocess import PIPE
def find_test_files(path):
files = []
for r, d, f in os.walk(path):
for file_name in f:
if file_name.endswith('Test.php'):
files.append(os.path.join(r, file_name))
return files
def check_file(path):
with open(path, 'r') as f:
content = f.read()
old_content = content
search_result = re.findall(r'(\nclass (\S+) extends \\?MediaWikiTestCase)', content)
if not search_result:
return
with open(path, 'w') as f:
f.write(
content.replace(
search_result[0][0],
'\nclass {} extends \MediaWikiUnitTestCase'.format(
search_result[0][1])).replace('\nuse MediaWikiTestCase;', '')
.replace('\n\n\n', '\n\n').replace('\n\n\n', '\n\n'))
res = subprocess.run(["composer", "phpunit:unit", path], stdout=PIPE, stderr=PIPE)
if res.returncode != 0:
print('It did not work :((')
with open(path, 'w') as f:
f.write(old_content)
else:
print('IT WORKED!!!')
for f in find_test_files(sys.argv[1]):
check_file(f)
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
7693316
Default Alt Text
raw.txt (1 KB)
Attached To
Mode
P8702 Python script to fix unit tests
Attached
Detach File
Event Timeline
Log In to Comment