def test_add_repo(self):
        r1 = repo.Repo()
        r1.repoid = "a-repo-id"

        r2 = repo.Repo()
        r2.repoid = "another-repo-id"

        rd = repo.RepoDict()
        rd.add_repo(r1)

        repos = {r1.repoid: r1}
        rd.set_repos(repos)

        repos[r2.repoid] = r2
        rd.set_repos(repos)

        r1_copy = repos["a-repo-id"]
        self.assertEqual(r1, r1_copy)
        self.assertEqual(r1.repoid, "a-repo-id")
        self.assertEqual(r1_copy.repoid, "a-repo-id")

        r1.repoid = "foo"
        self.assertEqual(r1.repoid, "foo")
        self.assertEqual(r1_copy.repoid, "foo")

        r1_copy.repoid = "bar"
        self.assertEqual(r1.repoid, "bar")
        self.assertEqual(r1_copy.repoid, "bar")
Example #2
0
def main():
    global DEBUG
    import optparse
    parser = optparse.OptionParser(USAGE)
    parser.add_option('--debug', '-d', action='store_true')
    parser.add_option('--repo', '-r', default=None)
    options, args = parser.parse_args()
    DEBUG = options.debug
    filename = options.repo
    if not filename:
        raise SystemExit('filename not specified')

    r = repo.Repo(options.repo)
    r.load()
    tree = Tree(r)
    top = Tk()
    top.title(APP_TITLE)
    top.wm_geometry('+0+0')
    top.withdraw()
    default_font = tkinter.font.nametofont("TkDefaultFont")
    default_font.configure(size=11)

    b = Browser(top, tree)
    #b.lb.focus()
    top.deiconify()
    mainloop()
Example #3
0
 def __init__(self):
     resource.Resource.__init__(self)
     self.putChild("workers", workers.Workers())
     self.putChild("task", task.Task())
     self.putChild("repo", repo.Repo())
     self.putChild("job", job.JobResource())
     self.putChild("log", log.LogResource())
Example #4
0
def main(argv):
    try:
        opts, leftover = getopt.getopt(argv[1:], 'd:a:u:r:D:A:p:P:Mz:', [
            'src-device=', 'src-archive=', 'src-url=', 'src-repo=',
            'dst-device=', 'dst-archive=', 'config=', 'no-meta', 'compression='
        ])
    except getopt.GetoptError:
        print "Invalid Options"
        return 1

    src = None
    dst = None
    pspecs = []
    pops = []
    needmeta = True
    compress = 'gzip'
    for opt, arg in opts:
        if opt in ('-d', '--src-device'):
            if (src):
                raise Exception("May not have more than one source.")
            src = container.BlockDevice(arg, src=True)
        elif opt in ('-D', '--dst-device'):
            if (dst):
                raise Exception("May not have more than one destination.")
            dst = container.BlockDevice(arg)
        elif opt in ('-a', '--src-archive'):
            if (src):
                raise Exception("May not have more than one source.")
            src = container.Archive(arg, src=True)
        elif opt in ('-u', '--src-url'):
            if (src):
                raise Exception("May not have more than one source.")
            src = repo.URL(arg)
        elif opt in ('-r', '--src-repo'):
            if (src):
                raise Exception("May not have more than one source.")
            src = repo.Repo(arg)
        elif opt in ('-A', '--dst-archive'):
            if (dst):
                raise Exception("May not have more than one destination.")
            dst = container.Archive(arg)
        elif opt in ('-p'):
            pspecs.append(part.PartitionSpec(arg))
        elif opt in ('-P'):
            pops.append(part.PartitionOptions(arg))
        elif opt in ('-M'):
            needmeta = False
        elif opt in ('-z', '--compression'):
            compress = arg
        else:
            pass
    if src and dst:
        return convertImage(src, dst, pspecs, pops, needmeta, compress)
    else:
        usage()
        return 2
Example #5
0
def ls(store, sha, prefix = ''):
    r = repo.Repo(store)
    blob = store.getobj(sha)
    if blob is None:
        return
    t = babygit.obj_type(blob)
    if t == 'tree':
        for mode, name, child_sha in r.parse_tree(blob):
            print mode, prefix + '/' + name
            ls(store, child_sha, prefix + '/' + name)
