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

Update WAVE test runner #46286

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

FritzHeiden
Copy link
Contributor

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

@FritzHeiden FritzHeiden requested a review from a team as a code owner May 15, 2024 14:03
@FritzHeiden FritzHeiden marked this pull request as draft May 15, 2024 14:05
@FritzHeiden FritzHeiden force-pushed the master branch 4 times, most recently from d792e57 to 6b08ce8 Compare May 16, 2024 14:47
@FritzHeiden FritzHeiden marked this pull request as ready for review May 16, 2024 14:48
@foolip
Copy link
Member

foolip commented May 21, 2024

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

@JohnRiv
Copy link

JohnRiv commented Jun 12, 2024

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

@FritzHeiden
Copy link
Contributor Author

Unfortunately, I don't know how to resolve these errors:

[Errno 2] No such file or directory: '/home/test/web-platform-tests/tools/wave/../wptrunner/requirements_chrome.txt'

This is not part of the tools/wave directory, so I don't know what this is for and how to resolve it. Can someone please assist me with this?

Copy link

@JohnRiv JohnRiv left a 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', ''))
Copy link

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);
Copy link

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> -->
Copy link

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> -->
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed commented-out code

Comment on lines 106 to 109
// /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"
Copy link

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

Comment on lines 1 to 2
ua-parser==0.8.0
python-dateutil==2.8.1
Copy link

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

Comment on lines 1 to 2
[tox]
envlist = py38,py39,py310,py311,py312
envlist = py36,py37,py38,py39
Copy link

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

-r{toxinidir}/../wptrunner/requirements.txt
-r{toxinidir}/../wptrunner/requirements_chromium.txt
-r{toxinidir}/../wptrunner/requirements_chrome.txt
Copy link

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

Copy link

@JohnRiv JohnRiv left a 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

@@ -1,7 +1,8 @@
# mypy: allow-untyped-defs
Copy link

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.

Copy link
Contributor

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

Copy link

@JohnRiv JohnRiv left a 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$"
Copy link

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:
Copy link

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 use isinstance()

so try this as a suggestion:

Suggested change
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)
Copy link

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:
Copy link

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:

Suggested change
if type(expiration_date) != int:
if not isinstance(expiration_date, int):

regex_patterns = []

if test_list is not None and len(test_list) > 0:
is_valid = False
Copy link

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



def download_file(url, file_path):
response = urllib2.urlopen(url)
Copy link

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

Suggested change
response = urllib2.urlopen(url)
response = urllib.request.urlopen(url)

see urllib.request.urlopen docs

os.remove(os.path.join(
result_directory, browser["zip"]))

main()
Copy link

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)

Comment on lines 10 to 11
except ImportError:
from urlparse import parse_qsl
Copy link

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?

Comment on lines 5 to 8
try:
from urllib.parse import urlunsplit
except ImportError:
from urlparse import urlunsplit
Copy link

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?

Comment on lines 9 to 13
try:
from urllib.request import urlopen
from urllib.error import URLError
except ImportError:
from urllib2 import urlopen, URLError
Copy link

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]

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

Successfully merging this pull request may close these issues.

6 participants