]> ruderich.org/simon Gitweb - coloredstderr/coloredstderr.git/blob - tests/test_environment.sh
update copyright year
[coloredstderr/coloredstderr.git] / tests / test_environment.sh
1 #!/bin/sh
2
3 # Copyright (C) 2013-2015  Simon Ruderich
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 test "x$srcdir" = x && srcdir=.
19 . "$srcdir/lib.sh"
20
21 # Test unexpected values for COLORED_STDERR_PRIVATE_FDS environment variable.
22
23 echo 'Empty fields.'
24 fds=
25 test_program          example example_environment_empty
26 test_program_subshell example example_environment_empty
27 fds=,,,
28 test_program          example example_environment_empty
29 test_program_subshell example example_environment_empty
30 fds=,,,2
31 test_program          example example_environment_empty
32 test_program_subshell example example_environment_empty
33 fds=2,,,
34 test_program          example example_environment
35 test_program_subshell example example_environment
36
37 echo 'Invalid fds.'
38 fds=-20,-30
39 test_program          example example_environment_empty
40 test_program_subshell example example_environment_empty
41 fds=-20,-30,2,
42 test_program          example example_environment
43 test_program_subshell example example_environment
44 fds=-20,-30,2,-1,
45 test_program          example example_environment
46 test_program_subshell example example_environment
47
48 echo 'Test COLORED_STDERR_FDS overwrites COLORED_STDERR_PRIVATE_FDS.'
49 # Additional tests in example_exec.
50
51 fds=
52 COLORED_STDERR_FDS=2,
53 export COLORED_STDERR_FDS
54 test_program          example example_environment
55 test_program_subshell example example_environment
56
57 fds=2,
58 COLORED_STDERR_FDS=
59 export COLORED_STDERR_FDS
60 test_program          example example_environment_empty
61 test_program_subshell example example_environment_empty
62
63 unset COLORED_STDERR_FDS
64
65
66 echo 'Test COLORED_STDERR_IGNORED_BINARIES.'
67
68 if test -x /proc/self/exe; then
69     COLORED_STDERR_IGNORED_BINARIES="$abs_builddir/example"
70     export COLORED_STDERR_IGNORED_BINARIES
71     test_program          example example_environment_empty
72     test_program_subshell example example_environment_empty
73
74     COLORED_STDERR_IGNORED_BINARIES=",some,other,path,,"
75     export COLORED_STDERR_IGNORED_BINARIES
76     test_program          example example_environment
77     test_program_subshell example example_environment
78 fi