diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2018-09-27 18:22:31 +0200 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2018-09-27 18:23:37 +0200 |
commit | 5a48669e90176a2043bfdee03931192e9ccb1d27 (patch) | |
tree | e1f9493dcceeb95ffc44ce2d8bc63138107f9c1e /etc/taskcluster/mock.py | |
parent | 515afac456d162bab6bf8edbf9745920b2420e4a (diff) | |
download | servo-5a48669e90176a2043bfdee03931192e9ccb1d27.tar.gz servo-5a48669e90176a2043bfdee03931192e9ccb1d27.zip |
Move etc/ci/taskcluster one level up
Diffstat (limited to 'etc/taskcluster/mock.py')
-rwxr-xr-x | etc/taskcluster/mock.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/etc/taskcluster/mock.py b/etc/taskcluster/mock.py new file mode 100755 index 00000000000..085c82c2917 --- /dev/null +++ b/etc/taskcluster/mock.py @@ -0,0 +1,45 @@ +#!/usr/bin/python3 + +# Copyright 2018 The Servo Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution. +# +# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +""" +Run the decision task with fake Taskcluster APIs, to catch Python errors before pushing. +""" + +import os +import sys +from unittest.mock import MagicMock + + +class TaskclusterRestFailure(Exception): + status_code = 404 + + +class Index: + __init__ = insertTask = lambda *_, **__: None + + def findTask(self, _): + raise TaskclusterRestFailure + + +Queue = stringDate = fromNow = slugId = MagicMock() +sys.modules["taskcluster"] = sys.modules[__name__] +sys.dont_write_bytecode = True +code = open(os.path.join(os.path.dirname(__file__), "decision-task.py"), "rb").read() +for k in "TASK_ID TASK_OWNER TASK_SOURCE GIT_URL GIT_REF GIT_SHA".split(): + os.environ[k] = k + +print("Push:") +os.environ["TASK_FOR"] = "github-push" +exec(code) + +print("Daily:") +os.environ["TASK_FOR"] = "daily" +exec(code) |