65 lines
2.0 KiB
Racket
65 lines
2.0 KiB
Racket
#lang racket
|
|
|
|
(require rackunit
|
|
racket/file
|
|
linea/read)
|
|
|
|
(define tmp (make-temporary-file "rash-git-cli~a" 'directory))
|
|
|
|
(dynamic-wind
|
|
void
|
|
(λ ()
|
|
(define module-path (build-path tmp "Rash.rkt"))
|
|
|
|
(call-with-output-file module-path
|
|
#:exists 'truncate/replace
|
|
(λ (out)
|
|
(displayln "#lang rash" out)
|
|
(displayln "(require rash-git-cli)" out)))
|
|
|
|
(define module-name `(file ,(path->string module-path)))
|
|
|
|
(parameterize ([current-directory tmp])
|
|
(dynamic-require module-name #f))
|
|
|
|
(define ns (module->namespace module-name))
|
|
(parameterize ([current-directory tmp]
|
|
[current-namespace ns])
|
|
;; In expression mode the same binding remains callable as git-cli's
|
|
;; first-class Git procedure.
|
|
(check-true (eval #'(procedure? git)))
|
|
|
|
;; The Rash line form initializes a repository.
|
|
(define init-line
|
|
(linea-read-syntax 'drracket-interaction
|
|
(open-input-string "git init\n")))
|
|
(eval init-line)
|
|
(check-true (directory-exists? (build-path tmp ".git")))
|
|
|
|
(check-true (eval #'(git 'config 'set! "user.name" "Rash Test")))
|
|
(check-true (eval #'(git 'config 'set! "user.email" "rash@example.invalid")))
|
|
|
|
(call-with-output-file (build-path tmp "test.txt")
|
|
#:exists 'truncate/replace
|
|
(λ (out)
|
|
(displayln "rash" out)))
|
|
|
|
(eval
|
|
(linea-read-syntax 'drracket-interaction
|
|
(open-input-string "git add test.txt\n")))
|
|
|
|
(check-true
|
|
(eval
|
|
(linea-read-syntax 'drracket-interaction
|
|
(open-input-string
|
|
"git commit -m \"Rash commit\"\n"))))
|
|
|
|
(check-equal?
|
|
(eval
|
|
(linea-read-syntax 'drracket-interaction
|
|
(open-input-string "git status\n")))
|
|
'())
|
|
(check-equal? (eval #'(git 'status)) '())))
|
|
(λ ()
|
|
(delete-directory/files tmp #:must-exist? #f)))
|