-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Update WAVE test runner #46286
base: master
Are you sure you want to change the base?
Update WAVE test runner #46286
Conversation
d792e57
to
6b08ce8
Compare
@FritzHeiden is there someone familiar with this setup who you'd like review from? If not, then as long as the CI passes and the diff looks reasonable, someone like me could rubberstamp and merge it. Right now the CI isn't passing, have you checked that out? |
@foolip as the WAVE HATF chair, I'll review this PR for the implementation. Agree we need tests to pass as well for this to be able to be merged. |
Unfortunately, I don't know how to resolve these errors:
This is not part of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FritzHeiden I left some comments inline. I believe the last few may resolve most/all of the failing tests
} | ||
|
||
const jsRelativePath = path.relative(testsPath, currentPath); | ||
// console.log(jsRelativePath.replace('.js', '')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably best to remove commented-out debug code to clean up the files
const jsSrc = await readFile(currentPath); | ||
const meta = parseFrontmatter(jsSrc); | ||
const includes = (meta && meta.includes) || []; | ||
//console.log(includes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented-out debug code
<title>{{ TEST_TITLE }}</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<!-- <script charset="UTF-8" src="/ecmascript/harness/jquery-1.4.2.min.js"></script> --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed commented-out code (I'm not sure this path to jQuery is valid if it was uncommented?)
<script charset="UTF-8" src="/ecmascript/harness/cth.js"></script> | ||
<script charset="UTF-8" src="/ecmascript/harness/propertyHelper.js"></script> | ||
<script charset="UTF-8" src="/ecmascript/harness/PromiseHelper.js"></script> | ||
<!-- <script charset="UTF-8" src="/ecmascript/harness/jquery-1.4.2.min.js"></script> --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed commented-out code
// /ecmascript/tests/built-ins/RegExp/prototype/Symbol.match/builtin-coerce-global.html "Aw Snap" | ||
// /ecmascript/tests/built-ins/RegExp/prototype/Symbol.match/coerce-global.html "Aw Snap" | ||
// /ecmascript/tests/built-ins/RegExp/prototype/Symbol.replace/coerce-global.html "Aw Snap" | ||
// /ecmascript/tests/language/statements/for-of/iterator-next-reference.html "Website unresponsive" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unclear if we need these comments to stay in the code or not
tools/wave/requirements.txt
Outdated
ua-parser==0.8.0 | ||
python-dateutil==2.8.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was this change intentional? the previous versions were set by dependabot, so I assume this will just cause dependabot to issue a follow-up PR
tools/wave/tox.ini
Outdated
[tox] | ||
envlist = py38,py39,py310,py311,py312 | ||
envlist = py36,py37,py38,py39 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prior commits to this file from the past couple years indicate this envlist
change should be reverted
tools/wave/tox.ini
Outdated
-r{toxinidir}/../wptrunner/requirements.txt | ||
-r{toxinidir}/../wptrunner/requirements_chromium.txt | ||
-r{toxinidir}/../wptrunner/requirements_chrome.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should be reverted, the filename is requirements_chromium.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few other unit test failures besides no-untyped-def
, but this should at least address the majority of them
tools/wave/configuration_loader.py
Outdated
@@ -1,7 +1,8 @@ | |||
# mypy: allow-untyped-defs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FritzHeiden the majority of the unit test failures are because this line was removed from many of the files. Please restore it to all the files it was removed from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @JohnRiv we will update the PR ASAP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FritzHeiden if you address the inline comments here, I believe that should take care of all the failures we see in tools/ unittests
@@ -20,12 +19,11 @@ | |||
from ..data.session import COMPLETED | |||
|
|||
WAVE_SRC_DIR = "./tools/wave" | |||
RESULTS_FILE_REGEX = r"^\w\w\d\d\d?\.json$" | |||
RESULTS_FILE_REGEX = "^\w\w\d\d\d?\.json$" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed there is now this warning in the unit tests regarding this line:
SyntaxWarning: invalid escape sequence '\w'
so the removal of the r
should probably be reverted
raise InvalidDataException(f"Unknown type '{test_type}'") | ||
raise InvalidDataException("Unknown type '{}'".format(test_type)) | ||
|
||
if expiration_date is not None and type(expiration_date) != int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this has a lint error in the unit tests:
E721 do not compare types, for exact checks use
is
/is not
, for instance checks useisinstance()
so try this as a suggestion:
if expiration_date is not None and type(expiration_date) != int: | |
if expiration_date is not None and not isinstance(expiration_date, int): |
raise InvalidDataException("Unknown type '{}'".format(test_type)) | ||
|
||
if expiration_date is not None and type(expiration_date) != int: | ||
expiration_date = iso_to_millis(expiration_date) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this has a lint error in the unit tests:
F821 undefined name 'iso_to_millis'
So you'll need to import that function from tools/wave/utils/deserializer.py in addition to the deserialize_session
function you already import from there
|
||
if expiration_date is not None and type(expiration_date) != int: | ||
expiration_date = iso_to_millis(expiration_date) | ||
if type(expiration_date) != int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another E721
lint error, so likely need to change this to:
if type(expiration_date) != int: | |
if not isinstance(expiration_date, int): |
tools/wave/testing/test_loader.py
Outdated
regex_patterns = [] | ||
|
||
if test_list is not None and len(test_list) > 0: | ||
is_valid = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line, as it does nothing per the lint error
F841 local variable 'is_valid' is assigned to but never used
tools/wave/wave-cli.py
Outdated
|
||
|
||
def download_file(url, file_path): | ||
response = urllib2.urlopen(url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming you make the urllib
change on line 5 above, this will have to become
response = urllib2.urlopen(url) | |
response = urllib.request.urlopen(url) |
see urllib.request.urlopen
docs
os.remove(os.path.join( | ||
result_directory, browser["zip"])) | ||
|
||
main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error: Call to untyped function "main" in typed context [no-untyped-call]
I'm not sure why that error is happening since you have the # mypy: allow-untyped-defs
comment at the top, but this file is relatively small so you can probably add typing to the main function definition above on line 33:
def main() -> None:
and then be sure to type the functions that main calls as well (and so on)
except ImportError: | ||
from urlparse import parse_qsl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need this? It's throwing 2 errors:
error: Cannot find implementation or library stub for module named "urlparse" [import-not-found]
error: Name "parse_qsl" already defined (possibly by an import) [no-redef]
and other parts of the project use urllib.parse
and parse_qsl
is in python 3.8, so I assume that's fine?
try: | ||
from urllib.parse import urlunsplit | ||
except ImportError: | ||
from urlparse import urlunsplit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also throwing 2 errors:
error: Cannot find implementation or library stub for module named "urlparse" [import-not-found]
error: Name "urlunsplit" already defined (possibly by an import) [no-redef]
likewise, do you need the except
?
tools/wave/tests/test_wave.py
Outdated
try: | ||
from urllib.request import urlopen | ||
from urllib.error import URLError | ||
except ImportError: | ||
from urllib2 import urlopen, URLError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one more time, errors related to the try/except on imports:
Cannot find implementation or library stub for module named "urllib2" [import-not-found]
Name "urlopen" already defined (possibly by an import) [no-redef]
Name "URLError" already defined (possibly by an import) [no-redef]
This PR updates the wave test runner used in WMAS and DPCTF projects by CTA. It mainly includes bug fixes as well as change to support python 3.8