Skip to content

Commit

Permalink
Add lint and manifest commands to |wpt|
Browse files Browse the repository at this point in the history
  • Loading branch information
jgraham committed Jun 14, 2017
1 parent be3784c commit f55f875
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
3 changes: 3 additions & 0 deletions tools/lint/commands.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"lint":
{"path": "lint.py", "script": "main", "parser": "create_parser", "help": "Run the lint",
"virtualenv": false}}
6 changes: 3 additions & 3 deletions tools/lint/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ def output_error_count(error_count):
else:
logger.info("There were %d errors (%s)" % (count, by_type))

def parse_args():
def create_parser():
parser = argparse.ArgumentParser()
parser.add_argument("paths", nargs="*",
help="List of paths to lint")
Expand All @@ -681,7 +681,7 @@ def parse_args():
help="Run CSS testsuite specific lints")
parser.add_argument("--repo-root", help="The WPT directory. Use this"
"option if the lint script exists outside the repository")
return parser.parse_args()
return parser


def main(**kwargs):
Expand Down Expand Up @@ -765,7 +765,7 @@ def process_errors(errors):
file_lints = [check_regexp_line, check_parsed, check_python_ast, check_script_metadata]

if __name__ == "__main__":
args = parse_args()
args = create_parser.parse_args()
error_count = main(**vars(args))
if error_count > 0:
sys.exit(1)
3 changes: 3 additions & 0 deletions tools/manifest/commands.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"manifest":
{"path": "update.py", "script": "run", "parser": "create_parser", "help": "Update the MANIFEST.json file",
"virtualenv": false}}
27 changes: 10 additions & 17 deletions tools/manifest/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

here = os.path.dirname(__file__)

wpt_root = os.path.abspath(os.path.join(here, os.pardir, os.pardir))

def update(tests_root, manifest, working_copy=False):
tree = None
Expand Down Expand Up @@ -57,7 +58,7 @@ def create_parser():
parser.add_argument(
"-p", "--path", type=abs_path, help="Path to manifest file.")
parser.add_argument(
"--tests-root", type=abs_path, help="Path to root of tests.")
"--tests-root", type=abs_path, default=wpt_root, help="Path to root of tests.")
parser.add_argument(
"-r", "--rebuild", action="store_true", default=False,
help="Force a full rebuild of the manifest.")
Expand All @@ -81,24 +82,16 @@ def find_top_repo():
return rv


def main(default_tests_root=None):
opts = create_parser().parse_args()
def run(**kwargs):
if kwargs["path"] is None:
kwargs["path"] = os.path.join(kwargs["tests_root"], "MANIFEST.json")

if opts.tests_root is None:
tests_root = None
if default_tests_root is not None:
tests_root = default_tests_root
else:
tests_root = find_top_repo()
update_from_cli(**kwargs)

if tests_root is None:
print >> sys.stderr, """No git repo found; could not determine test root.
Run again with --test-root"""
sys.exit(1)

opts.tests_root = tests_root
def main():
opts = create_parser().parse_args()

if opts.path is None:
opts.path = os.path.join(opts.tests_root, "MANIFEST.json")
run(**vars(opts))

update_from_cli(**vars(opts))
print run
2 changes: 2 additions & 0 deletions tools/wpt/paths
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
tools/wpt/
tools/browserutils/
tools/lint/
tools/manifest/
2 changes: 1 addition & 1 deletion tools/wptrunner/wptrunner/testloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def update_manifest(self, manifest_path, tests_path, url_base="/",
except manifest.ManifestVersionMismatch:
manifest_file = manifest.Manifest(url_base)

manifest_update.update(tests_path, manifest_file, True)
manifest_update.update(tests_path, manifest_file, True)

manifest.write(manifest_file, manifest_path)

Expand Down

0 comments on commit f55f875

Please sign in to comment.