Improve unix installer tester.

* The installer is a command-line argument.

* Make it work in xterm too, by unsetting TERM.

* Works with version-less directories, from release installers.
This commit is contained in:
Eli Barzilay 2011-10-29 00:16:27 -04:00
parent 98cde53fa0
commit 1eec2b75e3

View File

@ -7,12 +7,15 @@ exec racket "$0" "$@"
(require racket/list racket/file racket/match racket/system) (require racket/list racket/file racket/match racket/system)
(define testdir "/tmp/racket-installer-test")
(define installer "/tmp/r.sh")
(define (err fmt . args) (define (err fmt . args)
(raise-user-error (format "Error: ~a" (apply format fmt args)))) (raise-user-error (format "Error: ~a" (apply format fmt args))))
(define testdir "/tmp/racket-installer-test")
(define installer
(match (current-command-line-arguments)
[(vector installer) installer]
[(vector _ ...) (err "usage: test-installer <instalelr-file-name>")]))
(define (exe name [just-path? #f]) (define (exe name [just-path? #f])
(define path (or (find-executable-path name) (define path (or (find-executable-path name)
(err "no `~a' executable found" name))) (err "no `~a' executable found" name)))
@ -26,8 +29,8 @@ exec racket "$0" "$@"
(when (directory-exists? testdir) (err "test directory exists: ~a" testdir)) (when (directory-exists? testdir) (err "test directory exists: ~a" testdir))
(make-directory testdir) (make-directory testdir)
(current-directory testdir) (current-directory testdir)
;; make identifiable prompts, predictable ls output, safe-for-play home ;; plain interaction, identifiable prompts, safe-for-play home
(void (putenv "PS1" "sh> ") (putenv "COLUMNS" "72") (putenv "HOME" testdir)) (void (putenv "TERM" "dumb") (putenv "PS1" "sh> ") (putenv "HOME" testdir))
(define (transcript) (define (transcript)
;; the test transcript text: ;; the test transcript text:
@ -35,15 +38,22 @@ exec racket "$0" "$@"
;; - `i' is for user input to send ;; - `i' is for user input to send
;; - `r' is for a regexp ;; - `r' is for a regexp
;; - `s' is a nested list to be spliced in ;; - `s' is a nested list to be spliced in
;; - `N' is short for @r{[0-9.]+} ;; - `N' is short for @r{(?:-?[0-9.]+)?}
;; - `...' makes the next match unanchored (so it's similar to a non-greedy ;; - `...' makes the next match unanchored (so it's similar to a non-greedy
;; ".*" regexp) ;; ".*" regexp)
(define (i . xs) `(i . ,xs)) (define (i . xs) `(i . ,xs))
(define (r . xs) `(r . ,xs)) (define (r . xs) `(r . ,xs))
(define (s . xs) `(s . ,xs)) (define (s . xs) `(s . ,xs))
(define break 'break) (define break 'break)
(define N @r{[0-9.]+}) (define N @r{(?:-?[0-9.]+)?})
(define ... '...) (define ... '...)
(define not-recommended
(let ([s (string-append
"*** This is a nightly build: such a unix-style distribution"
" is *not*\n"
"*** recommended because it cannot be used to install multiple"
" versions.\n")])
(format "(?:~a)?" (regexp-quote s))))
@list{ @list{
@; the first few puzzling interactions are testing that we generate the @; the first few puzzling interactions are testing that we generate the
@; right expect code -- which requires regexp and $-quoting. @; right expect code -- which requires regexp and $-quoting.
@ -58,6 +68,8 @@ exec racket "$0" "$@"
[]{}blah*$x* []{}blah*$x*
sh> @i{pwd} sh> @i{pwd}
@testdir @testdir
@; utilities
sh> @i{LS() { ls --width=72 -mF "$@"@""@";" }}
@; proper testing begins here @; proper testing begins here
sh> @i{sh @installer} sh> @i{sh @installer}
This program will extract and install Racket v@|N|. This program will extract and install Racket v@|N|.
@ -72,22 +84,21 @@ exec racket "$0" "$@"
(movable and erasable), possibly with external links into it -- this is (movable and erasable), possibly with external links into it -- this is
often more convenient, especially if you want to install multiple often more convenient, especially if you want to install multiple
versions or keep it in your home directory. versions or keep it in your home directory.
*** This is a nightly build: such a unix-style distribution is *not* @r{@not-recommended}@;
*** recommended because it cannot be used to install multiple versions.
Enter yes/no (default: no) > @i{bleh} Enter yes/no (default: no) > @i{bleh}
Enter yes/no (default: no) > @i{foo} Enter yes/no (default: no) > @i{foo}
Enter yes/no (default: no) > @i{} Enter yes/no (default: no) > @i{}
@|| @||
Where do you want to install the "racket-@N" directory tree? Where do you want to install the "racket@N" directory tree?
1 - /usr/racket-@N [default] 1 - /usr/racket@N [default]
2 - /usr/local/racket-@N 2 - /usr/local/racket@N
3 - ~/racket-@N (@|testdir|/racket-@N) 3 - ~/racket@N (@|testdir|/racket@N)
4 - ./racket-@N (here) 4 - ./racket@N (here)
Or enter a different "racket" directory to install in. Or enter a different "racket" directory to install in.
> @i{4} > @i{4}
@|| @||
Checking the integrity of the binary archive... ok. Checking the integrity of the binary archive... ok.
Unpacking into "@|testdir|/racket-@N" (Ctrl+C to abort)... Unpacking into "@|testdir|/racket@N" (Ctrl+C to abort)...
Done. Done.
@|| @||
If you want to install new system links within the "bin" and If you want to install new system links within the "bin" and
@ -98,9 +109,9 @@ exec racket "$0" "$@"
(default: skip links) > @i{} (default: skip links) > @i{}
@|| @||
Installation complete. Installation complete.
sh> @i{ls -mF} sh> @i{LS}
racket-@|N|/ racket@|N|/
sh> @i{ls -mF racket-*} sh> @i{LS racket*}
README, bin/, collects/, doc/, include/, lib/, man/ README, bin/, collects/, doc/, include/, lib/, man/
sh> @i{sh @installer} sh> @i{sh @installer}
@... @...
@ -109,9 +120,9 @@ exec racket "$0" "$@"
> @i{.} > @i{.}
@|| @||
Checking the integrity of the binary archive... ok. Checking the integrity of the binary archive... ok.
"@|testdir|/racket-@N" exists, delete? @i{n} "@|testdir|/racket@N" exists, delete? @i{n}
Aborting installation. Aborting installation.
sh> @i{ls -mF racket-*} sh> @i{LS racket*}
README, bin/, collects/, doc/, include/, lib/, man/ README, bin/, collects/, doc/, include/, lib/, man/
sh> @i{chmod 000 racket*} sh> @i{chmod 000 racket*}
sh> @i{sh @installer} sh> @i{sh @installer}
@ -121,11 +132,11 @@ exec racket "$0" "$@"
> @i{./} > @i{./}
@|| @||
Checking the integrity of the binary archive... ok. Checking the integrity of the binary archive... ok.
"@|testdir|/racket-@N" exists, delete? @i{y} "@|testdir|/racket@N" exists, delete? @i{y}
Deleting old "@|testdir|/racket-@N"... @; Deleting old "@|testdir|/racket@N"... @;
/bin/rm: cannot remove `@|testdir|/racket-@N': @; /bin/rm: cannot remove `@|testdir|/racket@N': @;
Permission denied Permission denied
Error: could not delete "@|testdir|/racket-@N". Error: could not delete "@|testdir|/racket@N".
sh> @i{chmod 755 racket*} sh> @i{chmod 755 racket*}
sh> @i{sh @installer} sh> @i{sh @installer}
@... @...
@ -134,8 +145,8 @@ exec racket "$0" "$@"
> @i{.} > @i{.}
@|| @||
Checking the integrity of the binary archive... ok. Checking the integrity of the binary archive... ok.
"@|testdir|/racket-@N" exists, delete? @i{y} "@|testdir|/racket@N" exists, delete? @i{y}
Deleting old "@|testdir|/racket-@N"... done. Deleting old "@|testdir|/racket@N"... done.
@... @...
(default: skip links) > @i{.} (default: skip links) > @i{.}
"@|testdir|/bin" does not exist, skipping. "@|testdir|/bin" does not exist, skipping.
@ -167,18 +178,18 @@ exec racket "$0" "$@"
"@|testdir|/share/man/man1" does not exist, skipping. "@|testdir|/share/man/man1" does not exist, skipping.
@|| @||
Installation complete. Installation complete.
sh> @i{ls -mF .} sh> @i{LS .}
R/, bin/, racket-@|N|/ R/, bin/, racket@|N|/
sh> @i{ls -mF R} sh> @i{LS R}
README, bin/, collects/, doc/, include/, lib/, man/ README, bin/, collects/, doc/, include/, lib/, man/
sh> @i{ls -mF bin} sh> @i{LS bin}
@s|{drracket@, gracket, gracket-text@, mred@, mred-text@, mzc@, mzpp@, @s|{drracket@, gracket, gracket-text@, mred@, mred-text@, mzc@, mzpp@,
mzscheme@, mztext@, pdf-slatex@, planet@, plt-games@, plt-help@, mzscheme@, mztext@, pdf-slatex@, planet@, plt-games@, plt-help@,
plt-r5rs@, plt-r6rs@, plt-web-server@, racket@, raco@, scribble@, plt-r5rs@, plt-r6rs@, plt-web-server@, racket@, raco@, scribble@,
setup-plt@, slatex@, slideshow@, swindle@, tex2page@}| setup-plt@, slatex@, slideshow@, swindle@, tex2page@}|
sh> @i{ls -l bin/ra*} sh> @i{LS -l bin/ra*}
lrwxrwxrwx. @... bin/racket -> @|testdir|/R/bin/racket lrwxrwxrwx. @... bin/racket -> @|testdir|/R/bin/racket*
lrwxrwxrwx. @... bin/raco -> @|testdir|/R/bin/raco lrwxrwxrwx. @... bin/raco -> @|testdir|/R/bin/raco*
sh> @i{sh @installer} sh> @i{sh @installer}
@... @...
Enter yes/no (default: no) > @i{} Enter yes/no (default: no) > @i{}
@ -190,8 +201,8 @@ exec racket "$0" "$@"
@break @break
Error: Aborting... Error: Aborting...
(Removing installation files in @|testdir|/R1) (Removing installation files in @|testdir|/R1)
sh> @i{ls -mF} sh> @i{LS}
R/, bin/, racket-@|N|/ R/, bin/, racket@|N|/
sh> @i{sh @installer} sh> @i{sh @installer}
@... @...
Enter yes/no (default: no) > @i{} Enter yes/no (default: no) > @i{}
@ -203,8 +214,8 @@ exec racket "$0" "$@"
@... @...
(default: skip links) > @break (default: skip links) > @break
Error: Aborting... Error: Aborting...
sh> @i{ls -mF} sh> @i{LS}
R/, bin/, mmm/, racket-5.2.0.1/ R/, bin/, mmm/, racket@|N|/
sh> @i{sh @installer} sh> @i{sh @installer}
@... @...
Enter yes/no (default: no) > @i{} Enter yes/no (default: no) > @i{}
@ -223,13 +234,13 @@ exec racket "$0" "$@"
"/usr/local" is not writable, skipping links. "/usr/local" is not writable, skipping links.
@|| @||
Installation complete. Installation complete.
sh> @i{ls -mF} sh> @i{LS}
sh> @i{cd /} sh> @i{cd /}
sh> @i{cd @testdir} sh> @i{cd @testdir}
sh> @i{ls -mF} sh> @i{LS}
README, bin/, collects/, doc/, include/, lib/, man/ README, bin/, collects/, doc/, include/, lib/, man/
sh> @i{rm -rf [a-zR]*} sh> @i{rm -rf [a-zR]*}
sh> @i{ls -mF} sh> @i{LS}
sh> @i{sh @installer} sh> @i{sh @installer}
@... @...
Do you want a Unix-style distribution? Do you want a Unix-style distribution?
@ -261,11 +272,11 @@ exec racket "$0" "$@"
@|| @||
Target Directories: Target Directories:
[e] Executables @|testdir|/bin (will be created) [e] Executables @|testdir|/bin (will be created)
[r] Racket Code @|testdir|/lib/racket-@|N|/collects (will be created) [r] Racket Code @|testdir|/lib/racket@|N|/collects (will be created)
[d] Core Docs @|testdir|/share/racket-@|N|/doc (will be created) [d] Core Docs @|testdir|/share/racket@|N|/doc (will be created)
[l] C Libraries @|testdir|/lib (will be created) [l] C Libraries @|testdir|/lib (will be created)
[h] C headers @|testdir|/include/racket-@|N| (will be created) [h] C headers @|testdir|/include/racket@|N| (will be created)
[o] Extra C Objs @|testdir|/lib/racket-@|N| (will be created) [o] Extra C Objs @|testdir|/lib/racket@|N| (will be created)
[m] Man Pages @|testdir|/share/man (will be created) [m] Man Pages @|testdir|/share/man (will be created)
Enter a letter to change an entry, or enter to continue. Enter a letter to change an entry, or enter to continue.
> @i{z} > @i{z}
@ -273,43 +284,43 @@ exec racket "$0" "$@"
> @i{} > @i{}
@|| @||
Checking the integrity of the binary archive... ok. Checking the integrity of the binary archive... ok.
Unpacking into "@|testdir|/racket-@|N|-tmp-install" (Ctrl+C to abort)... Unpacking into "@|testdir|/racket@|N|-tmp-install" (Ctrl+C to abort)...
Done. Done.
Moving bin -> @|testdir|/bin Moving bin -> @|testdir|/bin
Moving collects -> @|testdir|/lib/racket-@|N|/collects Moving collects -> @|testdir|/lib/racket@|N|/collects
Moving doc -> @|testdir|/share/racket-@|N|/doc Moving doc -> @|testdir|/share/racket@|N|/doc
Moving include -> @|testdir|/include/racket-@|N| Moving include -> @|testdir|/include/racket@|N|
Moving lib -> @|testdir|/lib/racket-@|N| Moving lib -> @|testdir|/lib/racket@|N|
Moving man -> @|testdir|/share/man Moving man -> @|testdir|/share/man
Moving README -> @|testdir|/share/racket-@|N|/doc/README Moving README -> @|testdir|/share/racket@|N|/doc/README
Writing uninstaller at: @|testdir|/bin/racket-uninstall... Writing uninstaller at: @|testdir|/bin/racket-uninstall...
Rewriting configuration file at: @|testdir|/lib/racket-@|N|/@; Rewriting configuration file at: @|testdir|/lib/racket@|N|/@;
collects/config/config.rkt... collects/config/config.rkt...
Recompiling to @|testdir|/lib/racket-@|N|/@; Recompiling to @|testdir|/lib/racket@|N|/@;
collects/config/compiled/config_rkt.zo... collects/config/compiled/config_rkt.zo...
@|| @||
Installation complete. Installation complete.
sh> @i{ls -mF} sh> @i{LS}
bin/, include/, lib/, share/ bin/, include/, lib/, share/
sh> @i{ls -mF bin} sh> @i{LS bin}
drracket*, gracket*, gracket-text*, mred*, mred-text*, mzc*, mzpp*, drracket*, gracket*, gracket-text*, mred*, mred-text*, mzc*, mzpp*,
mzscheme*, mztext*, pdf-slatex*, planet*, plt-games*, plt-help*, mzscheme*, mztext*, pdf-slatex*, planet*, plt-games*, plt-help*,
plt-r5rs*, plt-r6rs*, plt-web-server*, racket*, racket-uninstall*, plt-r5rs*, plt-r6rs*, plt-web-server*, racket*, racket-uninstall*,
raco*, scribble*, setup-plt*, slatex*, slideshow*, swindle*, tex2page* raco*, scribble*, setup-plt*, slatex*, slideshow*, swindle*, tex2page*
sh> @i{ls -mF include && ls -mF lib && ls -mF share} sh> @i{LS include && LS lib && LS share}
racket-@|N|/ racket@|N|/
racket-@|N|/ racket@|N|/
man/, racket-@|N|/ man/, racket@|N|/
sh> @i{ls -mF include/r*} sh> @i{LS include/r*}
escheme.h, ext.exp, mzconfig.h, mzscheme3m.exp, scheme.h, schemef.h, escheme.h, ext.exp, mzconfig.h, mzscheme3m.exp, scheme.h, schemef.h,
schemegc2.h, schemex.h, schemexm.h, schexn.h, schgc2obj.h, schthread.h, schemegc2.h, schemex.h, schemexm.h, schexn.h, schgc2obj.h, schthread.h,
schvers.h, sconfig.h, stypes.h, uconfig.h schvers.h, sconfig.h, stypes.h, uconfig.h
sh> @i{ls -mF lib/r*} sh> @i{LS lib/r*}
buildinfo, collects/, libfit.so*, mzdyn3m.o, starter* buildinfo, collects/, libfit.so*, mzdyn3m.o, starter*
sh> @i{ls -mF share/r* && ls -mF share/r*/doc} sh> @i{LS share/r* && LS share/r*/doc}
doc/ doc/
README, @... xrepl/ README, @... xrepl/
sh> @i{ls -mF share/man && ls -mF share/man/man1} sh> @i{LS share/man && LS share/man/man1}
man1/ man1/
drracket.1, gracket.1, mred.1, mzc.1, mzscheme.1, plt-help.1, racket.1, drracket.1, gracket.1, mred.1, mzc.1, mzscheme.1, plt-help.1, racket.1,
raco.1, setup-plt.1, tex2page.1 raco.1, setup-plt.1, tex2page.1
@ -330,11 +341,11 @@ exec racket "$0" "$@"
@|| @||
Target Directories: Target Directories:
[e] Executables @|testdir|/bin (exists) [e] Executables @|testdir|/bin (exists)
[r] Racket Code @|testdir|/lib/racket-@|N|/collects (exists) [r] Racket Code @|testdir|/lib/racket@|N|/collects (exists)
[d] Core Docs @|testdir|/share/racket-@|N|/doc (exists) [d] Core Docs @|testdir|/share/racket@|N|/doc (exists)
[l] C Libraries @|testdir|/lib (exists) [l] C Libraries @|testdir|/lib (exists)
[h] C headers @|testdir|/include/racket-@|N| (exists) [h] C headers @|testdir|/include/racket@|N| (exists)
[o] Extra C Objs @|testdir|/lib/racket-@|N| (exists) [o] Extra C Objs @|testdir|/lib/racket@|N| (exists)
[m] Man Pages @|testdir|/share/man (exists) [m] Man Pages @|testdir|/share/man (exists)
Enter a letter to change an entry, or enter to continue. Enter a letter to change an entry, or enter to continue.
> @i{m} > @i{m}
@ -342,11 +353,11 @@ exec racket "$0" "$@"
@|| @||
Target Directories: Target Directories:
[e] Executables @|testdir|/bin (exists) [e] Executables @|testdir|/bin (exists)
[r] Racket Code @|testdir|/lib/racket-@|N|/collects (exists) [r] Racket Code @|testdir|/lib/racket@|N|/collects (exists)
[d] Core Docs @|testdir|/share/racket-@|N|/doc (exists) [d] Core Docs @|testdir|/share/racket@|N|/doc (exists)
[l] C Libraries @|testdir|/lib (exists) [l] C Libraries @|testdir|/lib (exists)
[h] C headers @|testdir|/include/racket-@|N| (exists) [h] C headers @|testdir|/include/racket@|N| (exists)
[o] Extra C Objs @|testdir|/lib/racket-@|N| (exists) [o] Extra C Objs @|testdir|/lib/racket@|N| (exists)
[m] Man Pages @|testdir|/m (error: not a directory!) [m] Man Pages @|testdir|/m (error: not a directory!)
Enter a letter to change an entry, or enter to continue. Enter a letter to change an entry, or enter to continue.
> @i{} > @i{}
@ -358,11 +369,11 @@ exec racket "$0" "$@"
@|| @||
Target Directories: Target Directories:
[e] Executables @|testdir|/bin (exists) [e] Executables @|testdir|/bin (exists)
[r] Racket Code @|testdir|/lib/racket-@|N|/collects (exists) [r] Racket Code @|testdir|/lib/racket@|N|/collects (exists)
[d] Core Docs @|testdir|/share/racket-@|N|/doc (exists) [d] Core Docs @|testdir|/share/racket@|N|/doc (exists)
[l] C Libraries @|testdir|/lib (exists) [l] C Libraries @|testdir|/lib (exists)
[h] C headers @|testdir|/include/racket-@|N| (exists) [h] C headers @|testdir|/include/racket@|N| (exists)
[o] Extra C Objs @|testdir|/lib/racket-@|N| (exists) [o] Extra C Objs @|testdir|/lib/racket@|N| (exists)
[m] Man Pages @|testdir|/man (will be created) [m] Man Pages @|testdir|/man (will be created)
Enter a letter to change an entry, or enter to continue. Enter a letter to change an entry, or enter to continue.
> @i{} > @i{}
@ -375,7 +386,7 @@ exec racket "$0" "$@"
Checking the integrity of the binary archive... ok. Checking the integrity of the binary archive... ok.
@... @...
Installation complete. Installation complete.
sh> @i{ls -mF} sh> @i{LS}
bin/, include/, lib/, m, man/, share/ bin/, include/, lib/, m, man/, share/
sh> @i{sh @installer} sh> @i{sh @installer}
@... @...
@ -400,7 +411,7 @@ exec racket "$0" "$@"
Enter a letter to change an entry, or enter to continue. Enter a letter to change an entry, or enter to continue.
> @break > @break
Error: Aborting... Error: Aborting...
sh> @i{ls -mF} sh> @i{LS}
bin/, include/, lib/, m, man/ bin/, include/, lib/, m, man/
sh> @i{exit} sh> @i{exit}
@||}) @||})