Example #6
0
def init_test_repo():
    babygit.put_test_repo(s)

    r = repo.Repo(s)
    stage.checkout(r) 
    tree = stage.getroot(r)
    tree = stage.save(r, 'dir/newfile', 'This is a new file!\n', tree)
    tree = stage.save(r, 'dir/anotherfile', 'This is another new file!\n', tree)
    tree = stage.save(r, 'dir/newfile', 'Replace contents\n', tree)
    stage.add(r, tree)
    stage.commit(r, 'Author <*****@*****.**>', 'Test adding a new file\n')
Example #7
0
def find_command(message, ghrepo):
    config = ConfigParser.RawConfigParser()
    config.read('command.cfg')
    commands = config.items('commands')

    command = None
    for key, value in commands:
        ret = re.search(r"{}".format(key), message)

        if (ret is not None):
            class_ = getattr(importlib.import_module("cmd." + value),
                             value.capitalize())
            command = class_(repo.Repo(ghrepo), message)
            logger.info('command: ' + value)

            find_command_arguments(message, command, value)

    return command
    def test_polymorfism(self):
        r = repo.Repo()

        p1 = package.RPMPackage()
        p1.name = "one"
        p1.version = "version"

        p2 = package.ModulePackage()
        p2.name = "two"
        p2.stream = "stream"

        r.packages.append(p1)
        r.packages.append(p2)

        p1_copy = r.packages[0]
        self.assertEqual(p1, p1_copy)

        p1.name = "foo"
        self.assertEqual(p1.name, "foo")
        self.assertEqual(p1_copy.name, "foo")

        p1_copy.name = "bar"
        self.assertEqual(p1.name, "bar")
        self.assertEqual(p1_copy.name, "bar")
 def test_baseurl_set_get(self):
     r = repo.Repo()
     r.set_baseurl(["http://example.com/repo"])
     self.assertEqual(r.get_baseurl(), ("http://example.com/repo", ))
Example #10
0
    def generate_revision_key(self, url, ud, d):
        key = self._revision_key(url, ud, d)
        return "%s-%s" % (key, bb.data.getVar("PN", d, True) or "")


import cvs
import git
import local
import svn
import wget
import svk
import ssh
import perforce
import bzr
import hg
import osc
import repo

methods.append(local.Local())
methods.append(wget.Wget())
methods.append(svn.Svn())
methods.append(git.Git())
methods.append(cvs.Cvs())
methods.append(svk.Svk())
methods.append(ssh.SSH())
methods.append(perforce.Perforce())
methods.append(bzr.Bzr())
methods.append(hg.Hg())
methods.append(osc.Osc())
methods.append(repo.Repo())
Example #11
0
 def __init__(self, request, response):
     self.initialize(request, response)
     self.store = s
     self.repo = repo.Repo(s)
