[thin_check] Spot XML and be helpful.
This commit is contained in:
@@ -19,7 +19,8 @@
|
||||
|
||||
assert-equal
|
||||
assert-eof
|
||||
assert-starts-with)
|
||||
assert-starts-with
|
||||
assert-matches)
|
||||
|
||||
(import
|
||||
(chezscheme)
|
||||
@@ -27,6 +28,7 @@
|
||||
(list-utils)
|
||||
(logging)
|
||||
(process)
|
||||
(regex)
|
||||
(temp-file)
|
||||
(utils)
|
||||
(srfi s8 receive))
|
||||
@@ -215,6 +217,9 @@
|
||||
(dsp ", ")
|
||||
(wrt str)))))
|
||||
|
||||
(define (assert-matches pattern str)
|
||||
(unless ((regex pattern) str)
|
||||
(fail (fmt #f "string should match: " pattern ", " str))))
|
||||
|
||||
)
|
||||
|
||||
|
||||
@@ -111,6 +111,19 @@
|
||||
(with-valid-metadata (md)
|
||||
(thin-check "--clear-needs-check-flag" md)))
|
||||
|
||||
(define-scenario (thin-check tiny-metadata)
|
||||
"Prints helpful message in case XML metadata given"
|
||||
(with-thin-xml (xml)
|
||||
(receive (_ stderr) (run-fail "thin_check" xml)
|
||||
(assert-starts-with "Metadata device/file too small. Is this binary metadata?" stderr))))
|
||||
|
||||
(define-scenario (thin-check spot-accidental-xml-data)
|
||||
"Prints helpful message if XML metadata given"
|
||||
(with-thin-xml (xml)
|
||||
(system (fmt #f "man bash >> " xml))
|
||||
(receive (_ stderr) (run-fail "thin_check" xml)
|
||||
(assert-matches ".*This looks like XML. thin_check only checks the binary metadata format." stderr))))
|
||||
|
||||
;;;-----------------------------------------------------------
|
||||
;;; thin_restore scenarios
|
||||
;;;-----------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user