
A platform-specific dependency is useful for triggering installation of a platform-specific library only on the platform where its needed.
72 lines
2.5 KiB
Racket
72 lines
2.5 KiB
Racket
#lang racket/base
|
|
(require rackunit
|
|
racket/file
|
|
racket/format
|
|
pkg/util
|
|
(prefix-in db: pkg/pnr-db)
|
|
"shelly.rkt"
|
|
"util.rkt")
|
|
|
|
(pkg-tests
|
|
(shelly-begin
|
|
(define pkgs-dir (make-temporary-file "~a-pkgs" 'directory))
|
|
(define db (build-path pkgs-dir "pnr.sqlite"))
|
|
(define pkg-x-dir (build-path pkgs-dir "pkg-x"))
|
|
|
|
(make-directory* pkg-x-dir)
|
|
(call-with-output-file*
|
|
(build-path pkg-x-dir "info.rkt")
|
|
(lambda (o)
|
|
(displayln "#lang setup/infotab" o)
|
|
(write `(define deps '(("pkg-x-windows" #:platform windows)
|
|
("pkg-x-unix" #:platform unix)
|
|
("pkg-x-macosx" #:platform macosx)
|
|
("pkg-x-platform1"
|
|
#:platform
|
|
,(path->string (system-library-subpath #f)))
|
|
("pkg-x-platform2" #:platform #rx".")
|
|
("pkg-x-platform-no" #:platform #rx"no such platform")))
|
|
o)))
|
|
|
|
(parameterize ([db:current-pkg-index-file db])
|
|
(db:set-indexes! '("local"))
|
|
(db:set-pkgs! "local"
|
|
'("pkg-x" "pkg-x-windows" "pkg-x-unix" "pkg-x-macosx"
|
|
"pkg-x-platform1" "pkg-x-platform2")))
|
|
|
|
(define (create-package name)
|
|
(define pkg-name name)
|
|
(define dir (build-path pkgs-dir pkg-name))
|
|
(make-directory* dir)
|
|
(define coll-dir (build-path dir name))
|
|
(make-directory* coll-dir)
|
|
(call-with-output-file*
|
|
(build-path coll-dir "main.rkt")
|
|
(lambda (o)
|
|
(displayln "#lang racket/base" o)))
|
|
(parameterize ([db:current-pkg-index-file db])
|
|
(db:set-pkg! pkg-name "local" "author@place" (path->string dir) "123456" "")))
|
|
|
|
(create-package "pkg-x")
|
|
(create-package "pkg-x-unix")
|
|
(create-package "pkg-x-windows")
|
|
(create-package "pkg-x-macosx")
|
|
(create-package "pkg-x-platform1")
|
|
(create-package "pkg-x-platform2")
|
|
|
|
(with-fake-root
|
|
(shelly-begin
|
|
$ (~a "raco pkg config --set indexes file://" (path->string db))
|
|
$ "racket -e '(require pkg-x)'" =exit> 1
|
|
$ "raco pkg install --deps search-auto pkg-x" =exit> 0
|
|
$ "racket -e '(require pkg-x)'" =exit> 0
|
|
$ (~a "racket -e '(require pkg-x-" (system-type) ")'") =exit> 0
|
|
$ "racket -e '(require pkg-x-platform1)'" =exit> 0
|
|
$ "racket -e '(require pkg-x-platform2)'" =exit> 0
|
|
$ "racket -e '(require pkg-x-platform-no)'" =exit> 1
|
|
$ "raco pkg remove pkg-x"))
|
|
|
|
(delete-directory/files pkgs-dir)))
|
|
|
|
|