-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbcat_test.py
53 lines (50 loc) · 1.51 KB
/
bcat_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os
import shell
from test_util import unindent, rm_whitespace, clone_source
def setup_module(m):
m.tempdir = clone_source()
m.orig = os.getcwd()
m.path = os.environ['PATH']
os.chdir(m.tempdir)
os.environ['PATH'] = f'{os.getcwd()}/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/bin'
shell.run('make clean && make bsv csv bcat', stream=True)
def teardown_module(m):
os.chdir(m.orig)
os.environ['PATH'] = m.path
assert m.tempdir.startswith('/tmp/') or m.tempdir.startswith('/private/var/folders/')
shell.run('rm -rf', m.tempdir)
def test_basic():
with shell.tempdir():
shell.run('for char in a a b b c c; do echo $char | bsv >> $char; done')
stdout = """
a:a
b:b
c:c
"""
assert rm_whitespace(unindent(stdout)) == shell.run('bcat --prefix --head 1 a b c')
stdout = """
a:a
a:a
b:b
b:b
c:c
c:c
"""
assert rm_whitespace(unindent(stdout)) == shell.run('bcat --prefix --head 2 a b c')
assert rm_whitespace(unindent(stdout)) == shell.run('bcat --head 2 --prefix a b c')
assert rm_whitespace(unindent(stdout)) == shell.run('bcat --prefix a b c')
stdout = """
a
b
c
"""
assert rm_whitespace(unindent(stdout)) == shell.run('bcat --head 1 a b c')
stdout = """
a
a
b
b
c
c
"""
assert rm_whitespace(unindent(stdout)) == shell.run('bcat a b c')