Persist variables to file (~/.whenjobs/variables).
[whenjobs.git] / tests / jobs / t300_reload.ml
1 (* whenjobs
2  * Copyright (C) 2012 Red Hat Inc.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  *)
18
19 (* Test reloading the script. *)
20
21 let () =
22   Whentools.set_variable_int "counter" 1;
23   Whentools.set_variable "state" "A"
24
25 every 4 seconds :
26 <<
27   echo $JOBSERIAL $JOBNAME $counter >\> $HOME/test_output
28   whenjobs --set --type int counter=$(($counter+1))
29 >>
30
31 when counter == 2 :
32 <<
33   echo $JOBSERIAL $JOBNAME $counter $state >\> $HOME/test_output
34
35   # Actually modify the 'set_variable' lines above in the jobs script.
36   mv $HOME/.whenjobs/jobs.ml $HOME/.whenjobs/jobs.ml.old
37   sed \
38       -e 's/"counter" 1/"counter" 3/' \
39       -e 's/"state" "A"/"state" "B"/' \
40        < $HOME/.whenjobs/jobs.ml.old > $HOME/.whenjobs/jobs.ml
41
42   whenjobs --upload --lib "$libdir"
43 >>
44
45 when counter == 4 :
46 <<
47   echo $JOBSERIAL $JOBNAME $counter $state >\> $HOME/test_output
48   whenjobs --daemon-stop
49 >>