Version 0.2.
[goaljobs.git] / goaljobs-reference.pod
index 393e4b5..da98946 100644 (file)
@@ -193,6 +193,21 @@ would print:
 
  my name is foo
 
+=head2 goalloc
+
+Inside goals, you can use C<goalloc> to get a printable source
+location of the goal, ie:
+
+ let goal foo () =
+   printf "%s\n" goalloc
+
+would print:
+
+ File "source.ml", line 2, characters 13-71 (end at line 3, character 23)
+
+Note that the actual string format depends on the internal OCaml
+function C<Loc.to_string> so it might change in future.
+
 =head2 onfail, onsuccess, onrun
 
 Inside goals you can register function(s) which run if the goal
@@ -264,6 +279,7 @@ sees one it will ensure it passes the tests:
  let goal git_commit_tested commit =
    let key = sprintf "repo-tested-%s" commit in
    target (memory_exists key);
+   onrun (fun () -> memory_set key "1");
  
    sh "
      git clone %s test
@@ -271,10 +287,7 @@ sees one it will ensure it passes the tests:
      ./configure
      make
      make check
-   " repo_url;
-
-   (* Record that this commit was tested successfully. *)
-   memory_set key "1"
+   " repo_url
  
  every 30 minutes (fun () ->
    let commit = shout "cd %s && git rev-parse HEAD" repo in
@@ -355,10 +368,9 @@ A common pattern is:
 let goal tested version =
   let key = "myapp-tested-" ^ version in
   target (memory_exists key);
+  onrun (fun () -> memory_set key "1");
  
   (* some code to test this version *)
-  memory_set key "1"
 
 Note in that example the value C<1> is arbitrary.  You just want to
 store I<any> value so that a later call to C<memory_exists> will