1
2
3
4
5
6
7
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
;; Copyright 2006-2017, Matthew Welland.
;;
;; This file is part of Megatest.
;;
;; Megatest is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; Megatest is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with Megatest. If not, see <http://www.gnu.org/licenses/>.
(use json)
(use ducttape-lib)
(define (get-last-runname area-path target)
(let* ((run-data (with-input-from-pipe (conc "megatest -list-runs % -target " target " -fields runs:runname,event_time -dumpmode sexpr -start-dir " area-path)
read)))
|
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
67
|
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
-
-
-
-
+
+
+
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
+
+
+
+
+
+
+
-
+
|
last-name))))
(define (str-first-char->number str)
(char->integer (string-ref str 0)))
;; example of how to set up and write target mappers
;;
(hash-table-set! *target-mappers*
'prefix-contour
(lambda (target run-name area area-path reason contour mode-patt)
(conc contour "/" target)))
(add-target-mapper 'prefix-contour
(lambda (target run-name area area-path reason contour mode-patt)
(conc contour "/" target)))
(hash-table-set! *target-mappers*
'prefix-area-contour
(lambda (target run-name area area-path reason contour mode-patt)
(conc area "/" contour "/" target)))
(add-target-mapper 'prefix-area-contour
(lambda (target run-name area area-path reason contour mode-patt)
(conc area "/" contour "/" target)))
(hash-table-set! *runname-mappers*
'corporate-ww
(lambda (target run-name area area-path reason contour mode-patt)
(print "corporate-ww called with: target=" target " run-name=" run-name " area=" area " area-path=" area-path " reason=" reason " contour=" contour " mode-patt=" mode-patt)
(let* ((last-name (get-last-runname area-path target))
(last-letter (let* ((ch (if (string? last-name)
(let ((len (string-length last-name)))
(substring last-name (- len 1) len))
"a"))
(chnum (str-first-char->number ch))
(a (str-first-char->number "a"))
(z (str-first-char->number "z")))
(if (and (>= chnum a)(<= chnum z))
chnum
#f)))
(next-letter (if last-letter
(list->string
(list
(integer->char
(+ last-letter 1)))) ;; surely there is an easier way?
"a")))
;; (print "last-name: " last-name " last-letter: " last-letter " next-letter: " next-letter)
(conc (seconds->wwdate (current-seconds)) next-letter))))
(add-runname-mapper 'corporate-ww
(lambda (target run-name area area-path reason contour mode-patt)
(print "corporate-ww called with: target=" target " run-name=" run-name " area=" area " area-path=" area-path " reason=" reason " contour=" contour " mode-patt=" mode-patt)
(let* ((last-name (get-last-runname area-path target))
(last-letter (let* ((ch (if (string? last-name)
(let ((len (string-length last-name)))
(substring last-name (- len 1) len))
"a"))
(chnum (str-first-char->number ch))
(a (str-first-char->number "a"))
(z (str-first-char->number "z")))
(if (and (>= chnum a)(<= chnum z))
chnum
#f)))
(next-letter (if last-letter
(list->string
(list
(integer->char
(+ last-letter 1)))) ;; surely there is an easier way?
"a")))
;; (print "last-name: " last-name " last-letter: " last-letter " next-letter: " next-letter)
(conc (seconds->wwdate (current-seconds)) next-letter))))
(hash-table-set! *runname-mappers*
(add-runname-mapper 'auto
'auto
(lambda (target run-name area area-path reason contour mode-patt)
"auto-eh"))
(lambda (target run-name area area-path reason contour mode-patt)
"auto-eh"))
;; run only areas where first letter of area name is "a"
;;
(add-area-checker 'first-letter-a
(lambda (area target contour)
(string-match "^a.*$" area)))
;; (print "Got here!")
|