File: test003.py

package info (click to toggle)
aap 1.072-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,980 kB
  • ctags: 2,160
  • sloc: python: 15,113; makefile: 61; sh: 31
file content (66 lines) | stat: -rw-r--r-- 1,497 bytes parent folder | download | duplicates (2)
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
# Part of the A-A-P recipe executive: Testing of remembering signatures

# Copyright (C) 2002-2003 Stichting NLnet Labs
# Permission to copy and use this file is specified in the file COPYING.
# If this file is missing you can find it here: http://www.a-a-p.org/COPYING

import sys, os, stat

def runaap(args):
    return os.system("%s ..%sMain.py %s" % (sys.argv[1], os.sep, args))

os.chdir("rectest")

# Create a recipe and try running it.
# Then run it again and check it doesn't do the same thing twice.
rec = "rectest.aap"
inp = "rectest.in"
out = "rectest.out"

f = open(rec, "w")
f.write("""
%s: %s
    :cat %s >> %s
""" % (out, inp, inp, out))
f.close()

f = open(inp, "w")
f.write("This is input\n")
f.close()

f = open(out, "w")
f.write("This is output\n")
f.close()

# When running twice, the second time nothing should happen, since the source
# file didn't change.
runaap("-f %s %s" % (rec, out))
st1 = os.stat(out)
runaap("-f %s %s" % (rec, out))
st2 = os.stat(out)

res = 0
if st1[stat.ST_SIZE] != st2[stat.ST_SIZE]:
    print "Aap rebuild when it was not needed"
    res = 1

f = open(inp, "w")
f.write("This is foo again\n")
f.close()

# When running again while the source has changed, the result must change as
# well.
runaap("-f %s %s" % (rec, out))
st2 = os.stat(out)
if st1[stat.ST_SIZE] == st2[stat.ST_SIZE]:
    print "Aap did not rebuild when it was needed"
    res = 1

os.remove(rec)
os.remove(inp)
os.remove(out)

sys.exit(res)


# vim: set sw=4 et sts=4 tw=79 fo+=l: