Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
fengzch-das
multibuild
Commits
ae7c595e
Commit
ae7c595e
authored
May 22, 2018
by
Matthew Brett
Browse files
Tests for new suppress functionality
parent
8977eb2b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
7 deletions
+19
-7
tests/test_common_utils.sh
tests/test_common_utils.sh
+19
-7
No files found.
tests/test_common_utils.sh
View file @
ae7c595e
...
@@ -41,6 +41,7 @@ function bad_cmd {
...
@@ -41,6 +41,7 @@ function bad_cmd {
}
}
function
bad_mid_cmd
{
function
bad_mid_cmd
{
# Command returns 0, but errors in the middle
echo
ok
for
now
echo
ok
for
now
false
false
echo
should be bad now
echo
should be bad now
...
@@ -52,14 +53,25 @@ function good_cmd {
...
@@ -52,14 +53,25 @@ function good_cmd {
return
0
return
0
}
}
#
Check
state of
set -e, disable if set
#
Store
state of
options including -e, -x
# https://stackoverflow.com/questions/14564746/in-bash-how-to-get-the-current-status-of-set-x?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
# https://stackoverflow.com/questions/14564746/in-bash-how-to-get-the-current-status-of-set-x?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
using_e
=
${
-//[^e]/
}
ORIG_OPTS
=
$-
set
+e
set
+ex
[
"
$(
suppress bad_cmd
)
"
==
"
$(
printf
"Running bad_cmd
\n
bad"
)
"
]
||
ingest
"suppress bad_cmd"
[
"
$(
suppress bad_cmd
)
"
==
"
$(
printf
"Running bad_cmd
\n
bad"
)
"
]
\
[
"
$(
suppress good_cmd
)
"
==
"Running good_cmd"
]
||
ingest
"suppress good_cmd"
||
ingest
"suppress bad_cmd"
[
"
$(
suppress bad_mid_cmd
)
"
==
"Running bad_mid_cmd"
]
||
ingest
"suppress bad_mid_cmd"
[
"
$(
suppress good_cmd
)
"
==
"Running good_cmd"
]
\
if
[
-n
"
$using_e
"
]
;
then
set
-e
;
fi
||
ingest
"suppress good_cmd"
[
"
$(
suppress bad_mid_cmd
)
"
==
"Running bad_mid_cmd"
]
\
||
ingest
"suppress bad_mid_cmd"
[
"
$(
set
-e
;
suppress bad_cmd
)
"
==
"
$(
printf
"Running bad_cmd
\n
bad"
)
"
]
\
||
ingest
"suppress bad_cmd set -e"
[
"
$(
set
-e
;
suppress good_cmd
)
"
==
"Running good_cmd"
]
||
\
ingest
"suppress good_cmd set -e"
expected
=
"
$(
printf
"Running bad_mid_cmd
\n
ok for now"
)
"
[
"
$(
set
-e
;
suppress bad_mid_cmd
)
"
==
"
$expected
"
]
\
||
ingest
"suppress bad_mid_cmd set -e"
# Reset options
set_opts
$ORIG_OPTS
# On Linux docker containers in travis, can only be x86_64 or i686
# On Linux docker containers in travis, can only be x86_64 or i686
[
"
$(
get_platform
)
"
==
x86_64
]
||
[
"
$(
get_platform
)
"
==
i686
]
||
exit
1
[
"
$(
get_platform
)
"
==
x86_64
]
||
[
"
$(
get_platform
)
"
==
i686
]
||
exit
1
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment