mirror of
https://github.com/ostreedev/ostree.git
synced 2024-12-25 01:34:34 +03:00
1898019fac
On systems where `coreutils` are built with `--enable-single-binary=symlinks` like Nix, `/usr/bin/env` is symlinked to `/usr/bin/coreutils` and uses `argv[0]` to determine which program to run. Since the `test-cli-extensions.sh` created a new symlink named `ostree-env`, coreutils would be confused about the utility to choose, so running it would fail: ostree-env: unknown program ‘ostree-env’ Try 'ostree-env --help' for more information. Fixes: https://github.com/ostreedev/ostree/issues/2553
37 lines
1.0 KiB
Bash
Executable File
37 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Copyright (C) 2021 Red Hat Inc.
|
|
# SPDX-License-Identifier: LGPL-2.0+
|
|
|
|
set -euo pipefail
|
|
|
|
. $(dirname $0)/libtest.sh
|
|
|
|
echo '1..2'
|
|
|
|
# Test CLI extensions via $PATH. If you change this, you may
|
|
# also want to change the corresponding destructive version in
|
|
# tests/kolainst/destructive/basic-misc.sh
|
|
mkdir -p ./localbin
|
|
ORIG_PATH="${PATH}"
|
|
export PATH="./localbin/:${PATH}"
|
|
echo '#!/bin/sh' >> ./localbin/ostree-env
|
|
echo 'env "$@"' >> ./localbin/ostree-env
|
|
chmod +x ./localbin/ostree-env
|
|
export A_CUSTOM_TEST_FLAG="myvalue"
|
|
${CMD_PREFIX} ostree env >out.txt
|
|
assert_file_has_content out.txt "^A_CUSTOM_TEST_FLAG=myvalue"
|
|
PATH="${ORIG_PATH}"
|
|
export -n A_CUSTOM_TEST_FLAG
|
|
rm -rf -- localbin
|
|
|
|
echo 'ok CLI extension localbin ostree-env'
|
|
|
|
if ${CMD_PREFIX} ostree nosuchcommand 2>err.txt; then
|
|
assert_not_reached "missing CLI extension ostree-nosuchcommand succeeded"
|
|
fi
|
|
assert_file_has_content err.txt "Unknown command 'nosuchcommand'"
|
|
rm -f -- err.txt
|
|
|
|
echo 'ok CLI extension unknown ostree-nosuchcommand'
|