Bug 161578

Summary: W3C test importer should generate the list of resource files
Product: WebKit Reporter: youenn fablet <youennf>
Component: WebCore Misc.Assignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, glenn, mcatanzaro, rniwa
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=161604
Attachments:
Description Flags
Patch
none
Patch
none
Patch for landing none

Description youenn fablet 2016-09-04 11:38:50 PDT
Following on bug 161307, W3C test importer should generate the list of resource files.
Comment 1 youenn fablet 2016-09-04 11:45:35 PDT
Created attachment 287918 [details]
Patch
Comment 2 Ryosuke Niwa 2016-09-04 18:50:02 PDT
Comment on attachment 287918 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=287918&action=review

> Tools/Scripts/webkitpy/w3c/test_importer.py:473
> +                if not self._already_identified_as_resource_file(resource_file_path):
> +                    files.append(resource_file_path)
> +                    should_update_json_file = True

This would not catch the case when a resource file becomes a test.

> Tools/Scripts/webkitpy/w3c/test_importer.py:484
> +        for directory in self._test_resource_files["directories"]:
> +            if path.find(directory) != -1:
> +                return True
> +        return False

This should just be:
return any([path.find(directory) != -1 for directory in self._test_resource_files["directories"]])
Comment 3 youenn fablet 2016-09-05 00:11:10 PDT
Created attachment 287936 [details]
Patch
Comment 4 youenn fablet 2016-09-05 00:14:22 PDT
Thanks for the review.

> View in context:
> https://bugs.webkit.org/attachment.cgi?id=287918&action=review
> 
> > Tools/Scripts/webkitpy/w3c/test_importer.py:473
> > +                if not self._already_identified_as_resource_file(resource_file_path):
> > +                    files.append(resource_file_path)
> > +                    should_update_json_file = True
> 
> This would not catch the case when a resource file becomes a test.

I added a FIXME for it.
In the meantime, the plan is that on each full resync, the list of resource files will be fully regenerated.

I also added generation of a warning for tests imported in "resources" folder.


> > Tools/Scripts/webkitpy/w3c/test_importer.py:484
> > +        for directory in self._test_resource_files["directories"]:
> > +            if path.find(directory) != -1:
> > +                return True
> > +        return False
> 
> This should just be:
> return any([path.find(directory) != -1 for directory in
> self._test_resource_files["directories"]])

Done.
Comment 5 Ryosuke Niwa 2016-09-05 00:24:39 PDT
Comment on attachment 287936 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=287936&action=review

> Tools/Scripts/webkitpy/w3c/test_importer.py:475
> +                resource_file_path = full_path.replace(self.source_directory, '')[1:]

Presumably you're stripping the trailing / with [1:] but this is not robust nor is semantically descriptive.
Use .rstrip('/') instead. An even better approach is to use self.filesystem.relpath.
Comment 6 youenn fablet 2016-09-05 03:00:55 PDT
Created attachment 287944 [details]
Patch for landing
Comment 7 youenn fablet 2016-09-05 03:01:25 PDT
(In reply to comment #5)
> Comment on attachment 287936 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=287936&action=review
> 
> > Tools/Scripts/webkitpy/w3c/test_importer.py:475
> > +                resource_file_path = full_path.replace(self.source_directory, '')[1:]
> 
> Presumably you're stripping the trailing / with [1:] but this is not robust
> nor is semantically descriptive.
> Use .rstrip('/') instead. An even better approach is to use
> self.filesystem.relpath.

Done, thanks.
Comment 8 WebKit Commit Bot 2016-09-05 03:32:04 PDT
Comment on attachment 287944 [details]
Patch for landing

Clearing flags on attachment: 287944

Committed r205447: <http://trac.webkit.org/changeset/205447>
Comment 9 WebKit Commit Bot 2016-09-05 03:32:08 PDT
All reviewed patches have been landed.  Closing bug.
Comment 10 Michael Catanzaro 2016-09-05 09:29:55 PDT
It broke a python test:

[1432/1462] webkitpy.w3c.test_importer_unittest.TestImporterTest.test_clean_directory_option erred:
  Traceback (most recent call last):
    File "/home/slave/webkitgtk/gtk-linux-64-release-tests/build/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py", line 204, in test_clean_directory_option
      fs = self.import_downloaded_tests(['--no-fetch', '--import-all', '-d', 'w3c', '--clean-dest-dir'], FAKE_FILES)
    File "/home/slave/webkitgtk/gtk-linux-64-release-tests/build/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py", line 132, in import_downloaded_tests
      importer = TestImporter(host, None, options)
    File "/home/slave/webkitgtk/gtk-linux-64-release-tests/build/Tools/Scripts/webkitpy/w3c/test_importer.py", line 184, in __init__
      self._test_resource_files["files"] = []
  TypeError: 'NoneType' object does not support item assignment
Comment 11 youenn fablet 2016-09-05 09:32:03 PDT
This should be covered by bug 161604, let me know if you still see broken tests.