Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 191 lines (163 sloc) 6.846 kB
23b9a57 @mario-goulart Added `die' and moved `cmd-line-arg' to salmonella-common.scm
authored
1 (import irregex)
56bb9d9 @mario-goulart Added --verbosity command line option
authored
2 (use srfi-1 ports files posix)
23b9a57 @mario-goulart Added `die' and moved `cmd-line-arg' to salmonella-common.scm
authored
3
7b2c0cf @mario-goulart Don't use delete-directory recursively
authored
4 (define (delete-path . paths)
5 ;; We could simply use delete-directory giving it a truthy value as
6 ;; second argument to make it recursive, but the recursive mode uses
7 ;; find-files, which was broken before
8 ;; ba01911d2644dd8ac40eced46a8451033e565d86. So, we implement a
9 ;; simplified version of ##sys#find-files (find) and
10 ;; delete-directory (rmdir).
11
12 (define (find dir)
13 ;; simplified implementation of ##sys#find-files, which was broken
14 ;; before
15 (let loop ((files (glob (make-pathname dir "?*")))
16 (all-files '()))
17 (if (null? files)
18 all-files
19 (let ((f (car files))
20 (rest (cdr files)))
21 (if (directory? f)
22 (cond ((member (pathname-file f) '("." ".."))
23 (loop rest all-files))
24 ((and (symbolic-link? f))
25 (loop rest (cons f all-files)))
26 (else
27 (loop rest
28 (loop (glob (make-pathname f "?*"))
29 (cons f all-files)))))
30 (loop rest (cons f all-files)))))))
31
32 (define (rmdir name)
33 (let ((files (find name)))
34 (for-each
35 (lambda (f)
36 ((cond ((symbolic-link? f) delete-file)
37 ((directory? f) delete-directory)
38 (else delete-file))
39 f))
40 files)
41 (delete-directory name)))
42
43 (for-each (lambda (path)
44 (when (file-exists? path)
45 (if (directory? path)
46 (rmdir path)
47 (delete-file path))))
48 paths))
49
b796452 @mario-goulart Added `with-versions?' keyword parameter to `egg-dependencies'
authored
50 (define (get-egg-dependencies meta-data #!key with-test-dependencies?
51 with-versions?)
b9a1e7c @mario-goulart Added `egg-dependencies'
authored
52 (define (deps key)
53 (or (and-let* ((d (assq key meta-data)))
54 (cdr d))
55 '()))
56 (map (lambda (dep)
b796452 @mario-goulart Added `with-versions?' keyword parameter to `egg-dependencies'
authored
57 (if with-versions?
58 dep
59 (if (pair? dep)
60 (car dep)
61 dep)))
b9a1e7c @mario-goulart Added `egg-dependencies'
authored
62 (append (deps 'depends)
63 (deps 'needs)
64 (if with-test-dependencies?
65 (deps 'test-depends)
66 '()))))
23b9a57 @mario-goulart Added `die' and moved `cmd-line-arg' to salmonella-common.scm
authored
67
68
69 (define (cmd-line-arg option args)
70 ;; Returns the argument associated to the command line option OPTION
71 ;; in ARGS or #f if OPTION is not found in ARGS or doesn't have any
72 ;; argument.
73 (let ((val (any (lambda (arg)
74 (irregex-match
75 `(seq ,(->string option) "=" (submatch (* any)))
76 arg))
77 args)))
78 (and val (irregex-match-substring val 1))))
79
80
81 (define (die . msg)
82 (with-output-to-port (current-error-port)
83 (lambda ()
84 (for-each display msg)
85 (newline)
86 (flush-output)))
87 (exit 1))
56bb9d9 @mario-goulart Added --verbosity command line option
authored
88
89
90 (define (mktempdir)
91 ;; For compatibility with older chickens.
92 ;; `create-temporary-directory' has been introduced by 4.6.0
93 (let loop ()
94 (let ((dir (make-pathname
95 (current-directory)
96 (string-append "salmonella-tmp-"
97 (number->string (random 1000000) 16)))))
98 (if (file-exists? dir)
99 (loop)
100 (begin
101 (create-directory dir)
102 dir)))))
62753cd @mario-goulart -h|--help command line options for salmonella-epidemy
authored
103
104 (define (usage #!key exit-code epidemy?)
8136fb3 @mario-goulart Take the exit-code into account to determine the port to print messag…
authored
105 (let ((this (pathname-strip-directory (program-name)))
106 (port (if (and exit-code (not (zero? exit-code)))
107 (current-error-port)
108 (current-output-port))))
62753cd @mario-goulart -h|--help command line options for salmonella-epidemy
authored
109 (display #<#EOF
110 #this [ -h | --help ]
9ee10f5 @mario-goulart Add --version to usage message
authored
111 #this --version
62753cd @mario-goulart -h|--help command line options for salmonella-epidemy
authored
112 #this [ [ <options> ] eggs ]
113
114 When called without eggs in the command line, salmonella will try to
115 find a .setup file in the current directory and process it (just like
116 chicken-install).
117
118 <options>:
119 --log-file=<logfile>
120 The name for the log file to be generated by salmonella
121 (default=salmonella.log).
122
123 --chicken-installation-prefix=<prefix dir>
124 If you want to test eggs using a chicken installed on a certain directory,
125 you can use this option (it should point to the same directory as given to
126 `PREFIX' when installing CHICKEN). If omitted, salmonella uses CHICKEN
cca5267 @mario-goulart Fix message for --chicken-installation-prefix
authored
127 tools from the current runtime's installation prefix.
62753cd @mario-goulart -h|--help command line options for salmonella-epidemy
authored
128
129 --chicken-install-args=<install args>
130 This option can be used customize chicken-install's arguments. You can
131 use <repo> to indicate where you want the actual repository directory
132 to be replaced by salmonella.
133
134 --eggs-source-dir=<eggs dir>
135 By default, salmonella fetches eggs from the egg server. If you have a
136 local copy of eggs code, you can use this option to point to the directory
137 where they are located.
138
139 --eggs-doc-dir=<doc dir>
140 By default, salmonella checks if documentation for eggs exist by accessing
141 the CHICKEN wiki. If you have a local copy of the wiki documentation for
142 eggs, you can use this option to point to the directory where they can be
143 found.
144
145 --keep-repo
146 For each egg that salmonella tests, it sets the egg installation repository
147 empty and removes it at the end of its execution. This option makes
148 salmonella keep the egg installation repository after testing each egg and
149 after finishing its execution. This option can save a lot of time when
150 testing several eggs, at the cost of potentially making salmonella unable
151 to catch dependencies problems.
152
153 --skip-eggs=<comma-separated list of eggs to skip>
154 A comma-separated list of eggs to be skipped.
155
156 --repo-dir=<path to repo dir to be used>
157 Alternative location for the egg installation directory used by salmonella.
158 By default, salmonella generates a `salmonella-tmp-xxxxx' directory in the
159 current directory. This option can be useful when used with `--keep-repo'
160 to reuse egg installation repositories for several salmonella executions.
161
9379dce @mario-goulart Add --clear-chicken-home command line option
authored
162 --clear-chicken-home
163 Remove Scheme files from <chicken-installation-prefix>/share/chicken.
164 WARNING: use this option with care. If you don't understand the
165 consequences of this option, DON'T USE IT. Extra care when you don't
166 use --chicken-installation-prefix -- in this case --clear-chicken-home
167 will remove Scheme files from your "host" CHICKEN installation.
168 This option is only effective when --keep-repo is NOT used.
169
62753cd @mario-goulart -h|--help command line options for salmonella-epidemy
authored
170 --verbosity=<number>
171 A number to indicate salmonella's verbosity level. 0 means practically
172 silent. 1 is mostly silent and 2 (default) prints some useful information
173 while salmonella is running.
174
175 EOF
8136fb3 @mario-goulart Take the exit-code into account to determine the port to print messag…
authored
176 port)
62753cd @mario-goulart -h|--help command line options for salmonella-epidemy
authored
177 (when epidemy?
178 (display #<#EOF
179
180 --instances=<number>
181 Number of salmonella instances to run in parallel.
182
f3d934a @mario-goulart Add --salmonella-prefix to salmonella-epidemy's help message
authored
183 --salmonella-prefix=<prefix dir>
184 Path to the directory where salmonella is installed. The default
185 value is the same prefix directory as salmonella-epidemy.
186
62753cd @mario-goulart -h|--help command line options for salmonella-epidemy
authored
187 EOF
188 ))
189 (newline)
190 (when exit-code (exit exit-code))))
Something went wrong with that request. Please try again.