]> code.delx.au - gnu-emacs-elpa/blob - packages/realgud/test/test-bashdb.el
09d066fc0c6a1824891a0cb627db0030fc42a1ec
[gnu-emacs-elpa] / packages / realgud / test / test-bashdb.el
1 (require 'test-simple)
2 (require 'load-relative)
3 (load-file "../realgud/debugger/bashdb/bashdb.el")
4 (load-file "../realgud/debugger/bashdb/core.el")
5 (load-file "../realgud/common/core.el")
6 (load-file "../realgud/common/lang.el")
7
8 (declare-function realgud:expand-file-name-if-exists 'realgud-core)
9
10 (eval-when-compile
11 (defvar test:run-process-save)
12 (defvar realgud:bashdb-minibuffer-history)
13 )
14
15 (declare-function bashdb-parse-cmd-args 'realgud:bashdb)
16 (declare-function bashdb-suggest-invocation 'realgud:bzshdb)
17 (declare-function realgud:bashdb 'realgud:bashdb)
18 (declare-function __FILE__ 'load-relative)
19
20 (test-simple-start)
21 (make-local-variable 'realgud:bashdb-minibuffer-history)
22 (setq realgud:bashdb-minibuffer-history nil)
23
24 ;; Save value realgud:run-process and change it to something we want
25 (setq test:run-process-save (symbol-function 'realgud:run-process))
26 (defun realgud:run-process(debugger-name script-filename cmd-args
27 minibuf-history
28 &optional no-reset)
29 "Fake realgud:run-process used in testing"
30 (note
31 (format "%s %s %s" debugger-name script-filename cmd-args))
32 (assert-equal "bashdb" debugger-name "debugger name gets passed")
33 (let ((expanded-name
34 (realgud:expand-file-name-if-exists "./gcd.sh")))
35 (assert-equal expanded-name script-filename "file name check")
36 (assert-equal (list "-l" (expand-file-name ".") expanded-name "3" "5")
37 (cdr cmd-args) "command args listified")
38 ))
39
40 (note "bashdb-parse-cmd-args")
41 (assert-equal (list nil '("bashdb")
42 (list (realgud:expand-file-name-if-exists "foo")) nil)
43 (bashdb-parse-cmd-args '("bashdb" "foo")))
44 (assert-equal (list nil '("bashdb")
45 (list (realgud:expand-file-name-if-exists "program.sh")
46 "foo") nil)
47 (bashdb-parse-cmd-args
48 '("bashdb" "program.sh" "foo")))
49 (with-current-buffer (find-file "gcd.sh")
50 (shell-script-mode)
51 (assert-matches "bashdb .*gcd.sh$" (bashdb-suggest-invocation "bashdb")))
52
53 (realgud:bashdb "bashdb -l . ./gcd.sh 3 5")
54 ;; Restore the old value of realgud:run-process
55 (fset 'realgud:run-process test:run-process-save)
56
57 (end-tests)