a complete git commandline
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#lang racket/base
|
||||
|
||||
(require rackunit
|
||||
"../main.rkt")
|
||||
|
||||
;; The Racket reader parses '-i as the complex number 0-1i. git-grep treats
|
||||
;; that value as the Git -i option when it appears in option position.
|
||||
(check-equal? '-i 0-1i)
|
||||
|
||||
;; Exercise the public argument parser indirectly in a temporary repository.
|
||||
(require racket/file)
|
||||
|
||||
(define tmp (make-temporary-file "git-command-grep-reader~a" 'directory))
|
||||
|
||||
(dynamic-wind
|
||||
void
|
||||
(lambda ()
|
||||
(parameterize ([current-directory tmp])
|
||||
(git 'init)
|
||||
(call-with-output-file "sample.txt"
|
||||
#:exists 'truncate/replace
|
||||
(lambda (out)
|
||||
(displayln "Todo" out)
|
||||
(displayln "other" out)))
|
||||
(git 'add "sample.txt")
|
||||
(define entries (git 'grep '-i "todo"))
|
||||
(check-equal? (length entries) 1)
|
||||
(check-equal? (git-grep-entry-path (car entries)) "sample.txt")
|
||||
(check-equal? (git-grep-entry-line-number (car entries)) 1)
|
||||
(check-equal? (git-grep-entry-line (car entries)) "Todo")))
|
||||
(lambda ()
|
||||
(delete-directory/files tmp #:must-exist? #f)))
|
||||
Reference in New Issue
Block a user