annotate tests/automated/process-tests.el @ 5886:c96000075e49

Be more careful about C integer overflow, #'parse-integer. src/ChangeLog addition: 2015-04-08 Aidan Kehoe <kehoea@parhasard.net> * data.c (parse_integer): Fix a bug in my detecting a C overflow here. tests/ChangeLog addition: 2015-04-08 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el: Add a couple of tests for #'parse-integer to check for a bug just fixed.
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 08 Apr 2015 21:03:18 +0100
parents 7addb3dbe4b4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5764
7addb3dbe4b4 process-tests should work on all POSIX systems.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5687
diff changeset
1 ;;; process-tests.el --- test process execution
7addb3dbe4b4 process-tests should work on all POSIX systems.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5687
diff changeset
2
7addb3dbe4b4 process-tests should work on all POSIX systems.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5687
diff changeset
3 ;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
5533
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
4
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
5 ;; Author: Mats Lidell <matsl@xemacs.org>
5764
7addb3dbe4b4 process-tests should work on all POSIX systems.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5687
diff changeset
6 ;; Maintainer: XEmacs Dev Team <xemacs-beta@xemacs.org>
5533
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
7 ;; Created: 2011
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
8 ;; Keywords: tests
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
9
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
10 ;; This file is part of XEmacs.
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
11
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
12 ;; XEmacs is free software: you can redistribute it and/or modify it
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by the
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
14 ;; Free Software Foundation, either version 3 of the License, or (at your
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
15 ;; option) any later version.
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
16
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
18 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
19 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
20 ;; for more details.
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
21
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
23 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>.
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
24
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
25 ;;; Synched up with: Not in FSF.
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
26
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
27 ;;; Commentary:
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
28
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
29 ;; Test tag support.
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
30 ;; See test-harness.el for instructions on how to run these tests.
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
31
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
32 (require 'test-harness)
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
33
5764
7addb3dbe4b4 process-tests should work on all POSIX systems.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5687
diff changeset
34 ;; Should work on all POSIX systems.
7addb3dbe4b4 process-tests should work on all POSIX systems.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 5687
diff changeset
35 (unless (member system-type '(windows-nt))
5533
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
36 (setenv "LANG" "C")
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
37
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
38 ;; One line output
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
39 (Assert (= 0 (shell-command "echo hello")))
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
40 (Assert (equal "hello" (message-displayed-p t)))
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
41 (with-current-buffer " *Echo Area*"
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
42 (goto-char (point-min))
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
43 (Assert (looking-at "hello")))
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
44
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
45 ;; Two lines. No output in echo area. (GNU resizes minibuffer but we
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
46 ;; haven't implemented that.)
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
47 (message "")
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
48 (Assert (= 0 (shell-command "echo -e \"foo\nbar\n\"")))
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
49 (with-current-buffer " *Echo Area*"
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
50 (Assert (= 0 (buffer-size))))
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
51 (with-current-buffer "*Shell Command Output*"
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
52 (goto-char (point-min))
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
53 (Assert (looking-at "foo"))):
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
54
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
55 (Assert (= 127 (shell-command "unknown_command")))
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
56 (Assert (= 2 (shell-command "exit 2")))
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
57 (Assert (equal "(Shell command failed with code 2 and no output)" (message-displayed-p t)))
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
58
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
59 ;; Output to stderr With error buffer
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
60 (Assert (= 0 (shell-command "echo -e \"foo\nbar\n\" 1>&2" "Output buffer" "Error buffer")))
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
61 (Assert (equal "(Shell command succeeded with some error output)" (message-displayed-p t)))
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
62 (with-current-buffer "Error buffer"
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
63 (goto-char (point-min))
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
64 (Assert (looking-at "foo")))
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
65 (with-current-buffer "Output buffer"
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
66 (Assert (= 0 (buffer-size))))
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
67
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
68 ;; Output to stderr but no error buffer
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
69 (Assert (= 0 (shell-command "echo -e \"foobar\nfoobar\n\" 1>&2" "Output buffer")))
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
70 (with-current-buffer "Output buffer"
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
71 (goto-char (point-min))
11da5b828d10 shell-command and shell-command-on-region API compliant with FSF 23.3.1
Mats Lidell <mats.lidell@cag.se>
parents:
diff changeset
72 (Assert (looking-at "foobar")))
5687
965a9ddc915a Introduce call-process-shell-command from GNU.
Mats Lidell <matsl@xemacs.org>
parents: 5533
diff changeset
73 )
965a9ddc915a Introduce call-process-shell-command from GNU.
Mats Lidell <matsl@xemacs.org>
parents: 5533
diff changeset
74
965a9ddc915a Introduce call-process-shell-command from GNU.
Mats Lidell <matsl@xemacs.org>
parents: 5533
diff changeset
75 ;; call-process-shell-command
965a9ddc915a Introduce call-process-shell-command from GNU.
Mats Lidell <matsl@xemacs.org>
parents: 5533
diff changeset
76 (when (equal system-type 'linux)
965a9ddc915a Introduce call-process-shell-command from GNU.
Mats Lidell <matsl@xemacs.org>
parents: 5533
diff changeset
77 (setenv "LANG" "C")
965a9ddc915a Introduce call-process-shell-command from GNU.
Mats Lidell <matsl@xemacs.org>
parents: 5533
diff changeset
78
965a9ddc915a Introduce call-process-shell-command from GNU.
Mats Lidell <matsl@xemacs.org>
parents: 5533
diff changeset
79 ;; Output one line
965a9ddc915a Introduce call-process-shell-command from GNU.
Mats Lidell <matsl@xemacs.org>
parents: 5533
diff changeset
80 (Assert (= 0 (call-process-shell-command "echo hello")))
965a9ddc915a Introduce call-process-shell-command from GNU.
Mats Lidell <matsl@xemacs.org>
parents: 5533
diff changeset
81
965a9ddc915a Introduce call-process-shell-command from GNU.
Mats Lidell <matsl@xemacs.org>
parents: 5533
diff changeset
82 ;; Output to stderr but no error buffer
965a9ddc915a Introduce call-process-shell-command from GNU.
Mats Lidell <matsl@xemacs.org>
parents: 5533
diff changeset
83 (Assert (= 0 (call-process-shell-command "echo -e \"barefoot\nfoobar\n\" 1>&2" nil "Output buffer")))
965a9ddc915a Introduce call-process-shell-command from GNU.
Mats Lidell <matsl@xemacs.org>
parents: 5533
diff changeset
84 (with-current-buffer "Output buffer"
965a9ddc915a Introduce call-process-shell-command from GNU.
Mats Lidell <matsl@xemacs.org>
parents: 5533
diff changeset
85 (goto-char (point-min))
965a9ddc915a Introduce call-process-shell-command from GNU.
Mats Lidell <matsl@xemacs.org>
parents: 5533
diff changeset
86 (Assert (looking-at "barefoot\n")))
965a9ddc915a Introduce call-process-shell-command from GNU.
Mats Lidell <matsl@xemacs.org>
parents: 5533
diff changeset
87 )