racket/collects/tests/pkg/tests-update-auto.rkt
Matthew Flatt fc54bbba3c pkg: "module name resolver" and "index" -> "catalog"
This termonology change affects lots of function names from `pkg/lib'
and `pkg/db' (former `pkg/pnr-db'), and it also affects some `raco
pkg' commands.

Existing package installations that are marked as 'pnr in a
local configuration are converted automatically to 'catalog, but any
existing "indexes" configuration must be changed to "catalogs".
2013-04-23 08:38:07 -06:00

72 lines
3.1 KiB
Racket

#lang racket/base
(require racket/file
"shelly.rkt"
"util.rkt")
(define (init-update-deps-test)
(shelly-begin
(hash-set! *index-ht-1* "pkg-b"
(hasheq 'checksum
(file->string "test-pkgs/pkg-b-first.plt.CHECKSUM")
'source
"http://localhost:9999/pkg-b-first.plt"))
$ "raco pkg config --set catalogs http://localhost:9990"
$ "raco pkg install pkg-b"
$ "racket -e '(require pkg-b)'" =exit> 42
(hash-set! *index-ht-1* "pkg-b"
(hasheq 'checksum
(file->string "test-pkgs/pkg-b-second.plt.CHECKSUM")
'source
"http://localhost:9999/pkg-b-second.plt"))
(hash-set! *index-ht-1* "pkg-a"
(hasheq 'checksum
(file->string "test-pkgs/pkg-a-first.plt.CHECKSUM")
'source
"http://localhost:9999/pkg-a-first.plt"))))
(pkg-tests
(shelly-case
"create packages"
$ "raco pkg create --format plt test-pkgs/pkg-b-second"
$ "raco pkg create --format plt test-pkgs/pkg-a-first"
$ "raco pkg create --format plt test-pkgs/pkg-a-second")
(with-fake-root
(shelly-case
"update and then remove an auto"
$ "raco pkg config --set catalogs http://localhost:9990"
(hash-set! *index-ht-1* "pkg-b"
(hasheq 'checksum
(file->string "test-pkgs/pkg-b-second.plt.CHECKSUM")
'source
"http://localhost:9999/pkg-b-second.plt"))
(hash-set! *index-ht-1* "pkg-a"
(hasheq 'checksum
(file->string "test-pkgs/pkg-a-first.plt.CHECKSUM")
'source
"http://localhost:9999/pkg-a-first.plt"))
$ "raco pkg install --deps search-auto pkg-b" =exit> 0 <input= "y\n"
$ "raco pkg show -u" =stdout> #rx"Package\\[\\*=auto\\] +Checksum +Source\npkg-a\\* +[a-f0-9]+ \\(catalog pkg-a\\)\npkg-b +[a-f0-9]+ +\\(catalog pkg-b\\)\n"
$ "racket -e '(require pkg-b)'" =exit> 43
$ "racket -e '(require pkg-a)'" =exit> 0
;; remove auto doesn't do anything because everything is needed
$ "raco pkg remove --auto"
$ "raco pkg show -u" =stdout> #rx"Package\\[\\*=auto\\] +Checksum +Source\npkg-a\\* +[a-f0-9]+ \\(catalog pkg-a\\)\npkg-b +[a-f0-9]+ +\\(catalog pkg-b\\)\n"
$ "racket -e '(require pkg-b)'" =exit> 43
$ "racket -e '(require pkg-a)'" =exit> 0
;; pkg-a is now an auto
(hash-set! *index-ht-1* "pkg-a"
(hasheq 'checksum
(file->string "test-pkgs/pkg-a-second.plt.CHECKSUM")
'source
"http://localhost:9999/pkg-a-second.plt"))
$ "raco pkg update -a" =exit> 0
$ "racket -e '(require pkg-a)'" =exit> 43
$ "raco pkg remove pkg-b"
$ "raco pkg show -u" =stdout> #rx"Package\\[\\*=auto\\] +Checksum +Source\npkg-a\\* +[a-f0-9]+ +\\(catalog pkg-a\\)\n"
$ "racket -e '(require pkg-b)'" =exit> 1
;; pkg-a is now not needed
$ "raco pkg remove --auto"
$ "raco pkg show -u" =stdout> " [none]\n"
$ "racket -e '(require pkg-a)'" =exit> 1)))