Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Commit

Permalink
Make it possible to update against an existing manifest from the Test…
Browse files Browse the repository at this point in the history
…Loader rather than always creating a new one.
  • Loading branch information
jgraham committed Dec 8, 2014
1 parent bec36fe commit 20023be
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions wptrunner/testloader.py
@@ -1,3 +1,4 @@
import json
import os
import urlparse
from abc import ABCMeta, abstractmethod
Expand Down Expand Up @@ -233,16 +234,33 @@ def load(self):
return rv

def create_manifest(self, manifest_path, tests_path, url_base="/"):
self.logger.info("Creating test manifest %s" % manifest_path)
manifest_file = manifest.Manifest(None, url_base)
self.update_manifest(manifest_path, tests_path, url_base, recreate=True)

def update_manifest(self, manifest_path, tests_path, url_base="/",
recreate=False):
self.logger.info("Updating test manifest %s" % manifest_path)

json_data = None
if not recreate:
try:
json_data = json.load(open(manifest_path))
except IOError:
#If the existing file doesn't exist just create one from scratch
pass

if not json_data:
manifest_file = manifest.Manifest(None, url_base)
else:
manifest_file = manifest.Manifest.from_json(json_data)

manifest.update(tests_path, url_base, manifest_file)
manifest.write(manifest_file, manifest_path)

def load_manifest(self, tests_path, metadata_path, url_base="/"):
manifest_path = os.path.join(metadata_path, "MANIFEST.json")
if (not os.path.exists(manifest_path) or
self.force_manifest_update):
self.create_manifest(manifest_path, tests_path, url_base)
self.update_manifest(manifest_path, tests_path, url_base)
manifest_file = manifest.load(manifest_path)
if manifest_file.url_base != url_base:
self.logger.info("Updating url_base in manifest from %s to %s" % (manifest_file.url_base,
Expand Down

0 comments on commit 20023be

Please sign in to comment.