Example #1
0
def test_batchpipe():
    with no_lingering_errors():
        for chunk in batchpipe(['echo'], []):
            WVPASS(False)
        out = ''
        for chunk in batchpipe(['echo'], ['42']):
            out += chunk
        WVPASSEQ(out, '42\n')
        try:
            batchpipe(['bash', '-c'], ['exit 42'])
        except Exception as ex:
            WVPASSEQ(str(ex),
                     "subprocess 'bash -c exit 42' failed with status 42")
        args = [str(x) for x in range(6)]
        # Force batchpipe to break the args into batches of 3.  This
        # approach assumes all args are the same length.
        arg_max = \
            helpers._argmax_base(['echo']) + helpers._argmax_args_size(args[:3])
        batches = batchpipe(['echo'], args, arg_max=arg_max)
        WVPASSEQ(next(batches), '0 1 2\n')
        WVPASSEQ(next(batches), '3 4 5\n')
        WVPASSEQ(next(batches, None), None)
        batches = batchpipe(['echo'], [str(x) for x in range(5)],
                            arg_max=arg_max)
        WVPASSEQ(next(batches), '0 1 2\n')
        WVPASSEQ(next(batches), '3 4\n')
        WVPASSEQ(next(batches, None), None)
Example #2
0
def test_batchpipe():
    with no_lingering_errors():
        for chunk in batchpipe(['echo'], []):
            WVPASS(False)
        out = ''
        for chunk in batchpipe(['echo'], ['42']):
            out += chunk
        WVPASSEQ(out, '42\n')
        try:
            batchpipe(['bash', '-c'], ['exit 42'])
        except Exception as ex:
            WVPASSEQ(str(ex),
                     "subprocess 'bash -c exit 42' failed with status 42")
        args = [str(x) for x in range(6)]
        # Force batchpipe to break the args into batches of 3.  This
        # approach assumes all args are the same length.
        arg_max = \
            helpers._argmax_base(['echo']) + helpers._argmax_args_size(args[:3])
        batches = batchpipe(['echo'], args, arg_max=arg_max)
        WVPASSEQ(next(batches), '0 1 2\n')
        WVPASSEQ(next(batches), '3 4 5\n')
        WVPASSEQ(next(batches, None), None)
        batches = batchpipe(['echo'], [str(x) for x in range(5)], arg_max=arg_max)
        WVPASSEQ(next(batches), '0 1 2\n')
        WVPASSEQ(next(batches), '3 4\n')
        WVPASSEQ(next(batches, None), None)
Example #3
0
def test_batchpipe():
    for chunk in batchpipe(['echo'], []):
        WVPASS(False)
    out = ''
    for chunk in batchpipe(['echo'], ['42']):
        out += chunk
    WVPASSEQ(out, '42\n')
    try:
        batchpipe(['bash', '-c'], ['exit 42'])
    except Exception, ex:
        WVPASSEQ(str(ex), "subprocess 'bash -c exit 42' failed with status 42")
    args = [str(x) for x in range(6)]
    # Force batchpipe to break the args into batches of 3.  This
    # approach assumes all args are the same length.
    arg_max = \
        helpers._argmax_base(['echo']) + helpers._argmax_args_size(args[:3])
    batches = batchpipe(['echo'], args, arg_max=arg_max)
    WVPASSEQ(next(batches), '0 1 2\n')
    WVPASSEQ(next(batches), '3 4 5\n')
    WVPASSEQ(next(batches, None), None)
    batches = batchpipe(['echo'], [str(x) for x in range(5)], arg_max=arg_max)
    WVPASSEQ(next(batches), '0 1 2\n')
    WVPASSEQ(next(batches), '3 4\n')
    WVPASSEQ(next(batches, None), None)


@wvtest
def test_atomically_replaced_file():
    tmpdir = tempfile.mkdtemp(dir=bup_tmp, prefix='bup-thelper-')
    target_file = os.path.join(tmpdir, 'test-atomic-write')
    initial_failures = wvfailure_count()
Example #4
0
def test_batchpipe():
    for chunk in batchpipe(['echo'], []):
        WVPASS(False)
    out = ''
    for chunk in batchpipe(['echo'], ['42']):
        out += chunk
    WVPASSEQ(out, '42\n')
    try:
        batchpipe(['bash', '-c'], ['exit 42'])
    except Exception, ex:
        WVPASSEQ(str(ex), "subprocess 'bash -c exit 42' failed with status 42")
    args = [str(x) for x in range(6)]
    # Force batchpipe to break the args into batches of 3.  This
    # approach assumes all args are the same length.
    arg_max = \
        helpers._argmax_base(['echo']) + helpers._argmax_args_size(args[:3])
    batches = batchpipe(['echo'], args, arg_max=arg_max)
    WVPASSEQ(next(batches), '0 1 2\n')
    WVPASSEQ(next(batches), '3 4 5\n')
    WVPASSEQ(next(batches, None), None)
    batches = batchpipe(['echo'], [str(x) for x in range(5)], arg_max=arg_max)
    WVPASSEQ(next(batches), '0 1 2\n')
    WVPASSEQ(next(batches), '3 4\n')
    WVPASSEQ(next(batches, None), None)


@wvtest
def test_atomically_replaced_file():
    tmpdir = tempfile.mkdtemp(dir=bup_tmp, prefix='bup-thelper-')
    target_file = os.path.join(tmpdir, 'test-atomic-write')
    initial_failures = wvfailure_count()