validate:launcher: Let the responsibility to update asset to the testsuite

Summary:
It makes it easier to make sure that the assets needed for a specific
testsuite are available when needed

Reviewers: Mathieu_Du

Differential Revision: http://phabricator.freedesktop.org/D92
This commit is contained in:
Thibault Saunier 2015-04-10 18:11:09 +02:00
parent 101ed96b5a
commit 5a6d6b9475

View file

@ -17,7 +17,6 @@
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA. # Boston, MA 02110-1301, USA.
import os import os
import re
import sys import sys
import utils import utils
import urlparse import urlparse
@ -138,37 +137,9 @@ QA_ASSETS = "gst-integration-testsuites"
MEDIAS_FOLDER = "medias" MEDIAS_FOLDER = "medias"
DEFAULT_GST_QA_ASSETS_REPO = "git://anongit.freedesktop.org/gstreamer/gst-integration-testsuites" DEFAULT_GST_QA_ASSETS_REPO = "git://anongit.freedesktop.org/gstreamer/gst-integration-testsuites"
OLD_DEFAULT_GST_QA_ASSETS_REPO = "https://gitlab.com/thiblahute/gst-integration-testsuites.git" OLD_DEFAULT_GST_QA_ASSETS_REPO = "https://gitlab.com/thiblahute/gst-integration-testsuites.git"
DEFAULT_SYNC_ASSET_COMMAND = "git fetch origin && git checkout origin/master && git annex get medias/defaults/"
DEFAULT_SYNC_ALL_ASSET_COMMAND = "git fetch origin && git checkout origin/master && git annex get ."
DEFAULT_TESTSUITES_DIR = os.path.join(DEFAULT_MAIN_DIR, QA_ASSETS, "testsuites") DEFAULT_TESTSUITES_DIR = os.path.join(DEFAULT_MAIN_DIR, QA_ASSETS, "testsuites")
def update_assets(options):
try:
if options.remote_assets_url == DEFAULT_GST_QA_ASSETS_REPO:
if re.findall("origin.*%s" % OLD_DEFAULT_GST_QA_ASSETS_REPO,
subprocess.check_output("cd %s && git remote -v" % options.clone_dir, shell=True)):
launch_command("cd %s && git remote set-url origin %s" % (options.clone_dir,
DEFAULT_GST_QA_ASSETS_REPO))
launch_command("cd %s && %s" % (options.clone_dir,
options.update_assets_command),
fails=True)
except subprocess.CalledProcessError as e:
if "annex" in options.update_assets_command:
m = "\n\nMAKE SURE YOU HAVE git-annex INSTALLED!"
else:
m = ""
printc("Could not update assets repository\n\nError: %s%s" % (e, m),
Colors.FAIL, True)
return False
return True
def download_assets(options): def download_assets(options):
try: try:
launch_command("%s %s %s" % (options.get_assets_command, launch_command("%s %s %s" % (options.get_assets_command,
@ -235,7 +206,6 @@ class LauncherConfig(Loggable):
self.http_bandwith = 1024 * 1024 self.http_bandwith = 1024 * 1024
self.http_server_dir = None self.http_server_dir = None
self.httponly = False self.httponly = False
self.update_assets_command = DEFAULT_SYNC_ASSET_COMMAND
self.get_assets_command = "git clone" self.get_assets_command = "git clone"
self.remote_assets_url = DEFAULT_GST_QA_ASSETS_REPO self.remote_assets_url = DEFAULT_GST_QA_ASSETS_REPO
self.sync = False self.sync = False
@ -293,8 +263,6 @@ class LauncherConfig(Loggable):
if self.sync_all is True: if self.sync_all is True:
self.sync = True self.sync = True
if self.update_assets_command == DEFAULT_SYNC_ASSET_COMMAND:
self.update_assets_command = DEFAULT_SYNC_ALL_ASSET_COMMAND
if not self.sync and not os.path.exists(self.clone_dir) and \ if not self.sync and not os.path.exists(self.clone_dir) and \
self.clone_dir == os.path.join(self.clone_dir, MEDIAS_FOLDER): self.clone_dir == os.path.join(self.clone_dir, MEDIAS_FOLDER):
@ -465,9 +433,6 @@ Note that all testsuite should be inside python modules, so the directory should
help="Start the http server and quit") help="Start the http server and quit")
assets_group = parser.add_argument_group("Handle remote assets") assets_group = parser.add_argument_group("Handle remote assets")
assets_group.add_argument(
"-u", "--update-assets-command", dest="update_assets_command",
help="Command to update assets")
assets_group.add_argument( assets_group.add_argument(
"--get-assets-command", dest="get_assets_command", "--get-assets-command", dest="get_assets_command",
help="Command to get assets") help="Command to get assets")
@ -497,16 +462,9 @@ Note that all testsuite should be inside python modules, so the directory should
if not options.cleanup(): if not options.cleanup():
exit(1) exit(1)
if options.remote_assets_url and options.sync: if options.remote_assets_url and options.sync and not os.path.exists(options.clone_dir):
if os.path.exists(options.clone_dir): if not download_assets(options):
if not update_assets(options): exit(1)
exit(1)
else:
if not download_assets(options):
exit(1)
if not update_assets(options):
exit(1)
tests_launcher.set_settings(options, []) tests_launcher.set_settings(options, [])