From aaa289c7b66ca8012e07dc119c1f4a1b7ede0899 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sat, 16 May 2015 17:15:22 -0600 Subject: [PATCH] tests and repairs for early checks Also, avoid "early" checks when recurring, just in case. --- pkgs/racket-test/tests/pkg/tests-install.rkt | 6 ++++++ pkgs/racket-test/tests/pkg/tests-update.rkt | 6 ++++++ racket/collects/pkg/private/install.rkt | 11 +++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/pkgs/racket-test/tests/pkg/tests-install.rkt b/pkgs/racket-test/tests/pkg/tests-install.rkt index 6840bef428..fe00d967a9 100644 --- a/pkgs/racket-test/tests/pkg/tests-install.rkt +++ b/pkgs/racket-test/tests/pkg/tests-install.rkt @@ -148,6 +148,12 @@ (shelly-install "redundant packages ignored" (~a tmp-dir"pkg-test1/ "tmp-dir"pkg-test1/") $ "racket -e '(require pkg-test1)'") + + (shelly-install "already-installed error before no-such-file error" + "test-pkgs/pkg-test1/" + $ "raco pkg install no-such-dir/pkg-test1.zip" + =exit> 1 + =stderr> #rx"already installed") (shelly-case "conflicting package names disallowed" diff --git a/pkgs/racket-test/tests/pkg/tests-update.rkt b/pkgs/racket-test/tests/pkg/tests-update.rkt index 5e41f2f1ee..e1164b54f1 100644 --- a/pkgs/racket-test/tests/pkg/tests-update.rkt +++ b/pkgs/racket-test/tests/pkg/tests-update.rkt @@ -75,6 +75,12 @@ (finally (delete-directory/files tmp2-dir))) + (shelly-case + "not installed error before file-not-found error" + $ "raco pkg update --user no-such-file.zip" + =exit> 1 + =stderr> #rx"not currently installed") + (shelly-wind $ "mkdir -p test-pkgs/update-test" $ "cp -f test-pkgs/pkg-test1.zip test-pkgs/update-test/pkg-test1.zip" diff --git a/racket/collects/pkg/private/install.rkt b/racket/collects/pkg/private/install.rkt index baec34dc0a..d188f147ff 100644 --- a/racket/collects/pkg/private/install.rkt +++ b/racket/collects/pkg/private/install.rkt @@ -817,6 +817,7 @@ #:update-cache [update-cache (make-hash)] #:catalog-lookup-cache [catalog-lookup-cache (make-hash)] #:remote-checksum-cache [remote-checksum-cache (make-hash)] + #:check-pkg-early? [check-pkg-early? #t] #:updating? [updating? #f] #:quiet? [quiet? #f] #:use-trash? [use-trash? #f] @@ -839,7 +840,9 @@ download-printf) given-descs)) - (define db (read-pkg-db)) + (define db (and (or check-pkg-early? + skip-installed?) + (read-pkg-db))) (define filtered-descs (remove-duplicates @@ -884,6 +887,7 @@ #:update-cache update-cache #:catalog-lookup-cache catalog-lookup-cache #:remote-checksum-cache remote-checksum-cache + #:check-pkg-early? #f #:pre-succeed (lambda () (pre-succeed) (more-pre-succeed)) #:updating? updating? #:quiet? quiet? @@ -1269,6 +1273,7 @@ #:update-cache update-cache #:catalog-lookup-cache catalog-lookup-cache #:remote-checksum-cache remote-checksum-cache + #:check-pkg-early? #f #:quiet? quiet? #:use-trash? use-trash? #:from-command-line? from-command-line? @@ -1295,7 +1300,9 @@ (if (pkg-desc? d) (or (pkg-desc-name d) (package-source->name (pkg-desc-source d) - (pkg-desc-type d))) + (if (eq? 'clone (pkg-desc-type d)) + 'name + (pkg-desc-type d)))) (package-source->name d))) (define info (package-info name wanted? #:db db)) (when (and info