Example #12
0
def load_params(args):
    """
    reads the parameter file and creates as list of test objects as well as
    the suite object
    """

    test_list = []

    cp = configparser.ConfigParser()    # note, need strict=False for Python3
    cp.optionxform = str

    log = test_util.Log()

    log.bold("loading " + args.input_file[0])

    try: cp.read(args.input_file[0])
    except:
        log.fail("ERROR: unable to read parameter file {}".format(file))

    # "main" is a special section containing the global suite parameters.
    mysuite = suite.Suite(args)

    mysuite.log = log

    valid_options = list(mysuite.__dict__.keys())

    for opt in cp.options("main"):

        # get the value of the current option
        value = convert_type(cp.get("main", opt))

        if opt in valid_options:

            if opt == "sourceTree":
                if not value in ["C_Src", "F_Src", "BoxLib"]:
                    mysuite.log.fail("ERROR: invalid sourceTree")
                else:
                    mysuite.sourceTree = value

            elif opt == "testTopDir": mysuite.testTopDir = mysuite.check_test_dir(value)
            elif opt == "webTopDir": mysuite.webTopDir = os.path.normpath(value) + "/"

            elif opt == "emailTo": mysuite.emailTo = value.split(",")

            else:
                # generic setting of the object attribute
                setattr(mysuite, opt, value)

        else:
            mysuite.log.warn("suite parameter {} not valid".format(opt))


    # BoxLib -- this will always be defined
    rdir = mysuite.check_test_dir(safe_get(cp, "BoxLib", "dir"))

    branch = convert_type(safe_get(cp, "BoxLib", "branch"))
    rhash = convert_type(safe_get(cp, "BoxLib", "hash"))

    mysuite.repos["BoxLib"] = repo.Repo(mysuite, rdir, "BoxLib",
                                        branch_wanted=branch, hash_wanted=rhash)


    # now all the other build and source directories
    other_srcs = [s for s in cp.sections() if s.startswith("extra-")]
    if not mysuite.sourceTree == "BoxLib": other_srcs.append("source")

    for s in other_srcs:
        if s.startswith("extra-"):
            k = s.split("-")[1]
        else:
            k = "source"

        rdir = mysuite.check_test_dir(safe_get(cp, s, "dir"))
        branch = convert_type(safe_get(cp, s, "branch"))
        rhash = convert_type(safe_get(cp, s, "hash"))

        build = convert_type(safe_get(cp, s, "build", default=0))
        if s == "source": build = 1

        comp_string = safe_get(cp, s, "comp_string")

        name = os.path.basename(os.path.normpath(rdir))

        mysuite.repos[k] = repo.Repo(mysuite, rdir, name,
                                     branch_wanted=branch, hash_wanted=rhash,
                                     build=build, comp_string=comp_string)


    # BoxLib-only tests don't have a sourceDir
    mysuite.boxlib_dir = mysuite.repos["BoxLib"].dir

    if mysuite.sourceTree == "BoxLib":
        mysuite.source_dir = mysuite.repos["BoxLib"].dir
    else:
        mysuite.source_dir = mysuite.repos["source"].dir


    # now flesh out the compile strings -- they may refer to either themselves
    # or the source dir
    for r in mysuite.repos.keys():
        s = mysuite.repos[r].comp_string
        if not s is None:
            mysuite.repos[r].comp_string = \
                s.replace("@self@", mysuite.repos[r].dir).replace("@source@", mysuite.repos["source"].dir)


    # the suite needs to know any ext_src_comp_string
    for r in mysuite.repos.keys():
        if not mysuite.repos[r].build == 1:
            if not mysuite.repos[r].comp_string is None:
                mysuite.extra_src_comp_string += "{} ".format(mysuite.repos[r].comp_string)

    # checks
    if mysuite.sendEmailWhenFail and not args.send_no_email:
        if mysuite.emailTo == [] or mysuite.emailBody == "":
            mysuite.log.fail("ERROR: when sendEmailWhenFail = 1, you must specify emailTo and emailBody\n")

        if mysuite.emailFrom == "":
            mysuite.emailFrom = '@'.join((getpass.getuser(), socket.getfqdn()))

        if mysuite.emailSubject == "":
            mysuite.emailSubject = mysuite.suiteName+" Regression Test Failed"

    if mysuite.slack_post:
        if not os.path.isfile(mysuite.slack_webhookfile):
            mysuite.log.warn("slack_webhookfile invalid")
            mysuite.slack_post = 0
        else:
            print(mysuite.slack_webhookfile)
            try: f = open(mysuite.slack_webhookfile)
            except:
                mysuite.log.warn("unable to open webhook file")
                mysuite.slack_post = 0
            else:
                mysuite.slack_webhook_url = str(f.readline())
                f.close()

    if (mysuite.sourceTree == "" or mysuite.boxlib_dir == "" or
        mysuite.source_dir == "" or mysuite.testTopDir == ""):
        mysuite.log.fail("ERROR: required suite-wide directory not specified\n" + \
                         "(sourceTree, boxLibDir, sourceDir, testTopDir)")

    # Make sure the web dir is valid (or use the default is none specified)
    if mysuite.webTopDir == "":
        mysuite.webTopDir = "{}/{}-web/".format(mysuite.testTopDir, mysuite.suiteName)

    if not os.path.isdir(mysuite.webTopDir):
        try: os.mkdir(mysuite.webTopDir)
        except:
            mysuite.log.fail("ERROR: unable to create the web directory: {}\n".format(
                mysuite.webTopDir))

    # all other sections are tests
    mysuite.log.skip()
    mysuite.log.bold("finding tests and checking parameters...")

    for sec in cp.sections():

        if sec in ["main", "BoxLib", "source"] or sec.startswith("extra-"): continue

        # maximum test name length -- used for HTML formatting
        mysuite.lenTestName = max(mysuite.lenTestName, len(sec))

        # create the test object for this test
        mytest = suite.Test(sec)
        mytest.log = log
        invalid = 0

        # set the test object data by looking at all the options in
        # the current section of the parameter file
        valid_options = list(mytest.__dict__.keys())
        valid_options += ["aux1File", "aux2File", "aux3File"]
        valid_options += ["link1File", "link2File", "link3File"]

        for opt in cp.options(sec):

            # get the value of the current option
            value = convert_type(cp.get(sec, opt))

            if opt in valid_options:

                if opt in ["aux1File", "aux2File", "aux3File"]:
                    mytest.auxFiles.append(value)

                elif opt in ["link1File", "link2File", "link3File"]:
                    mytest.linkFiles.append(value)

                else:
                    # generic setting of the object attribute
                    setattr(mytest, opt, value)

            else:
                mysuite.log.warn("unrecognized parameter {} for test {}".format(opt, sec))


        # make sure that the build directory actually exists
        if not mytest.extra_build_dir == "":
            bdir = mysuite.repos[mytest.extra_build_dir].dir + mytest.buildDir
        else:
            bdir = mysuite.source_dir + mytest.buildDir

        if not os.path.isdir(bdir):
            mysuite.log.warn("invalid build directory: {}".format(bdir))
            invalid = 1


        # make sure all the require parameters are present
        if mytest.compileTest:
            if mytest.buildDir == "":
                mysuite.log.warn("mandatory parameters for test {} not set".format(sec))
                invalid = 1

        else:
            if (mytest.buildDir == "" or mytest.inputFile == "" or
                (mysuite.sourceTree == "C_Src" and mytest.probinFile == "") or
                mytest.dim == -1):
                warn_msg = ["required params for test {} not set".format(sec),
                            "buildDir = {}".format(mytest.buildDir),
                            "inputFile = {}".format(mytest.inputFile)]
                if mysuite.sourceTree == "C_Src":
                    warn_msg += ["probinFile = {}".format(mytest.probinFile)]
                warn_msg += ["dim = {}".format(mytest.dim)]
                mysuite.log.warn(warn_msg)

                invalid = 1

        # check the optional parameters
        if mytest.restartTest and mytest.restartFileNum == -1:
            mysuite.log.warn("restart-test {} needs a restartFileNum".format(sec))
            invalid = 1

        if mytest.selfTest and mytest.stSuccessString == "":
            mysuite.log.warn("self-test {} needs a stSuccessString".format(sec))
            invalid = 1

        if mytest.useMPI and mytest.numprocs == -1:
            mysuite.log.warn("MPI parallel test {} needs numprocs".format(sec))
            invalid = 1

        if mytest.useOMP and mytest.numthreads == -1:
            mysuite.log.warn("OpenMP parallel test {} needs numthreads".format(sec))
            invalid = 1

        if mytest.doVis and mytest.visVar == "":
            mysuite.log.warn("test {} has visualization, needs visVar".format(sec))
            invalid = 1

        if mysuite.sourceTree == "BoxLib" and mytest.testSrcTree == "":
            mysuite.log.warn("testSrcTree not set for BoxLib test {}".format(sec))
            invalid = 1


        # add the current test object to the master list
        if not invalid:
            test_list.append(mytest)
        else:
            mysuite.log.warn("test {} will be skipped".format(sec))


    # if any runs are parallel, make sure that the MPIcommand is defined
    any_MPI = any([t.useMPI for t in test_list])

    if any_MPI and mysuite.MPIcommand == "":
        mysuite.log.fail("ERROR: some tests are MPI parallel, but MPIcommand not defined")

    test_list.sort()

    return mysuite, test_list
