forked from mario-goulart/salmonella
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsalmonella-common.scm
190 lines (163 loc) · 6.64 KB
/
salmonella-common.scm
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
(import irregex)
(use srfi-1 ports files posix)
(define (delete-path . paths)
;; We could simply use delete-directory giving it a truthy value as
;; second argument to make it recursive, but the recursive mode uses
;; find-files, which was broken before
;; ba01911d2644dd8ac40eced46a8451033e565d86. So, we implement a
;; simplified version of ##sys#find-files (find) and
;; delete-directory (rmdir).
(define (find dir)
;; simplified implementation of ##sys#find-files, which was broken
;; before
(let loop ((files (glob (make-pathname dir "?*")))
(all-files '()))
(if (null? files)
all-files
(let ((f (car files))
(rest (cdr files)))
(if (directory? f)
(cond ((member (pathname-file f) '("." ".."))
(loop rest all-files))
((and (symbolic-link? f))
(loop rest (cons f all-files)))
(else
(loop rest
(loop (glob (make-pathname f "?*"))
(cons f all-files)))))
(loop rest (cons f all-files)))))))
(define (rmdir name)
(let ((files (find name)))
(for-each
(lambda (f)
((if (directory? f)
delete-directory
delete-file)
f))
files)
(delete-directory name)))
(for-each (lambda (path)
(when (file-exists? path)
(if (directory? path)
(rmdir path)
(delete-file path))))
paths))
(define (get-egg-dependencies meta-data #!key with-test-dependencies?
with-versions?)
(define (deps key)
(or (and-let* ((d (assq key meta-data)))
(cdr d))
'()))
(map (lambda (dep)
(if with-versions?
dep
(if (pair? dep)
(car dep)
dep)))
(append (deps 'depends)
(deps 'needs)
(if with-test-dependencies?
(deps 'test-depends)
'()))))
(define (cmd-line-arg option args)
;; Returns the argument associated to the command line option OPTION
;; in ARGS or #f if OPTION is not found in ARGS or doesn't have any
;; argument.
(let ((val (any (lambda (arg)
(irregex-match
`(seq ,(->string option) "=" (submatch (* any)))
arg))
args)))
(and val (irregex-match-substring val 1))))
(define (die . msg)
(with-output-to-port (current-error-port)
(lambda ()
(for-each display msg)
(newline)
(flush-output)))
(exit 1))
(define (mktempdir)
;; For compatibility with older chickens.
;; `create-temporary-directory' has been introduced by 4.6.0
(let loop ()
(let ((dir (make-pathname
(current-directory)
(string-append "salmonella-tmp-"
(number->string (random 1000000) 16)))))
(if (file-exists? dir)
(loop)
(begin
(create-directory dir)
dir)))))
(define (usage #!key exit-code epidemy?)
(let ((this (pathname-strip-directory (program-name)))
(port (if (and exit-code (not (zero? exit-code)))
(current-error-port)
(current-output-port))))
(display #<#EOF
#this [ -h | --help ]
#this --version
#this [ [ <options> ] eggs ]
When called without eggs in the command line, salmonella will try to
find a .setup file in the current directory and process it (just like
chicken-install).
<options>:
--log-file=<logfile>
The name for the log file to be generated by salmonella
(default=salmonella.log).
--chicken-installation-prefix=<prefix dir>
If you want to test eggs using a chicken installed on a certain directory,
you can use this option (it should point to the same directory as given to
`PREFIX' when installing CHICKEN). If omitted, salmonella uses CHICKEN
tools from the current runtime's installation prefix.
--chicken-install-args=<install args>
This option can be used customize chicken-install's arguments. You can
use <repo> to indicate where you want the actual repository directory
to be replaced by salmonella.
--eggs-source-dir=<eggs dir>
By default, salmonella fetches eggs from the egg server. If you have a
local copy of eggs code, you can use this option to point to the directory
where they are located.
--eggs-doc-dir=<doc dir>
By default, salmonella checks if documentation for eggs exist by accessing
the CHICKEN wiki. If you have a local copy of the wiki documentation for
eggs, you can use this option to point to the directory where they can be
found.
--keep-repo
For each egg that salmonella tests, it sets the egg installation repository
empty and removes it at the end of its execution. This option makes
salmonella keep the egg installation repository after testing each egg and
after finishing its execution. This option can save a lot of time when
testing several eggs, at the cost of potentially making salmonella unable
to catch dependencies problems.
--skip-eggs=<comma-separated list of eggs to skip>
A comma-separated list of eggs to be skipped.
--repo-dir=<path to repo dir to be used>
Alternative location for the egg installation directory used by salmonella.
By default, salmonella generates a `salmonella-tmp-xxxxx' directory in the
current directory. This option can be useful when used with `--keep-repo'
to reuse egg installation repositories for several salmonella executions.
--clear-chicken-home
Remove Scheme files from <chicken-installation-prefix>/share/chicken.
WARNING: use this option with care. If you don't understand the
consequences of this option, DON'T USE IT. Extra care when you don't
use --chicken-installation-prefix -- in this case --clear-chicken-home
will remove Scheme files from your "host" CHICKEN installation.
This option is only effective when --keep-repo is NOT used.
--verbosity=<number>
A number to indicate salmonella's verbosity level. 0 means practically
silent. 1 is mostly silent and 2 (default) prints some useful information
while salmonella is running.
EOF
port)
(when epidemy?
(display #<#EOF
--instances=<number>
Number of salmonella instances to run in parallel.
--salmonella-prefix=<prefix dir>
Path to the directory where salmonella is installed. The default
value is the same prefix directory as salmonella-epidemy.
EOF
))
(newline)
(when exit-code (exit exit-code))))