File: output.bats

package info (click to toggle)
ruby-build 20260222-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,152 kB
  • sloc: sh: 1,929; ruby: 26; makefile: 19
file content (27 lines) | stat: -rw-r--r-- 1,066 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env bats

load test_helper

@test "print_command" {
  mkdir -p "$TMP"

  cat <<EOF > "$TMP"/definition
print_command ./configure --prefix="\$PREFIX_PATH" --arg='with spaces'
EOF
  # substitute $TMPDIR in command invocations
  TMPDIR="/tmp/" run ruby-build "$TMP"/definition /tmp/path/to/prefix
  assert_output " ./configure \"--prefix=\$TMPDIR/path/to/prefix\" '--arg=with spaces'"
  # doesn't substitute TMPDIR if it didn't come from user's environment
  TMPDIR="" run ruby-build "$TMP"/definition /tmp/path/to/prefix
  assert_output " ./configure --prefix=/tmp/path/to/prefix '--arg=with spaces'"

  cat <<EOF > "$TMP"/definition
print_command install --bindir="$TMP"/home/.local/bin
EOF
  # substitute $HOME in command invocations
  HOME="$TMP"/home TMPDIR="" run ruby-build "$TMP"/definition /tmp/path/to/prefix
  assert_output " install \"--bindir=\$HOME/.local/bin\""
  # do not substitute $HOME if it's root path
  HOME="/" TMPDIR="" run ruby-build "$TMP"/definition /tmp/path/to/prefix
  assert_output " install --bindir=${TMP}/home/.local/bin"
}