Example #13
0
def load_params(args):
    """
    reads the parameter file and creates as list of test objects as well as
    the suite object
    """

    test_list = []

    try:
        cp = configparser.ConfigParser(strict=False)
    except:
        cp = configparser.ConfigParser()

    cp.optionxform = str

    log = test_util.Log(output_file=args.log_file)

    log.bold("loading " + args.input_file[0])

    if not os.path.exists(args.input_file[0]):
        raise OSError(f"Parameter file {args.input_file[0]} does not exist")

    try:
        cp.read(args.input_file[0])
    except:
        log.fail(f"ERROR: unable to read parameter file {args.input_file[0]}")

    # "main" is a special section containing the global suite parameters.
    mysuite = suite.Suite(args)
    log.suite = mysuite
    mysuite.log = log

    valid_options = list(mysuite.__dict__.keys())

    for opt in cp.options("main"):

        # get the value of the current option
        value = convert_type(cp.get("main", opt))

        if opt in valid_options or "_" + opt in valid_options:

            if opt == "sourceTree":
                if not value in ["C_Src", "AMReX", "amrex"]:
                    mysuite.log.fail("ERROR: invalid sourceTree")
                else:
                    mysuite.sourceTree = value

            elif opt == "testTopDir":
                mysuite.testTopDir = mysuite.check_test_dir(value)
                print(f"just set testTopDir = {mysuite.testTopDir}")
            elif opt == "webTopDir":
                mysuite.init_web_dir(value)
            elif opt == "reportCoverage":
                mysuite.reportCoverage = mysuite.reportCoverage or value
            elif opt == "emailTo":
                mysuite.emailTo = value.split(",")
            elif opt == "ftools":
                mysuite.ftools = value.split()
            elif opt == "extra_tools":
                mysuite.extra_tools = value

            else:
                # generic setting of the object attribute
                setattr(mysuite, opt, value)

        else:
            mysuite.log.warn(f"suite parameter {opt} not valid")

    # AMReX -- this will always be defined
    rdir = mysuite.check_test_dir(safe_get(cp, "AMReX", "dir"))

    branch = safe_get(cp, "AMReX", "branch")  # note: always as string
    rhash = convert_type(safe_get(cp, "AMReX", "hash"))

    mysuite.repos["AMReX"] = repo.Repo(mysuite,
                                       rdir,
                                       "AMReX",
                                       branch_wanted=branch,
                                       hash_wanted=rhash)

    if args.amrex_pr is not None:
        mysuite.repos["AMReX"].pr_wanted = args.amrex_pr

    # Check for Cmake build options for both AMReX and Source
    for s in cp.sections():
        if s == "AMReX":
            mysuite.amrex_cmake_opts = safe_get(cp,
                                                s,
                                                "cmakeSetupOpts",
                                                default="")
        elif s == "source":
            mysuite.source_cmake_opts = safe_get(cp,
                                                 s,
                                                 "cmakeSetupOpts",
                                                 default="")

    # now all the other build and source directories
    other_srcs = [s for s in cp.sections() if s.startswith("extra-")]
    if not mysuite.sourceTree in ["AMReX", "amrex"]:
        other_srcs.append("source")

    for s in other_srcs:
        if s.startswith("extra-"):
            k = s.split("-", 1)[1]
        else:
            k = "source"

        rdir = mysuite.check_test_dir(safe_get(cp, s, "dir"))
        branch = safe_get(cp, s, "branch")  # note: always as string
        rhash = convert_type(safe_get(cp, s, "hash"))

        build = convert_type(safe_get(cp, s, "build", default=0))
        if s == "source": build = 1

        comp_string = safe_get(cp, s, "comp_string")

        name = os.path.basename(os.path.normpath(rdir))

        mysuite.repos[k] = repo.Repo(mysuite,
                                     rdir,
                                     name,
                                     branch_wanted=branch,
                                     hash_wanted=rhash,
                                     build=build,
                                     comp_string=comp_string)

    # AMReX-only tests don't have a sourceDir
    mysuite.amrex_dir = mysuite.repos["AMReX"].dir

    if mysuite.sourceTree in ["AMReX", "amrex"]:
        mysuite.source_dir = mysuite.repos["AMReX"].dir
    else:
        mysuite.source_dir = mysuite.repos["source"].dir

    # did we override the branch on the commandline?
    if args.source_branch is not None and args.source_pr is not None:
        mysuite.log.fail(
            "ERROR: cannot specify both source_branch and source_pr")

    if args.source_branch is not None:
        mysuite.repos["source"].branch_wanted = args.source_branch

    if args.source_pr is not None:
        mysuite.repos["source"].pr_wanted = args.source_pr

    # now flesh out the compile strings -- they may refer to either themselves
    # or the source dir
    for r in mysuite.repos.keys():
        s = mysuite.repos[r].comp_string
        if not s is None:
            mysuite.repos[r].comp_string = \
                s.replace("@self@", mysuite.repos[r].dir).replace("@source@", mysuite.repos["source"].dir)

    # the suite needs to know any ext_src_comp_string
    for r in mysuite.repos.keys():
        if not mysuite.repos[r].build == 1:
            if not mysuite.repos[r].comp_string is None:
                mysuite.extra_src_comp_string += f" {mysuite.repos[r].comp_string} "

    # checks
    if args.send_no_email:
        mysuite.sendEmailWhenFail = 0

    if mysuite.sendEmailWhenFail:
        if mysuite.emailTo == [] or mysuite.emailBody == "":
            mysuite.log.fail(
                "ERROR: when sendEmailWhenFail = 1, you must specify emailTo and emailBody\n"
            )

        if mysuite.emailFrom == "":
            mysuite.emailFrom = '@'.join((getpass.getuser(), socket.getfqdn()))

        if mysuite.emailSubject == "":
            mysuite.emailSubject = mysuite.suiteName + " Regression Test Failed"

    if mysuite.slack_post:
        if not os.path.isfile(mysuite.slack_webhookfile):
            mysuite.log.warn("slack_webhookfile invalid")
            mysuite.slack_post = 0
        else:
            print(mysuite.slack_webhookfile)
            try:
                f = open(mysuite.slack_webhookfile)
            except:
                mysuite.log.warn("unable to open webhook file")
                mysuite.slack_post = 0
            else:
                mysuite.slack_webhook_url = str(f.readline())
                f.close()

    if (mysuite.sourceTree == "" or mysuite.amrex_dir == ""
            or mysuite.source_dir == "" or mysuite.testTopDir == ""):
        mysuite.log.fail("ERROR: required suite-wide directory not specified\n" + \
                         "(sourceTree, amrexDir, sourceDir, testTopDir)")

    # Make sure the web dir is valid
    if not os.path.isdir(mysuite.webTopDir):
        try:
            os.mkdir(mysuite.webTopDir)
        except:
            mysuite.log.fail(
                "ERROR: unable to create the web directory: {}\n".format(
                    mysuite.webTopDir))

    # all other sections are tests
    mysuite.log.skip()
    mysuite.log.bold("finding tests and checking parameters...")

    for sec in cp.sections():

        if sec in ["main", "AMReX", "source"] or sec.startswith("extra-"):
            continue

        # maximum test name length -- used for HTML formatting
        mysuite.lenTestName = max(mysuite.lenTestName, len(sec))

        # create the test object for this test
        mytest = suite.Test(sec)
        mytest.log = log
        invalid = 0

        # set the test object data by looking at all the options in
        # the current section of the parameter file
        valid_options = list(mytest.__dict__.keys())
        aux_pat = re.compile(r"aux\d+File")
        link_pat = re.compile(r"link\d+File")

        for opt in cp.options(sec):

            # get the value of the current option
            value = convert_type(cp.get(sec, opt))

            if opt in valid_options or "_" + opt in valid_options:

                if opt == "keyword":
                    mytest.keywords = [k.strip() for k in value.split(",")]

                else:
                    # generic setting of the object attribute
                    setattr(mytest, opt, value)

            elif aux_pat.match(opt):

                mytest.auxFiles.append(value)

            elif link_pat.match(opt):

                mytest.linkFiles.append(value)

            else:

                mysuite.log.warn(
                    f"unrecognized parameter {opt} for test {sec}")

        # make sure that the build directory actually exists
        if not mytest.extra_build_dir == "":
            bdir = mysuite.repos[mytest.extra_build_dir].dir + mytest.buildDir
        else:
            bdir = mysuite.source_dir + mytest.buildDir

        if not os.path.isdir(bdir):
            mysuite.log.warn(f"invalid build directory: {bdir}")
            invalid = 1

        # make sure all the require parameters are present
        if mytest.compileTest:
            if mytest.buildDir == "":
                mysuite.log.warn(
                    f"mandatory parameters for test {sec} not set")
                invalid = 1

        else:

            input_file_invalid = mytest.inputFile == "" and not mytest.run_as_script
            if mytest.buildDir == "" or input_file_invalid or mytest.dim == -1:
                warn_msg = [
                    f"required params for test {sec} not set",
                    f"buildDir = {mytest.buildDir}",
                    f"inputFile = {mytest.inputFile}"
                ]
                warn_msg += [f"dim = {mytest.dim}"]
                mysuite.log.warn(warn_msg)

                invalid = 1

        # check the optional parameters
        if mytest.restartTest and mytest.restartFileNum == -1:
            mysuite.log.warn(f"restart-test {sec} needs a restartFileNum")
            invalid = 1

        if mytest.selfTest and mytest.stSuccessString == "":
            mysuite.log.warn(f"self-test {sec} needs a stSuccessString")
            invalid = 1

        if mytest.useMPI and mytest.numprocs == -1:
            mysuite.log.warn(f"MPI parallel test {sec} needs numprocs")
            invalid = 1

        if mytest.useOMP and mytest.numthreads == -1:
            mysuite.log.warn(f"OpenMP parallel test {sec} needs numthreads")
            invalid = 1

        if mytest.doVis and mytest.visVar == "":
            mysuite.log.warn(f"test {sec} has visualization, needs visVar")
            invalid = 1

        if mysuite.sourceTree in ["AMReX", "amrex"
                                  ] and mytest.testSrcTree == "":
            mysuite.log.warn(f"testSrcTree not set for AMReX test {sec}")
            invalid = 1

        # add the current test object to the master list
        if not invalid:
            test_list.append(mytest)
        else:
            mysuite.log.warn(f"test {sec} will be skipped")

    # if any runs are parallel, make sure that the MPIcommand is defined
    any_MPI = any([t.useMPI for t in test_list])

    if any_MPI and mysuite.MPIcommand == "":
        mysuite.log.fail(
            "ERROR: some tests are MPI parallel, but MPIcommand not defined")

    test_list.sort()

    return mysuite, test_list
