on 7.84+14.04.20140306-0ubuntu1 help sign in
unity8/.bazaar/plugins/makecheck_unity_phablet.py
43 lines 1.9 kB history raw
1#!/usr/bin/python
2# Copyright 2013 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, subprocess
17from bzrlib import branch, errors
18from bzrlib.urlutils import dirname, local_path_from_url
20def execute_makecheck(local_branch, master_branch, old_revision_number, old_revision_id, future_revision_number, future_revision_id, tree_delta, future_tree):
21 if not master_branch.basis_tree().has_filename("Shell.qml"):
22 return
24 os.chdir(local_path_from_url(master_branch.base))
26 print "Executing 'make -C builddir test'.."
27 os.environ['CTEST_OUTPUT_ON_FAILURE'] = "1"
28 if (subprocess.call("make -C builddir test", shell=True) != 0):
30 print("\n\n*** Warning ***\n\nBasic tests failed. This commit will not pass continuous integration.")
32 branch = local_branch or master_branch
33 revision = branch.repository.get_revision(future_revision_id)
34 msg_file = open('message.txt', 'w')
35 msg_file.write(revision.message)
36 msg_file.close()
38 print("\n\nSaved commit message to $SRC_DIR/message.txt.")
39 print("You can uncommit this revision, fix the tests and reuse your message running:\n\nbzr commit -F message.txt\n\n")
40 elif os.path.isfile("message.txt"):
41 os.remove("message.txt")
43branch.Branch.hooks.install_named_hook('pre_commit', execute_makecheck, 'make check pre-commit')