on bionic help sign in
unity8/.bazaar/plugins/makecheck_unity_phablet.py
51 lines 2.0 kB history raw
1#!/usr/bin/python
2# Copyright 2013, 2014 Canonical Ltd.
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU Lesser General Public License as published by
6# the Free Software Foundation; version 3.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU Lesser General Public License for more details.
13# You should have received a copy of the GNU Lesser General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
16import os
17import subprocess
18from bzrlib import branch
19from bzrlib.urlutils import local_path_from_url
22def execute_makecheck(
23 local_branch, master_branch, old_revision_number, old_revision_id,
24 future_revision_number, future_revision_id, tree_delta, future_tree):
25 if not master_branch.basis_tree().has_filename("qml/Shell.qml"):
26 return
28 os.chdir(local_path_from_url(master_branch.base))
30 print "Executing 'make -C builddir test'.."
31 os.environ['CTEST_OUTPUT_ON_FAILURE'] = "1"
32 if (subprocess.call("make -C builddir test", shell=True) != 0):
34 print("\n\n*** Warning ***\n\n"
35 "Basic tests failed. This commit will not pass continuous "
36 "integration.")
38 branch = local_branch or master_branch
39 revision = branch.repository.get_revision(future_revision_id)
40 msg_file = open('message.txt', 'w')
41 msg_file.write(revision.message)
42 msg_file.close()
44 print("\n\nSaved commit message to $SRC_DIR/message.txt.")
45 print("You can uncommit this revision, fix the tests and reuse your "
46 "message running:\n\nbzr commit -F message.txt\n\n")
47 elif os.path.isfile("message.txt"):
48 os.remove("message.txt")
50branch.Branch.hooks.install_named_hook(
51 'pre_commit', execute_makecheck, 'make check pre-commit')