示例#1
0
    def test_sets_environment_variables(self):
        directory = tempfile.mkdtemp()

        bp = BuildRequest()
        bp.workspace = "test"
        bp.command = """[ "$butts_key" = "lol" ]"""
        bp.priority = 10

        env_var = bp.environment.add()
        env_var.key = "butts_key"
        env_var.value = "lol"

        request = bp.SerializeToString()
        length = len(request)
        msg_type = juici_server.MSG_BUILD_REQUEST
        request = struct.pack(">II", msg_type, length) + request
        sock = self.socket()
        sock.send(request)
        status = sock.recv(1024)

        msg_type, size = struct.unpack(">II", status[0:8])

        self.assertEqual(msg_type, juici_server.MSG_BUILD_COMPLETE)

        resp = BuildComplete()
        resp.ParseFromString(status[8:])

        self.assertEqual(resp.status, 0)
示例#2
0
    def test_runs_in_worktree(self):
        bp = BuildRequest()
        bp.workspace = "test_butts_lol"
        bp.command = "echo butts > file"
        bp.priority = 10

        request = bp.SerializeToString()
        length = len(request)
        msg_type = juici_server.MSG_BUILD_REQUEST
        request = struct.pack(">II", msg_type, length) + request
        sock = self.socket()
        sock.send(request)
        status = sock.recv(1024)

        with open("worktree/test_butts_lol/file", "r") as fh:
            self.assertEqual(fh.read(), "butts\n")
示例#3
0
    def test_can_run_builds(self):
        directory = tempfile.mkdtemp()

        bp = BuildRequest()
        bp.workspace = "test"
        bp.command = "echo butts > %s/file" % directory
        bp.priority = 10

        request = bp.SerializeToString()
        length = len(request)
        msg_type = juici_server.MSG_BUILD_REQUEST
        request = struct.pack(">II", msg_type, length) + request
        sock = self.socket()
        sock.send(request)
        status = sock.recv(1024)

        with open("%s/file" % directory, "r") as fh:
            self.assertEqual(fh.read(), "butts\n")
示例#4
0
    def test_gets_exit_status(self):
        directory = tempfile.mkdtemp()

        bp = BuildRequest()
        bp.workspace = "test"
        bp.command = "exit 2"
        bp.priority = 10

        request = bp.SerializeToString()
        length = len(request)
        msg_type = juici_server.MSG_BUILD_REQUEST
        request = struct.pack(">II", msg_type, length) + request
        sock = self.socket()
        sock.send(request)
        status = sock.recv(1024)

        msg_type, size = struct.unpack(">II", status[0:8])

        self.assertEqual(msg_type, juici_server.MSG_BUILD_COMPLETE)

        resp = BuildComplete()
        resp.ParseFromString(status[8:])

        self.assertEqual(resp.status, 2)
示例#5
0
import sys
import struct
import argparse
from proto.build_request_pb2 import BuildRequest

parser = argparse.ArgumentParser()
parser.add_argument("--workspace", help="workspace to build in")
parser.add_argument("--command", help="command to run")
parser.add_argument("--priority", type=int, help="priority for the build", default=1)
args = parser.parse_args()


b = BuildRequest()

b.workspace = args.workspace
b.command = args.command
b.priority = args.priority

request = b.SerializeToString()
length = len(request)
sys.stdout.write(struct.pack(">I", length))
sys.stdout.write(request)