File: clean.test

package info (click to toggle)
atheist 0.20110402-2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 1,332 kB
  • ctags: 902
  • sloc: python: 4,764; xml: 626; makefile: 113; cpp: 54; ansic: 5; sh: 5
file content (47 lines) | stat: -rw-r--r-- 1,268 bytes parent folder | download | duplicates (3)
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
# -*- mode: python; coding: utf-8 -*-

import os
from atheist.const import ATHEIST_TMP_BASE

fname = os.path.join(ATHEIST_TMP_BASE, '$testname')

Command('rm -f %s*' % fname)


def filename(n):
    return '{0}-{1}'.format(fname, n)

def touch(n):
    return "Test('echo hola > {0}', shell=True).gen += '{0}'".format(filename(n))

def exists(n):
    return FileExists(filename(n))


t2 = Test('$atheist -vvo --dirty -s "%s"' % touch(1),
          shell=True, desc="Check file creation (--dirty mode)")
t2.post += exists(1)

t3 = Test('rm %s-1' % fname)
t3.pre  += exists(1)
t3.post += Not(exists(1))

t4 = Test('$atheist -s "%s"' % touch(2), shell=True, desc="Clean after test (default)")
t4.pre  += Not(exists(2))
t4.post += Not(exists(2))


t5 = Test('$atheist -vvo --dirty -s "%s"' % touch(3),
          shell=True, desc="Check file creation (--dirty mode)")
t5.post += exists(3)

t6 = Test('$atheist -C -s "%s"' % touch(3), shell=True, desc="-C: Clean only")
t6.pre  += exists(3)
t6.post += Not(exists(3))

# clean also when test fails
touch_fail = "Test('touch {0}; exit 1', shell=True).gen += '{0}'".format(filename(4))

t7 = Test('$atheist -s "%s"' % touch_fail,
         expected=1, shell=True, desc="clean even when fails (default)")
t7.post += Not(exists(4))