You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@yetus.apache.org by aw...@apache.org on 2017/11/10 15:38:45 UTC
[2/2] yetus git commit: YETUS-581. bash 3 throws syntax errors on
coproc statements
YETUS-581. bash 3 throws syntax errors on coproc statements
Signed-off-by: Sean Busbey <bu...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/yetus/repo
Commit: http://git-wip-us.apache.org/repos/asf/yetus/commit/dae92001
Tree: http://git-wip-us.apache.org/repos/asf/yetus/tree/dae92001
Diff: http://git-wip-us.apache.org/repos/asf/yetus/diff/dae92001
Branch: refs/heads/master
Commit: dae92001d2db74a05090a514aa54bc6b63e86434
Parents: 26dd3dd
Author: Allen Wittenauer <aw...@apache.org>
Authored: Mon Nov 6 06:33:25 2017 -0800
Committer: Allen Wittenauer <aw...@apache.org>
Committed: Fri Nov 10 07:38:12 2017 -0800
----------------------------------------------------------------------
precommit/coprocs.d/README.md | 25 +++++++++
precommit/coprocs.d/e_a_r_helper.sh | 34 ++++++++++++
precommit/coprocs.d/process_counter.sh | 47 +++++++++++++++++
precommit/coprocs.d/reaper.sh | 27 ++++++++++
precommit/test-patch.sh | 82 ++++++++---------------------
5 files changed, 156 insertions(+), 59 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/yetus/blob/dae92001/precommit/coprocs.d/README.md
----------------------------------------------------------------------
diff --git a/precommit/coprocs.d/README.md b/precommit/coprocs.d/README.md
new file mode 100755
index 0000000..e960cad
--- /dev/null
+++ b/precommit/coprocs.d/README.md
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#############################
+##
+## bash v4+ coproc routines
+##
+#############################
+
+# bash v3 and lower will treat coproc commands as syntax errors
+# therefore, ALL functions which activate coprocs are located
+# here
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/dae92001/precommit/coprocs.d/e_a_r_helper.sh
----------------------------------------------------------------------
diff --git a/precommit/coprocs.d/e_a_r_helper.sh b/precommit/coprocs.d/e_a_r_helper.sh
new file mode 100755
index 0000000..7b41b24
--- /dev/null
+++ b/precommit/coprocs.d/e_a_r_helper.sh
@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# SHELLDOC-IGNORE
+
+## @description helper function for echo_and_redirect
+## @audience private
+## @stability evolving
+## @replaceable no
+function e_a_r_helper
+{
+ declare logfile=$1
+ shift
+ declare params=("${@}")
+
+ # shellcheck disable=SC2034
+ coproc yrr_coproc {
+ ulimit -Su "${PROC_LIMIT}"
+ yetus_run_and_redirect "${logfile}" "${params[@]}"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/dae92001/precommit/coprocs.d/process_counter.sh
----------------------------------------------------------------------
diff --git a/precommit/coprocs.d/process_counter.sh b/precommit/coprocs.d/process_counter.sh
new file mode 100755
index 0000000..ddd247a
--- /dev/null
+++ b/precommit/coprocs.d/process_counter.sh
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# SHELLDOC-IGNORE
+
+function process_counter_coproc_start
+{
+ if [[ "${OSTYPE}" = Linux && "${DOCKERMODE}" = true ]]; then
+ # this is really only even remotely close to
+ # accurate under Docker, for the time being.
+
+ # shellcheck disable=SC2034
+ coproc process_counter_coproc {
+ declare threadcount
+ declare maxthreadcount
+ declare cmd
+
+ sleep 2
+ while true; do
+ threadcount=$(ps -L -u "${USER_ID}" -o lwp 2>/dev/null | wc -l)
+ if [[ ${threadcount} -gt ${maxthreadcount} ]]; then
+ maxthreadcount="${threadcount}"
+ echo "${maxthreadcount}" > "${PATCH_DIR}/threadcounter.txt"
+ fi
+ read -r -t 2 cmd
+ case "${cmd}" in
+ exit)
+ exit 0
+ ;;
+ esac
+ done
+ }
+ fi
+}
http://git-wip-us.apache.org/repos/asf/yetus/blob/dae92001/precommit/coprocs.d/reaper.sh
----------------------------------------------------------------------
diff --git a/precommit/coprocs.d/reaper.sh b/precommit/coprocs.d/reaper.sh
new file mode 100755
index 0000000..4427989
--- /dev/null
+++ b/precommit/coprocs.d/reaper.sh
@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# SHELLDOC-IGNORE
+
+function reaper_coproc_start
+{
+ if [[ "${REAPER_MODE}" != "off" ]]; then
+ # shellcheck disable=SC2034
+ coproc reaper_coproc {
+ reaper_coproc_func
+ }
+ fi
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/yetus/blob/dae92001/precommit/test-patch.sh
----------------------------------------------------------------------
diff --git a/precommit/test-patch.sh b/precommit/test-patch.sh
index b507101..3d47795 100755
--- a/precommit/test-patch.sh
+++ b/precommit/test-patch.sh
@@ -623,22 +623,6 @@ function compute_unidiff
rm "${tmpfile}"
}
-## @description helper function for echo_and_redirect
-## @audience private
-## @stability evolving
-## @replaceable no
-function e_a_r_helper
-{
- declare logfile=$1
- shift
- declare params=("${@}")
-
- # shellcheck disable=SC2034
- coproc yrr_coproc {
- ulimit -Su "${PROC_LIMIT}"
- yetus_run_and_redirect "${logfile}" "${params[@]}"
- }
-}
## @description Print the command to be executing to the screen. Then
## @description run the command, sending stdout and stderr to the given filename
@@ -685,7 +669,7 @@ function echo_and_redirect
# if bash < 4 (e.g., OS X), just run it
# the ulimit was set earlier
- yetus_run_and_redirect "${logfile}" "${params[@]}"
+ yetus_run_and_redirect "${logfile}" "${@}"
fi
}
@@ -3053,48 +3037,26 @@ function distclean
## @replaceable yes
function start_coprocessors
{
+
+ declare filename
+
# Eventually, we might open this up for plugins
# and other operating environments
# but for now, this is private and only for us
if [[ "${BASH_VERSINFO[0]}" -gt 3 ]]; then
- determine_user
-
- if [[ "${OSTYPE}" = Linux && "${DOCKERMODE}" = true ]]; then
+ for filename in "${BINDIR}/coprocs.d"/*; do
+ # shellcheck disable=SC1091
+ # shellcheck source=coprocs.d/process_counter.sh
+ . "${filename}"
+ done
- # this is really only even remotely close to
- # accurate under Docker, for the time being.
+ determine_user
- # shellcheck disable=SC2034
- coproc process_counter_coproc {
- declare threadcount
- declare maxthreadcount
- declare cmd
+ process_counter_coproc_start
- sleep 2
- while true; do
- threadcount=$(ps -L -u "${USER_ID}" -o lwp 2>/dev/null | wc -l)
- if [[ ${threadcount} -gt ${maxthreadcount} ]]; then
- maxthreadcount="${threadcount}"
- echo "${maxthreadcount}" > "${PATCH_DIR}/threadcounter.txt"
- fi
- read -r -t 2 cmd
- case "${cmd}" in
- exit)
- exit 0
- ;;
- esac
- done
- }
- fi
-
- if [[ "${REAPER_MODE}" != "off" ]]; then
- # shellcheck disable=SC2034
- coproc reaper_coproc {
- reaper_coproc_func
- }
- fi
+ repear_coproc_start
fi
}
@@ -3105,16 +3067,18 @@ function start_coprocessors
## @replaceable yes
function stop_coprocessors
{
- # shellcheck disable=SC2154
- if [[ -n "${process_counter_coproc_PID}" ]]; then
- # shellcheck disable=SC2086
- echo exit >&${process_counter_coproc[1]}
- fi
+ if [[ "${BASH_VERSINFO[0]}" -gt 3 ]]; then
+ # shellcheck disable=SC2154
+ if [[ -n "${process_counter_coproc_PID}" ]]; then
+ # shellcheck disable=SC2086
+ echo exit >&${process_counter_coproc[1]}
+ fi
- #shellcheck disable=SC2154
- if [[ -n "${reaper_coproc_PID}" ]]; then
- # shellcheck disable=SC2086
- echo exit >&${reaper_coproc[1]}
+ #shellcheck disable=SC2154
+ if [[ -n "${reaper_coproc_PID}" ]]; then
+ # shellcheck disable=SC2086
+ echo exit >&${reaper_coproc[1]}
+ fi
fi
}