~ubuntu-dev/ubuntu/lucid/atheist/lucid-201002101849

« back to all changes in this revision

Viewing changes to doc/intro.rst

  • Committer: Bazaar Package Importer
  • Author(s): Cleto Martin Angelina
  • Date: 2009-09-14 13:36:31 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20090914133631-fi4cla3ohh7u88t6
Tags: upstream-0.20090921
ImportĀ upstreamĀ versionĀ 0.20090921

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
Introduction
2
2
============
3
3
 
4
 
Athest is a simple framework for running test cases. You need to write
5
 
small files in Python language using a set of predefined functions and
6
 
classes. In many senses, the concept is quite similar to the SCons
7
 
framework although Atheist isn't a building system at all.
 
4
Athest is a simple framework for running test cases. You write small
 
5
files in Python language using a set of predefined functions and
 
6
classes. In many senses, the concept is quite similar to *make* or the
 
7
SCons framework although Atheist isn't a building system at all.
8
8
 
9
9
 
10
10
Test objects
18
18
exec.
19
19
 
20
20
The Test object is responsible to execute the command and check its
21
 
successful termination::
 
21
termination value::
22
22
 
23
23
   Test('true')
24
24
 
29
29
The Test instances need to be defined into text files. Although these
30
30
files are written in a subset of Python language, they may be seen as
31
31
declarative programs. You tell Athest what you want to test and even
32
 
the order, but the execution of the corresponding action is taken by
33
 
Athest, some of them may be never done. The file does not define
34
 
imperative sentences. For example, if you write this in a .test file::
 
32
the order, but the execution about when to execute the corresponding
 
33
action is taken by Athest; some of them may be never done. The file
 
34
does not define imperative sentences. For example, if you write this
 
35
in a .test file::
35
36
 
36
37
   Test('ls /')
37
38
   print "hello"
40
41
 
41
42
 
42
43
 
43
 
 
44
 
 
45
44
Key-args
46
45
^^^^^^^^
47
46
 
48
 
All Task's constructor accept the next key-val parameters. All of them
49
 
are optional. Beside the parameter name appears the its type and
 
47
Any Task constructor accepts the next key-val parameters. All of them
 
48
are optional. Beside the parameter name appears its type and
50
49
default value.
51
50
 
52
51
**cwd** -- type: ``str``
76
75
   Expected program return code. It may be negative if the process is
77
76
   killed by a signal.
78
77
 
79
 
**id** -- type: ``str``
 
78
**tid** -- type: ``str``
80
79
 
81
 
   It is a unique string Task identifier. You can get a reference to
 
80
   It is a unique string Task IDentifier. You can get a reference to
82
81
   the Task later giving this value to the :func:`get_task` function.
83
82
 
84
83
**must_fail** -- type: ``bool``, default: ``False``
126
125
 
127
126
 
128
127
    t1 = Template(timeout=2, expected=-9)
129
 
 
130
 
 
131
 
 
132
 
 
133
 
 
134
 
 
135
 
Conditions ----------
 
128
    Test('foo', templates[t1])
 
129
    Test('bar', templates[t1])
 
130
 
 
131
 
 
132
Both tests will be automatically killed after 2 seconds and the
 
133
expected return value is -9. That means these process recive the
 
134
SIGKILL(9) signal.
 
135
 
 
136
 
 
137
 
 
138
Conditions
 
139
----------
136
140
 
137
141
.. function:: EnvVarDefined(name[, value])
138
142
 
167
171
 
168
172
.. function:: Not(condition)
169
173
 
 
174
   It's True when *condition* is evaluated as False.
 
175
 
170
176
.. function:: Poll(condition[, interval=1[, timeout=5]])
171
177
 
 
178
   Checks *condition* each *interval* seconds stopping after *timeout*
 
179
   seconds or its value become True.
 
180
 
172
181
 
173
182
Pre and post conditions
174
183
^^^^^^^^^^^^^^^^^^^^^^^
175
184
 
 
185
Condition may be specified to be checked before (pre-conditions) or
 
186
after (post-conditions) the command execution. If any of the condition
 
187
fails, the test fails. This is an example::
 
188
 
 
189
  t = Test('foo')
 
190
  t.pre  += FileExists('/path/to/foofile')
 
191
  t.post += FileContains('path/to/barfile', 'some text')
176
192
 
177
193
 
178
194
Tasks, Tests, Commands and Daemons
190
206
 
191
207
.. function:: get_task(name)
192
208
 
193
 
   returns the task which ``id`` attribute is *name*.
 
209
   returns the task which ``tid`` attribute is *name*.
194
210
 
195
211
 
196
212
 
198
214
----------------------
199
215
 
200
216
The testfiles may include some useful substitutable variable. You must
201
 
to write the symbol '$' preceding one of the next words:
 
217
write the symbol '$' preceding one of the next words:
202
218
 
203
219
* basedir
204
220