File: test-cli-extensions.sh

package info (click to toggle)
ostree 2025.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,996 kB
  • sloc: ansic: 70,831; sh: 15,652; xml: 5,007; yacc: 1,236; javascript: 531; makefile: 243; python: 155
file content (36 lines) | stat: -rwxr-xr-x 1,028 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/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'