Skip to content

Commit

Permalink
Allow wpt.py to be called from outside the WPT directory
Browse files Browse the repository at this point in the history
Note that this is about wpt.py, which is a file specifically used for
Windows, and not 'wpt' which is the main entry-point file.

Previously wpt.py would just try to exec 'wpt' in the current working
directory, which may not be the directory that contains 'wpt.py' (and
thus, no 'wpt'!). To fix that, we os.chdir into the same directory as
the __file__.

Fixes web-platform-tests#23095
  • Loading branch information
stephenmcgruer authored and jgraham committed Apr 20, 2020
1 parent 9b5bded commit 07ca316
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion wpt.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# This file exists to allow `python wpt <command>` to work on Windows:
# https://github.com/web-platform-tests/wpt/pull/6907
# https://github.com/web-platform-tests/wpt/pull/6907 and
# https://github.com/web-platform-tests/wpt/issues/23095
import os
abspath = os.path.abspath(__file__)
os.chdir(os.path.dirname(abspath))
exec(compile(open("wpt", "r").read(), "wpt", 'exec'))

0 comments on commit 07ca316

Please sign in to comment.