Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix return code when subprocess fails #33

Merged
merged 7 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: return 1 when a subprocess fails
  • Loading branch information
git-developer committed Sep 28, 2024
commit d6daf22de9a77e327cfba7ccaac491dc51248fa1
20 changes: 7 additions & 13 deletions AppImageBuilder.test.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@ RUN <<EOR
return 1
}

handle_failure() {
return_code="${1}"
file="${2}"
if [ "${return_code}" = 139 ] && echo "${file}" | grep -q -P -- '-(noble|trixie|bookworm)-'; then
log "Ignoring failure ${return_code} for ${file}" \
"which is currently known to cause a segmentation fault"
else
return "${return_code}"
fi
}

prepare() {
if command -v apt-get >/dev/null; then
apt-get update && apt-get install -y --no-install-recommends libx11-6
Expand All @@ -43,14 +32,19 @@ RUN <<EOR
cancel "Error: No AppImage file found."
fi
prepare
config_path="${HOME}/.config/scc"
mkdir -p "${config_path}"
echo '{}' >"${config_path}/config.json"

echo "${files}" | while read -r file; do
log "${file}"
log "Testing ${file}"
chmod +x "${file}"
rm -rf squashfs-root/
"${file}" --appimage-extract >/dev/null
(
cd squashfs-root/runtime/compat
{ ../../AppRun dependency-check && ../../AppRun daemon --help; } || handle_failure "$?" "${file}"
../../AppRun dependency-check
../../AppRun daemon --help
)
rm -f "${file}"
done
Expand Down
17 changes: 9 additions & 8 deletions scc/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,30 @@

class InvalidArguments(Exception): pass

def run_binary(binary_name: str, argv: list[str]) -> int:
binary = find_binary(binary_name)
child = subprocess.Popen([binary] + argv)
child.communicate()
return child.returncode

def cmd_daemon(argv0, argv):
""" Controls scc-daemon """
# Actually just passes parameters to scc-daemon
scc_daemon = find_binary("scc-daemon")
subprocess.Popen([scc_daemon] + argv).communicate()
return run_binary("scc-daemon", argv)


def help_daemon():
scc_daemon = find_binary("scc-daemon")
subprocess.Popen([scc_daemon, "--help"]).communicate()
return run_binary("scc-daemon", ["--help"])


def cmd_gui(argv0, argv):
""" Starts GUI """
# Passes parameters to sc-controller
scc_daemon = find_binary("sc-controller")
subprocess.Popen([scc_daemon] + argv).communicate()
return run_binary("sc-controller", argv)


def help_gui():
scc_daemon = find_binary("sc-controller")
subprocess.Popen([scc_daemon, "--help"]).communicate()
return run_binary("sc-controller", ["--help"])


def cmd_test_evdev(argv0, argv):
Expand Down