Example #14
0
def handler(event, context):
    logger.info('event: ' + json.dumps(event))

    # Get from POST or GET requests
    if 'body' in event and \
       event['body'] is not None:
        event = json.loads(event['body'])
        logger.info('event: ' + json.dumps(event))

    elif 'queryStringParameters' in event and \
       event['queryStringParameters'] is not None:
        event = event['queryStringParameters']
        logger.info('event: ' + str(event))

    # Execute cron jobs
    if 'source' in event and \
       event['source'] == 'cron' and \
       'action' in event:
        ghrepo = None
        if 'squad-repo' in event:
            ghrepo = find_repo(event.pop('squad-repo'))

        class_ = getattr(importlib.import_module("jobs." + event['action']),
                         event['action'].capitalize())
        job = class_(repo.Repo(ghrepo), event)
        job.execute()

        ret = get_return(True, 'job ' + event['action'] + ' executed')

    # Execute html requests
    elif 'source' in event and \
       event.pop('source') == 'html' and \
       'action' in event and \
       'squad-repo' in event:

        ghrepo = find_repo(event.pop('squad-repo'))
        functionAttr = getattr(repo.Repo(ghrepo), event.pop('action'))
        jsonr = functionAttr(**event)

        ret = get_return(True, jsonr)

    # Execute BOT commands
    else:
        # Get the right parser
        parser = find_parser(event)

        if parser is not None:
            if hasattr(parser, 'validate'):
                ret = get_return(True, parser.validate)
                return ret

            if hasattr(parser, 'text'):
                ghrepo = find_repo(parser.text)
                if ghrepo is None and hasattr(parser, 'channel_name'):
                    ghrepo = parser.channel_name

                logger.info('ghrepo: {}'.format(ghrepo))
                command = find_command(parser.text, ghrepo)
                msg = command.execute()
                ret = get_return(True, parser.send_message(msg))

            else:
                ret = get_return(False, 'invalid command')

        else:
            ret = get_return(False, 'invalid parser')

    return ret
 def test_baseurl_property(self):
     r = repo.Repo()
 def test_baseurl_default(self):
     r = repo.Repo()
     self.assertEqual(r.get_baseurl(), ())
 def test_repoid_property(self):
     r = repo.Repo()
     r.repoid = "a-repo-id"
     self.assertEqual(r.repoid, "a-repo-id")
     # verify that the value is identical to what's returned from getter
     self.assertEqual(r.get_repoid(), "a-repo-id")
 def test_repoid_set_get(self):
     r = repo.Repo()
     r.set_repoid("a-repo-id")
     self.assertEqual(r.get_repoid(), "a-repo-id")
 def test_repoid_default(self):
     r = repo.Repo()
     self.assertEqual(r.get_repoid(), "")
     self.assertEqual(r.repoid, "")