コード例 #1
0
def test_readconfig(tmpdir):
    p16 = Proc()
    assert p16.id == 'p16'
    # nothing updated
    p16._readConfig(None, Config())
    assert p16.id == 'p16'

    config = Config()
    config._load({'f20': {'forks': 20}})
    p16.forks = 10
    p16._readConfig({'forks': 30}, config)
    assert p16.id == 'p16'
    assert p16.forks == 10
    assert p16.runner == 'local'
    assert p16.config.runner == '__tmp__'

    p17 = Proc()
    p17.forks = 10
    config = Config()
    config._load({'f30': {'forks': 20}})
    # no such profile in config
    p17._readConfig('dry', config)
    assert p17.forks == 10
    assert p17.runner == 'dry'
    assert p17.config.runner == 'dry'
コード例 #2
0
def test_runjobs(tmpdir):
    p21 = Proc()
    p21.forks = 3
    p21.input = 'a, b'
    p21.input = [(1, 2), (3, 4), (5, 6)]
    p21.output = 'a:{{i.a}}, b:{{i.b}}'
    p21.script = 'echo Hello world!'
    p21._preRunTidy()
    p21._runJobs()
    assert p21.channel == [('1', '2'), ('3', '4'), ('5', '6')]
    assert p21.channel.a.flatten() == ['1', '3', '5']
    assert p21.channel.b.flatten() == ['2', '4', '6']
コード例 #3
0
def test_postruntidy(tmpdir, caplog):
    p22 = Proc()
    p22.resume = 'skip+'
    p22.callback = lambda p: p.props.update({'channel': p.channel.cbind(1, 2)})
    p22._postRunTidy()
    assert p22.channel == [(1, 2)]

    p23 = Proc()
    p23.forks = 5
    p23.input = 'a, b'
    p23.input = [(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)]
    p23.output = 'a:{{i.a}}, b:{{i.b}}'
    p23.script = 'echo Hello world!'
    p23.errhow = 'ignore'
    p23.callback = lambda p: setattr(p, 'forks', 10)
    p23._preRunTidy()
    p23._runJobs()
    p23.jobs[0].state = STATES.BUILTFAILED
    p23.jobs[1].state = STATES.SUBMITFAILED
    p23.jobs[2].state = STATES.DONE
    p23.jobs[3].state = STATES.DONECACHED
    p23.jobs[4].state = STATES.ENDFAILED
    p23._postRunTidy()
    assert ' Jobs (Cached: 1, Succ: 1, B.Fail: 1, S.Fail: 1, R.Fail: 1)' in caplog.text
    assert 'Failed but ignored (totally 3).' in caplog.text
    assert p23.forks == 10

    p23.errhow = 'terminate'
    caplog.clear()
    with pytest.raises(SystemExit):
        p23._postRunTidy()
    assert 'Cached: 4' in caplog.text
    assert 'Succeeded: 3' in caplog.text
    assert 'Building failed: 1' in caplog.text
    assert 'Submission failed: 2' in caplog.text
    assert 'Running failed: 5' in caplog.text