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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
import os
import sys
import cliapp
import yarnutils
datadir = os.environ['DATADIR']
srcdir = os.environ['SRCDIR']
vars = yarnutils.Variables(datadir)
_next_match = 1
def get_next_match():
global _next_match
name = 'MATCH_{}'.format(_next_match)
_next_match += 1
return os.environ[name]
def cat_file(filename):
with open(filename) as f:
return f.read()
def write_file(filename, content):
with open(filename, 'w') as f:
f.write(content)
def runcmd(argv, **kwargs):
if 'cwd' not in kwargs:
kwargs['cwd'] = vars['cwd']
return cliapp.runcmd_unchecked(argv, **kwargs)
def configure_git():
# Yarn sets $HOME to point at an empty temporary directory.
# Set up a simple git config so tests can use git.
runcmd(['git', 'config', '--global', 'user.email', 'tomjon@example.com'])
runcmd(['git', 'config', '--global', 'user.name', 'Tomjon Tester'])
def run_distix(args, cwd=None):
if cwd is None:
cwd = vars['cwd']
distix = os.path.join(srcdir, 'distix')
log_file = os.path.join(datadir, 'distix.log')
exit_code, out, err = runcmd(
[distix, '--no-default-config', '--quiet', '--log', log_file] +
args,
cwd=cwd)
vars['exit'] = exit_code
vars['stdout'] = out
vars['stderr'] = err
def mkmaildir(dirname):
os.makedirs(dirname)
for subdir in ['cur', 'tmp', 'new']:
os.mkdir(os.path.join(dirname, subdir))
def unescape(s):
return '\n'.join(s.split('\\n'))
|