示例#1
0
文件: __init__.py 项目: kd0kfo/dag
def test_gsub():
    from dag import gsub, DEFAULT_DAGFILE_NAME, Engine
    from os.path import isfile

    expected_command = "print(\"Not a comment\")"

    if isfile(DEFAULT_DAGFILE_NAME):
        from os import unlink
        unlink(DEFAULT_DAGFILE_NAME)
    test_dag = gsub.gsub("test/internal.sub", init_filename="test/dagrc",
                         engine=Engine.SHELL)
    processes = test_dag.processes
    if len(processes) != 1:
        print("Invalid number of processes produced by submission file")
        print("Expected 1 but have {0}".format(len(processes)))
        return False

    process = processes[0]
    if process.cmd != expected_command:
        print("Command parsed from file is invalid.")
        print("Expected: {0}".format(expected_command))
        print("Have: {0}".format(process.cmd))
        return False

    return True
示例#2
0
文件: __init__.py 项目: kd0kfo/dag
def test_shell_processes():
    from dag import gsub, DEFAULT_DAGFILE_NAME, States, Engine
    from os.path import isfile

    if isfile(DEFAULT_DAGFILE_NAME):
        from os import unlink
        unlink(DEFAULT_DAGFILE_NAME)

    test_dag = gsub.gsub("test/shell.sub", init_filename="test/dagrc",
                         engine=Engine.SHELL)

    for proc in test_dag.processes:
        if proc.state != States.SUCCESS and proc.workunit_name != "cat-2":
            return False

    return True