diff --git a/authority/pom.xml b/authority/pom.xml new file mode 100644 index 0000000..67139fe --- /dev/null +++ b/authority/pom.xml @@ -0,0 +1,49 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 3.1.0 + + + + org.prole + authority + 0.0.1-SNAPSHOT + prole-authority + Minimal Authority service for Prole + + + 21 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-actuator + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/authority/src/main/java/org/prole/authority/AuthorityApplication.java b/authority/src/main/java/org/prole/authority/AuthorityApplication.java new file mode 100644 index 0000000..c8df072 --- /dev/null +++ b/authority/src/main/java/org/prole/authority/AuthorityApplication.java @@ -0,0 +1,11 @@ +package org.prole.authority; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class AuthorityApplication { + public static void main(String[] args) { + SpringApplication.run(AuthorityApplication.class, args); + } +} diff --git a/authority/src/main/java/org/prole/authority/HealthController.java b/authority/src/main/java/org/prole/authority/HealthController.java new file mode 100644 index 0000000..e6eb896 --- /dev/null +++ b/authority/src/main/java/org/prole/authority/HealthController.java @@ -0,0 +1,13 @@ +package org.prole.authority; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HealthController { + + @GetMapping("/health") + public String health() { + return "ok"; + } +} diff --git a/authority/src/main/resources/application.properties b/authority/src/main/resources/application.properties new file mode 100644 index 0000000..73a01e0 --- /dev/null +++ b/authority/src/main/resources/application.properties @@ -0,0 +1,3 @@ +server.port=8080 + +management.endpoints.web.exposure.include=health,info diff --git a/authority/src/test/java/org/prole/authority/AuthorityApplicationTests.java b/authority/src/test/java/org/prole/authority/AuthorityApplicationTests.java new file mode 100644 index 0000000..c42f0dc --- /dev/null +++ b/authority/src/test/java/org/prole/authority/AuthorityApplicationTests.java @@ -0,0 +1,12 @@ +package org.prole.authority; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class AuthorityApplicationTests { + + @Test + void contextLoads() { + } +} diff --git a/docs/layout.md b/docs/layout.md new file mode 100644 index 0000000..40751fb --- /dev/null +++ b/docs/layout.md @@ -0,0 +1,21 @@ +# Repository layout (first-pass) + +This repo is being refactored toward a clearer separation between runtime scripts, reusable shell libraries, operator validation scripts, and tests. + +## Top-level conventions + +- `etc/` + - Runtime/bootstrap/config scripts only. + - May contain thin compatibility shims that forward to new locations. +- `lib/shell/` + - Reusable shell helper libraries intended to be sourced by CLI/runtime scripts. + - Prefer keeping logic here deterministic/testable; keep entrypoint scripts thin. +- `scripts/validation/` + - Operator-run validation/check scripts. + - These may invoke cluster tooling (`kubectl`, etc.), but should source shared helpers from `lib/shell/`. +- `tests/shellspec/` + - Shellspec tests for deterministic helper behavior only (no cluster access). + - Focus areas: config parsing, env fallback resolution, realm normalization, secret precedence, guardrails, command assembly. +- `authority/` + - Minimal Maven-backed Spring Boot service. + - Provides application startup and a basic health endpoint. diff --git a/env.sh b/env.sh index f15680c..08a6a07 100755 --- a/env.sh +++ b/env.sh @@ -3,8 +3,7 @@ # This file is generated by the installer. Source it in new shells, or execute as a wrapper: # "$PROLE_HOME/env.sh" [args…] # shellcheck shell=bash -PROLE_HOME="${PROLE_HOME:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)}" -export PROLE_HOME +export PROLE_HOME="$HOME/dev/prole" export PROLE_CONF="${PROLE_CONF:-$PROLE_HOME/conf}" export PROLE_DATA="${PROLE_DATA:-$HOME/.prole/data}" export PROLE_LOGS="${PROLE_LOGS:-/opt/prole/logs/${USER}}" diff --git a/etc/common_core_lib.sh b/etc/common_core_lib.sh index c104978..65b4a3b 100644 --- a/etc/common_core_lib.sh +++ b/etc/common_core_lib.sh @@ -1,150 +1,6 @@ #!/usr/bin/env bash -# Shared helpers for common core init scripts (ArgoCD, OpenBao, OpenTofu, Garage). -# Responsibilities: -# - handle [-c|--config] early so prole_cfg.sh loads the right prole.cfg -# - parse standard actions/options -# - resolve and apply namespaces consistently +# Compatibility shim: shared shell libraries live in `lib/shell/`. +SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -# Actions supported by all common core scripts -COMMON_CORE_ACTIONS="start|stop|status|restart|initialize|update|reload" - -# Parse -c/--config before loading prole_cfg.sh so PROLE_CONF is set in time. -# Sets: -# COMMON_CORE_CONFIG_PATH - path to prole.cfg (if provided) -# COMMON_CORE_ARGS - original arguments minus -c/--config -common_core_preparse_config() { - COMMON_CORE_CONFIG_PATH="" - COMMON_CORE_ARGS=() - while [[ $# -gt 0 ]]; do - case "$1" in - -c|--config) - shift - if [[ -z "${1:-}" ]]; then - echo "ERROR: -c/--config requires a file path" >&2 - exit 2 - fi - COMMON_CORE_CONFIG_PATH="$1" - ;; - -c=*|--config=*) - COMMON_CORE_CONFIG_PATH="${1#*=}" - ;; - *) - COMMON_CORE_ARGS+=("$1") - ;; - esac - shift - done - - if [[ -n "$COMMON_CORE_CONFIG_PATH" ]]; then - if [[ ! -f "$COMMON_CORE_CONFIG_PATH" ]]; then - echo "ERROR: config file not found: $COMMON_CORE_CONFIG_PATH" >&2 - exit 2 - fi - local cfg_dir - cfg_dir=$(cd "$(dirname "$COMMON_CORE_CONFIG_PATH")" && pwd) - PROLE_CONF="$cfg_dir" - export PROLE_CONF - fi -} - -# Parse standard options and action. -# Sets (always): -# COMMON_CORE_ACTION -# COMMON_CORE_NAMESPACE -# COMMON_CORE_HELP (0/1) -# COMMON_CORE_PARSE_ERROR (empty or message) -common_core_parse_args() { - COMMON_CORE_ACTION="" - COMMON_CORE_NAMESPACE="" - COMMON_CORE_HELP=0 - COMMON_CORE_PARSE_ERROR="" - - while [[ $# -gt 0 ]]; do - case "$1" in - -m|--mode) - shift - prole_set_mode "${1:-}" - ;; - -m=*|--mode=*) - prole_set_mode "${1#*=}" - ;; - -n|--namespace) - shift - if [[ -z "${1:-}" ]]; then - COMMON_CORE_PARSE_ERROR="--namespace requires a value" - break - fi - COMMON_CORE_NAMESPACE="$1" - ;; - -n=*|--namespace=*) - COMMON_CORE_NAMESPACE="${1#*=}" - ;; - start|stop|status|restart|initialize|update|reload) - COMMON_CORE_ACTION="$1" - ;; - -h|--help) - COMMON_CORE_HELP=1 - ;; - --) - shift - break - ;; - *) - if [[ -z "$COMMON_CORE_ACTION" && "$1" != -* ]]; then - COMMON_CORE_ACTION="$1" - else - COMMON_CORE_PARSE_ERROR="Unknown argument: $1" - break - fi - ;; - esac - shift - done - - if [[ -z "$COMMON_CORE_ACTION" && "$COMMON_CORE_HELP" -eq 0 && -z "$COMMON_CORE_PARSE_ERROR" ]]; then - COMMON_CORE_PARSE_ERROR="Action is required (${COMMON_CORE_ACTIONS//|/, })" - fi -} - -common_core_usage() { - local prog="${1:-$0}" - echo "Usage: ${prog##*/} [${COMMON_CORE_ACTIONS//|/|}] [-n namespace] [--mode k3d|k3s|k8s] [-c conf/prole.cfg]" >&2 -} - -# Resolve namespace with precedence: CLI override -> SERVICE_NAMESPACE -> NAMESPACE -> provided default -common_core_resolve_namespace() { - local default_ns="${1:-default}" - local ns="${COMMON_CORE_NAMESPACE:-}" - [[ -z "$ns" && -n "${SERVICE_NAMESPACE:-}" ]] && ns="$SERVICE_NAMESPACE" - [[ -z "$ns" && -n "${NAMESPACE:-}" ]] && ns="$NAMESPACE" - [[ -z "$ns" ]] && ns="$default_ns" - - # In k3s mode, common core services must not default into the `default` namespace. - # If the caller didn't supply an explicit namespace, normalize `default` -> SERVICE_NAMESPACE - # from prole.cfg (Explicit `-n default` is treated as a legacy/mistake and will be corrected). - local mode="${PROLE_MODE:-}" - if declare -F prole_normalize_mode >/dev/null 2>&1; then - mode="$(prole_normalize_mode "$mode")" - fi - if [[ "$mode" == "k3s" && "$ns" == "default" ]]; then - if [[ -n "${SERVICE_NAMESPACE:-}" && "${SERVICE_NAMESPACE}" != "default" ]]; then - ns="$SERVICE_NAMESPACE" - elif [[ -n "${PROLE_NAMESPACE:-}" && "${PROLE_NAMESPACE}" != "default" ]]; then - ns="$PROLE_NAMESPACE" - else - echo "ERROR: k3s mode requires a non-default service namespace. Set SERVICE_NAMESPACE in prole.cfg or pass -n." >&2 - exit 2 - fi - fi - echo "$ns" -} - -# Apply a resolved namespace to both NAMESPACE and SERVICE_NAMESPACE for consistency -common_core_apply_namespace() { - local ns="$1" - if [[ -n "$ns" ]]; then - NAMESPACE="$ns" - SERVICE_NAMESPACE="$ns" - export NAMESPACE SERVICE_NAMESPACE - fi -} +# shellcheck disable=SC1091 +source "$SCRIPT_DIR/../lib/shell/common_core_lib.sh" diff --git a/etc/init_kerberos.sh b/etc/init_kerberos.sh index 9f0e78c..e13fa2c 100755 --- a/etc/init_kerberos.sh +++ b/etc/init_kerberos.sh @@ -1034,7 +1034,12 @@ run_test() { ensure_krb5_conf_configmap apply_krb5_conf_to_test_pod - if [[ -x "$SCRIPT_DIR/init_kerberos_test.sh" ]]; then + local kerberos_check_script="$SCRIPT_DIR/../scripts/validation/check_kerberos.sh" + if [[ ! -x "$kerberos_check_script" ]]; then + kerberos_check_script="$SCRIPT_DIR/init_kerberos_test.sh" + fi + + if [[ -x "$kerberos_check_script" ]]; then local test_samba_dns="${SAMBA_DNS_SERVER:-}" if [[ "${KRB5_AD_PORT_FORWARD}" == "1" ]]; then test_samba_dns="$effective_kdc" @@ -1050,7 +1055,7 @@ run_test() { KRB5_USER="${KERBEROS_TEST_ADMIN_USER:-administrator}" KRB5_PASSWORD="$KRB5_PASSWORD" \ SAMBA_ADMIN_USER="${KERBEROS_TEST_ADMIN_USER:-administrator}" SAMBA_ADMIN_PASSWORD="$KRB5_PASSWORD" \ SAMBA_DNS_SERVER="$test_samba_dns" \ - "$SCRIPT_DIR/init_kerberos_test.sh" test; then + "$kerberos_check_script" test; then return 0 fi @@ -1085,7 +1090,7 @@ run_test() { exit 1 done else - err "init_kerberos_test.sh not found." + err "Kerberos validation script not found (expected $SCRIPT_DIR/../scripts/validation/check_kerberos.sh)." exit 1 fi diff --git a/etc/init_kerberos_test.sh b/etc/init_kerberos_test.sh index 4955a8b..cb7ef5e 100755 --- a/etc/init_kerberos_test.sh +++ b/etc/init_kerberos_test.sh @@ -2,570 +2,13 @@ set -euo pipefail -# init_kerberos_test.sh -# Purpose: -# - Run Kerberos authentication checks inside the in-cluster KDC pod - -# Initialize SCRIPT_DIR +# Compatibility shim: Kerberos validation scripts live under `scripts/validation/`. SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -ORIG_ARGS=("$@") - -# Load env -if [[ -n "${PROLE_HOME:-}" && -f "$PROLE_HOME/env.sh" ]]; then - set -- - # shellcheck disable=SC1090 - source "$PROLE_HOME/env.sh" - set -- "${ORIG_ARGS[@]}" -elif [[ -f "$HOME/.prole/env.sh" ]]; then - set -- - # shellcheck disable=SC1090 - source "$HOME/.prole/env.sh" - set -- "${ORIG_ARGS[@]}" +check_script="$SCRIPT_DIR/../scripts/validation/check_kerberos.sh" +if [[ -x "$check_script" ]]; then + exec "$check_script" "$@" fi -# Load config values from prole.cfg before applying defaults/CLI overrides. -# shellcheck disable=SC1090 -source "$SCRIPT_DIR/prole_cfg.sh" - -if [[ "${1:-}" == "--mode" || "${1:-}" == "-m" ]]; then - prole_set_mode "${2:-}" - shift 2 -elif [[ "${1:-}" == --mode=* || "${1:-}" == -m=* ]]; then - prole_set_mode "${1#*=}" - shift -fi - -ACTION=${1:-test} - -NAMESPACE="${PROLE_NAMESPACE}" -SERVICE_NAMESPACE=${SERVICE_NAMESPACE:-${NAMESPACE}} -KRB5_REALM=${KRB5_REALM:-${REALM:-}} -KRB5_KDC=${KRB5_KDC:-} -KRB5_USER=${KRB5_USER:-${KRB5_USERNAME:-}} -KRB5_PASSWORD=${KRB5_PASSWORD:-} -PROLE_KDC_NAME=${PROLE_KDC_NAME:-auth} -PROLE_KDC_SERVICE=${PROLE_KDC_SERVICE:-auth} -SAMBA_ADMIN_USER=${SAMBA_ADMIN_USER:-} -SAMBA_ADMIN_PASSWORD=${SAMBA_ADMIN_PASSWORD:-} -SAMBA_DNS_SERVER=${SAMBA_DNS_SERVER:-} -KDC_POD_READY_TIMEOUT=${KDC_POD_READY_TIMEOUT:-60} -KDC_POD_READY_RETRIES=${KDC_POD_READY_RETRIES:-5} -PROLE_KDC_PRECHECK_TIMEOUT=${PROLE_KDC_PRECHECK_TIMEOUT:-5} - -ensure_tools() { - for t in kubectl curl jq; do - command -v "$t" >/dev/null || { echo "Missing required tool: $t" >&2; exit 1; } - done -} - -ensure_namespace() { - if ! kubectl get namespace "$NAMESPACE" >/dev/null 2>&1; then - echo "Creating namespace '$NAMESPACE' ..." - kubectl create namespace "$NAMESPACE" >/dev/null 2>&1 || true - fi -} - -write_krb5_conf_to_pod() { - local kdc_ns="$1" - local pod_name="$2" - if [[ -z "$kdc_ns" || -z "$pod_name" ]]; then - return 0 - fi - if [[ -z "$KRB5_REALM" || -z "$KRB5_KDC" ]]; then - return 0 - fi - - local admin_val domain_val tmp - admin_val="${KRB5_ADMIN:-$KRB5_KDC}" - domain_val=$(printf '%s' "$KRB5_REALM" | tr '[:upper:]' '[:lower:]') - - tmp=$(mktemp) - cat >"$tmp" < /etc/krb5.conf' <"$tmp"; then - echo "WARN: Unable to write /etc/krb5.conf in ${pod_name}." >&2 - fi - rm -f "$tmp" -} - -get_ready_kdc_pod() { - local kdc_ns="$1" - kubectl -n "$kdc_ns" wait --for=condition=Ready pod -l "app=${PROLE_KDC_NAME}" --timeout="${KDC_POD_READY_TIMEOUT}s" >/dev/null 2>&1 || true - kubectl -n "$kdc_ns" get pod -l "app=${PROLE_KDC_NAME}" --field-selector=status.phase=Running -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || true -} - -wait_for_kdc_pod() { - local kdc_ns="$1" - local attempt pod - attempt=1 - while [[ $attempt -le $KDC_POD_READY_RETRIES ]]; do - pod=$(get_ready_kdc_pod "$kdc_ns") - if [[ -n "$pod" ]]; then - printf '%s' "$pod" - return 0 - fi - echo "Waiting for KDC pod '${PROLE_KDC_NAME}' to be ready... (${attempt}/${KDC_POD_READY_RETRIES})" >&2 - sleep 2 - attempt=$((attempt + 1)) - done - return 1 -} - -# Return 0 if pod is in CrashLoopBackOff (any container), else 1 -is_pod_crashloop() { - local kdc_ns="$1" - local pod_name="$2" - if [[ -z "$pod_name" ]]; then - return 1 - fi - local reason - reason=$(kubectl -n "$kdc_ns" get pod "$pod_name" -o jsonpath='{range .status.containerStatuses[*]}{.state.waiting.reason}{"\n"}{end}' 2>/dev/null | tr -d '\r' | tr -s '\n' ' ' || true) - if echo "${reason}" | grep -q "CrashLoopBackOff"; then - return 0 - fi - return 1 -} - -debug_kdc_pod() { - local kdc_ns="$1" - local pod_name="$2" - if [[ -z "$pod_name" ]]; then - return 0 - fi - echo "--- describe pod ${pod_name} ---" >&2 - kubectl -n "$kdc_ns" describe pod "$pod_name" 1>&2 || true - echo "--- last 200 log lines from ${pod_name} ---" >&2 - kubectl -n "$kdc_ns" logs "$pod_name" --tail=200 1>&2 || true -} - -kdc_exec() { - local kdc_ns="$1" - local pod_name="$2" - shift 2 - local output="" - if output=$(kubectl -n "$kdc_ns" exec "$pod_name" -- "$@" 2>&1); then - printf '%s' "$output" - return 0 - fi - if echo "$output" | grep -qi "completed pod"; then - return 2 - fi - if echo "$output" | grep -qi "not found"; then - return 2 - fi - echo "$output" >&2 - return 1 -} - -run_samba_join() { - local kdc_ns="$1" - local pod_name="$2" - local domain="$3" - local output="" - if output=$(kubectl -n "$kdc_ns" exec "$pod_name" -- \ - env SAMBA_ADMIN_USER="$SAMBA_ADMIN_USER" SAMBA_ADMIN_PASSWORD="$SAMBA_ADMIN_PASSWORD" \ - SAMBA_DNS_SERVER="$SAMBA_DNS_SERVER" SAMBA_REALM="${KRB5_REALM:-}" \ - /bin/sh -c 'realm_flag=""; [ -n "${SAMBA_REALM}" ] && realm_flag="--realm=${SAMBA_REALM}"; samba-tool domain join "'"$domain"'" MEMBER -U"${SAMBA_ADMIN_USER}%${SAMBA_ADMIN_PASSWORD}" --server="${SAMBA_DNS_SERVER}" ${realm_flag}' 2>&1); then - printf '%s' "$output" - return 0 - fi - if echo "$output" | grep -qi "completed pod"; then - return 2 - fi - if echo "$output" | grep -qi "not found"; then - return 2 - fi - if [[ -n "$output" ]]; then - echo "$output" >&2 - else - echo "samba-tool produced no output." >&2 - fi - return 1 -} - -run_kinit() { - local kdc_ns="$1" - local pod_name="$2" - local output="" - - # Prefer /etc/krb5.conf if it exists, otherwise fallback to /opt/prole-kdc/krb5.conf - local krb5_config="/etc/krb5.conf" - if ! kubectl -n "$kdc_ns" exec "$pod_name" -- ls /etc/krb5.conf >/dev/null 2>&1; then - krb5_config="/opt/prole-kdc/krb5.conf" - fi - - echo "Running kinit for ${KRB5_USER}@${KRB5_REALM} inside ${PROLE_KDC_NAME} (${pod_name}) using ${krb5_config} ..." - if output=$(printf '%s\n' "$KRB5_PASSWORD" | kubectl -n "$kdc_ns" exec -i "$pod_name" -- \ - env KRB5_CONFIG="$krb5_config" kinit "${KRB5_USER}@${KRB5_REALM}" 2>&1); then - printf '%s' "$output" - return 0 - fi - if echo "$output" | grep -qi "completed pod"; then - return 2 - fi - if echo "$output" | grep -qi "not found"; then - return 2 - fi - if [[ -n "$output" ]]; then - echo "$output" >&2 - else - echo "kinit produced no output." >&2 - fi - return 1 -} - -check_samba_connectivity() { - local kdc_ns="$1" - local pod_name="$2" - if [[ -z "$SAMBA_DNS_SERVER" ]]; then - return 0 - fi - - echo "Checking connectivity from ${PROLE_KDC_NAME} to ${SAMBA_DNS_SERVER} ..." - local ports="88 389 445 464" - local port - for port in $ports; do - local out="" - out=$(kubectl -n "$kdc_ns" exec "$pod_name" -- /bin/sh -c "timeout 3 bash -c '&1) || true - if [[ -z "$out" ]]; then - echo "OK: ${SAMBA_DNS_SERVER}:${port}" - else - echo "WARN: ${SAMBA_DNS_SERVER}:${port} unreachable: ${out}" - fi - done -} - -check_kdc_direct_connectivity() { - local kdc_ns="$1" - local pod_name="$2" - local kdc_ip="${AD_DC_IP:-${KDC_ANSIBLE_DETECTED:-${KDC_AUTO_DETECTED:-}}}" - if [[ -z "$kdc_ip" ]]; then - return 0 - fi - - echo "Checking connectivity from ${PROLE_KDC_NAME} to KDC IP ${kdc_ip} ..." - local ports="88 389 445 464" - local port - for port in $ports; do - local out="" - out=$(kubectl -n "$kdc_ns" exec "$pod_name" -- /bin/sh -c "timeout 3 bash -c '&1) || true - if [[ -z "$out" ]]; then - echo "OK: ${kdc_ip}:${port}" - else - echo "WARN: ${kdc_ip}:${port} unreachable: ${out}" - fi - done -} - -openbao_url() { - if [[ -n "${PROLE_OPENBAO_URL:-}" ]]; then - echo "$PROLE_OPENBAO_URL" - return 0 - fi - if prole_is_in_cluster; then - echo "http://openbao.${SERVICE_NAMESPACE:-${NAMESPACE:-default}}.svc.cluster.local:8200" - return 0 - fi - if curl -sS "http://127.0.0.1:8200/v1/sys/health" >/dev/null 2>&1; then - echo "http://127.0.0.1:8200" - return 0 - elif curl -sS "http://127.0.0.1:8200/v1/sys/health" >/dev/null 2>&1; then - echo "http://127.0.0.1:8200" - return 0 - else - echo "" - return 0 - fi -} - -openbao_token() { - if [[ -f "$PROLE_SERVICE/secrets/openbao-root-token" ]]; then - cat "$PROLE_SERVICE/secrets/openbao-root-token" - else - echo "${OPENBAO_ROOT_TOKEN:-}" - fi -} - -fetch_openbao_secret() { - local path="$1" - local key="$2" - local token url - token=$(openbao_token) - url=$(openbao_url) - if [[ -z "$token" || -z "$url" ]]; then - echo "" - return 0 - fi - curl -sS -H "X-Vault-Token: $token" "$url/v1/kv/data/$path" | jq -r ".data.data.\"$key\"" || echo "" -} - -resolve_krb5_password() { - if [[ -z "${KRB5_PASSWORD}" || "${KRB5_PASSWORD}" == '${OPENBAO:'* || "${KRB5_PASSWORD}" == '${PROLE_SECRET:'* ]]; then - local path="prole/${NAMESPACE:-default}/kerberos" - local fetched - fetched=$(fetch_openbao_secret "$path" "password") - if [[ -n "$fetched" && "$fetched" != "null" ]]; then - KRB5_PASSWORD="$fetched" - fi - fi -} - -resolve_samba_vars() { - if [[ -n "${SAMBA_ADMIN_USER}" && -n "${SAMBA_ADMIN_PASSWORD}" && -n "${SAMBA_DNS_SERVER}" ]]; then - return 0 - fi - - # 1. Fallback for DNS server from prole.cfg env (AD_DC_HOST) - if [[ -z "$SAMBA_DNS_SERVER" && -n "${AD_DC_HOST:-}" ]]; then - SAMBA_DNS_SERVER="$AD_DC_HOST" - echo "Using SAMBA_DNS_SERVER=${SAMBA_DNS_SERVER} from AD_DC_HOST" - fi - - # 2. Try to resolve from Ansible inventory if possible - local root - if [[ -n "${PROLE_HOME:-}" && -d "${PROLE_HOME}" ]]; then - root="${PROLE_HOME}" - else - root="${SCRIPT_DIR}/.." - fi - - local vars_file="${root}/infrastructure/inventory/group_vars/ad_dc/vars.yml" - if [[ -f "$vars_file" ]]; then - if [[ -z "$SAMBA_DNS_SERVER" ]]; then - SAMBA_DNS_SERVER=$(awk -F: '/^[[:space:]]*samba_dns_server[[:space:]]*:/ {sub(/^[^:]+:[[:space:]]*/, "", $0); gsub(/"/, "", $0); print $0; exit}' "$vars_file") - fi - if [[ -z "$SAMBA_ADMIN_USER" ]]; then - SAMBA_ADMIN_USER=$(awk -F: '/^[[:space:]]*samba_dns_admin_user[[:space:]]*:/ {sub(/^[^:]+:[[:space:]]*/, "", $0); gsub(/"/, "", $0); print $0; exit}' "$vars_file") - fi - fi - - # 3. Fallback for Admin User - if [[ -z "$SAMBA_ADMIN_USER" ]]; then - if [[ -n "${AD_DC_USER:-}" ]]; then - SAMBA_ADMIN_USER="$AD_DC_USER" - echo "Using SAMBA_ADMIN_USER=${SAMBA_ADMIN_USER} from AD_DC_USER" - else - SAMBA_ADMIN_USER="administrator" - echo "Defaulting SAMBA_ADMIN_USER to administrator" - fi - fi - - # 4. Try to resolve password from Ansible Vault - if [[ -z "$SAMBA_ADMIN_PASSWORD" ]]; then - local vault_file="${root}/infrastructure/inventory/group_vars/ad_dc/vault.yml" - local vault_pass_file="" - if [[ -n "${ANSIBLE_VAULT_PASSWORD_FILE:-}" && -f "${ANSIBLE_VAULT_PASSWORD_FILE}" ]]; then - vault_pass_file="${ANSIBLE_VAULT_PASSWORD_FILE}" - elif [[ -n "${PROLE_HOME:-}" && -f "${PROLE_HOME}/.vault_pass" ]]; then - vault_pass_file="${PROLE_HOME}/.vault_pass" - elif [[ -f "${root}/.vault_pass" ]]; then - vault_pass_file="${root}/.vault_pass" - fi - - if [[ -f "$vault_file" && -n "$vault_pass_file" && -x "$(command -v ansible-vault)" ]]; then - local vault_out - vault_out=$(ansible-vault view "$vault_file" --vault-password-file "$vault_pass_file" 2>/dev/null || true) - if [[ -n "$vault_out" ]]; then - SAMBA_ADMIN_PASSWORD=$(printf '%s\n' "$vault_out" | awk -F: '/^[[:space:]]*vault_samba_dns_admin_pass[[:space:]]*:/ {sub(/^[^:]+:[[:space:]]*/, "", $0); gsub(/"/, "", $0); print $0; exit}') - fi - fi - fi - - # 5. Fallback for Password from OpenBao - if [[ -z "$SAMBA_ADMIN_PASSWORD" ]]; then - local path="prole/${NAMESPACE:-default}/ad_dc" - local fetched - fetched=$(fetch_openbao_secret "$path" "password") - if [[ -n "$fetched" && "$fetched" != "null" ]]; then - SAMBA_ADMIN_PASSWORD="$fetched" - echo "Fetched SAMBA_ADMIN_PASSWORD from OpenBao (${path})" - else - # Try kerberos path as fallback - path="prole/${NAMESPACE:-default}/kerberos" - fetched=$(fetch_openbao_secret "$path" "samba_password") - if [[ -n "$fetched" && "$fetched" != "null" ]]; then - SAMBA_ADMIN_PASSWORD="$fetched" - echo "Fetched SAMBA_ADMIN_PASSWORD from OpenBao (${path}#samba_password)" - fi - fi - fi -} - -join_samba_realm_if_needed() { - local kdc_ns="$1" - local pod_name="$2" - local domain="" - - resolve_samba_vars - - if [[ -z "$SAMBA_ADMIN_USER" || -z "$SAMBA_ADMIN_PASSWORD" || -z "$SAMBA_DNS_SERVER" ]]; then - echo "WARN: Missing Samba join info; skipping samba-tool realm join." - return 0 - fi - - check_samba_connectivity "$kdc_ns" "$pod_name" - - if [[ -n "$KRB5_REALM" ]]; then - domain=$(printf '%s' "$KRB5_REALM" | tr '[:upper:]' '[:lower:]') - fi - if [[ -z "$domain" ]]; then - domain="$SAMBA_DNS_SERVER" - fi - - if kubectl -n "$kdc_ns" exec "$pod_name" -- test -f /var/lib/samba/private/secrets.tdb >/dev/null 2>&1; then - echo "Samba already joined; skipping join." - return 0 - fi - - echo "Joining Samba realm '${domain}' (server ${SAMBA_DNS_SERVER}) ..." - local attempt=1 - while true; do - if run_samba_join "$kdc_ns" "$pod_name" "$domain"; then - return 0 - fi - if [[ $? -eq 2 ]]; then - if [[ $attempt -ge $KDC_POD_READY_RETRIES ]]; then - echo "WARN: KDC pod completed before join could run; skipping samba-tool join." >&2 - return 0 - fi - pod_name=$(wait_for_kdc_pod "$kdc_ns" || true) - if [[ -z "$pod_name" ]]; then - echo "WARN: KDC pod unavailable for samba-tool join." >&2 - return 0 - fi - attempt=$((attempt + 1)) - continue - fi - echo "WARN: samba-tool domain join failed; continuing to Kerberos test." >&2 - return 0 - done -} - -run_test() { - ensure_tools - ensure_namespace - resolve_krb5_password - - # Support both names for the toggle from prole.cfg - local enabled="${KERBEROS_ENABLED:-${ENABLED:-false}}" - if [[ "$enabled" == "false" || "$enabled" == "0" || "$enabled" == "False" ]]; then - echo "Kerberos is disabled (KERBEROS_ENABLED=$enabled). Skipping test." - return 0 - fi - - if [[ -z "$KRB5_REALM" || -z "$KRB5_USER" || -z "$KRB5_PASSWORD" || -z "$KRB5_KDC" ]]; then - echo "ERROR: Missing Kerberos configuration. Ensure KRB5_REALM, KRB5_KDC, KRB5_USER, KRB5_PASSWORD are set." >&2 - exit 1 - fi - - # Quick pre-check: if an existing 'auth' deployment is present but not Available, remove it - # to avoid starting a rollout that is likely to time out on a stale/broken replica set. - local kdc_ns - kdc_ns="${SERVICE_NAMESPACE:-${NAMESPACE:-default}}" - if kubectl -n "$kdc_ns" get deploy "$PROLE_KDC_NAME" >/dev/null 2>&1; then - # Try a fast availability wait; if it fails, treat as unhealthy and clean up before proceeding. - if ! kubectl -n "$kdc_ns" wait --for=condition=Available deploy/"$PROLE_KDC_NAME" --timeout="${PROLE_KDC_PRECHECK_TIMEOUT}s" >/dev/null 2>&1; then - echo "Detected unhealthy '$PROLE_KDC_NAME' deployment in namespace '$kdc_ns'; removing before Kerberos test rollout to avoid timeout..." >&2 - if [[ -x "$SCRIPT_DIR/init_kdc.sh" ]]; then - SERVICE_NAMESPACE="$SERVICE_NAMESPACE" "$SCRIPT_DIR/init_kdc.sh" cleanup || true - else - kubectl -n "$kdc_ns" delete deploy "$PROLE_KDC_NAME" --ignore-not-found || true - kubectl -n "$kdc_ns" delete svc "$PROLE_KDC_SERVICE" --ignore-not-found || true - kubectl -n "$kdc_ns" delete configmap prole-kdc-config --ignore-not-found || true - fi - fi - fi - - if [[ -x "$SCRIPT_DIR/init_kdc.sh" ]]; then - SERVICE_NAMESPACE="$SERVICE_NAMESPACE" KRB5_REALM="$KRB5_REALM" KRB5_KDC="$KRB5_KDC" \ - KRB5_ADMIN="$KRB5_KDC" KRB5_USER="$KRB5_USER" KRB5_PASSWORD="$KRB5_PASSWORD" \ - "$SCRIPT_DIR/init_kdc.sh" update || true - fi - - local pod_name - pod_name=$(wait_for_kdc_pod "$kdc_ns" || true) - if [[ -z "$pod_name" ]]; then - echo "ERROR: KDC pod '${PROLE_KDC_NAME}' not found in namespace '$kdc_ns'. Run init_kdc.sh update first." >&2 - exit 1 - fi - - # If the pod is crashlooping, dump logs and fail fast - if is_pod_crashloop "$kdc_ns" "$pod_name"; then - echo "ERROR: KDC pod '${pod_name}' is in CrashLoopBackOff. Dumping diagnostics..." >&2 - debug_kdc_pod "$kdc_ns" "$pod_name" - exit 1 - fi - - write_krb5_conf_to_pod "$kdc_ns" "$pod_name" - - check_kdc_direct_connectivity "$kdc_ns" "$pod_name" - - join_samba_realm_if_needed "$kdc_ns" "$pod_name" - - echo "Running kinit for ${KRB5_USER}@${KRB5_REALM} inside ${PROLE_KDC_NAME} (${pod_name}) ..." - local attempt=1 - while true; do - if run_kinit "$kdc_ns" "$pod_name"; then - break - fi - if [[ $? -eq 2 ]] || kubectl -n "$kdc_ns" get pod "$pod_name" -o jsonpath='{.status.phase}' 2>/dev/null | grep -qi "Succeeded"; then - if [[ $attempt -ge $KDC_POD_READY_RETRIES ]]; then - echo "ERROR: KDC pod completed before kinit could run." >&2 - exit 1 - fi - pod_name=$(wait_for_kdc_pod "$kdc_ns" || true) - if [[ -z "$pod_name" ]]; then - echo "ERROR: KDC pod unavailable for kinit." >&2 - exit 1 - fi - attempt=$((attempt + 1)) - continue - fi - # If the pod is crashlooping, show logs to aid troubleshooting - if is_pod_crashloop "$kdc_ns" "$pod_name"; then - echo "ERROR: KDC pod '${pod_name}' entered CrashLoopBackOff during kinit. Dumping diagnostics..." >&2 - debug_kdc_pod "$kdc_ns" "$pod_name" - fi - echo "ERROR: kinit failed for ${KRB5_USER}@${KRB5_REALM}." >&2 - exit 1 - done - - echo "Kerberos ticket cache:" - # Determine krb5 config path in the pod similar to run_kinit() - local krb5_config_in_pod="/etc/krb5.conf" - if ! kubectl -n "$kdc_ns" exec "$pod_name" -- ls /etc/krb5.conf >/dev/null 2>&1; then - krb5_config_in_pod="/opt/prole-kdc/krb5.conf" - fi - kubectl -n "$kdc_ns" exec "$pod_name" -- env KRB5_CONFIG="$krb5_config_in_pod" klist || true -} - -case "$ACTION" in - test) - run_test - ;; - cleanup) - echo "No test pods to cleanup (KDC-based test)." - ;; - *) - echo "Usage: $0 {test|cleanup}" >&2 - exit 2 - ;; -esac +echo "ERROR: validation script not found or not executable: $check_script" >&2 +exit 1 diff --git a/infrastructure/roles/k3s/defaults/main.yml b/infrastructure/roles/k3s/defaults/main.yml index f835a34..cc0ddc1 100644 --- a/infrastructure/roles/k3s/defaults/main.yml +++ b/infrastructure/roles/k3s/defaults/main.yml @@ -4,6 +4,11 @@ k3s_state: present k3s_version: "" k3s_guard_token_drift: true +# k3s service startup can be slow on first boot (image pulls, containerd unpacking, etc.). +# The service task is best-effort and then Ansible polls `systemctl is-active` using these knobs. +k3s_service_start_retries: 60 +k3s_service_start_delay: 5 + # Destructive repair/refresh workflow (server only) # A refresh wipes the k3s installation/state to a blank slate but preserves the # join token and CA material so existing agents can rejoin without changing the token. diff --git a/infrastructure/roles/k3s/tasks/cnpg.yml b/infrastructure/roles/k3s/tasks/cnpg.yml index f29d74d..02823c5 100644 --- a/infrastructure/roles/k3s/tasks/cnpg.yml +++ b/infrastructure/roles/k3s/tasks/cnpg.yml @@ -1,13 +1,20 @@ --- +- name: Check if controller has conf/prole.cfg (optional) + ansible.builtin.stat: + path: "{{ role_path }}/../../../conf/prole.cfg" + register: _k3s_prole_cfg_stat + delegate_to: localhost + - name: Load CNPG version from prole.cfg (pinned) ansible.builtin.set_fact: cnpg_version_raw: >- {{ lookup( 'ansible.builtin.ini', - 'CNPG_VERSION section=Global file=' + playbook_dir + '/../../conf/prole.cfg', - default=(k3s_cnpg_version_default | default('1.28.1')) - ) }} + 'CNPG_VERSION section=Global file=' ~ (role_path ~ '/../../../conf/prole.cfg'), + default=(k3s_cnpg_version_default | default('1.28.1')), + errors='ignore' + ) if _k3s_prole_cfg_stat.stat.exists else (k3s_cnpg_version_default | default('1.28.1')) }} - name: Normalize CNPG version ansible.builtin.set_fact: @@ -23,7 +30,13 @@ - name: Load k3s server URL from prole.cfg ansible.builtin.set_fact: - cnpg_prole_k3s_server_cfg: "{{ lookup('ansible.builtin.ini', 'PROLE_K3S_SERVER section=Global file=' + playbook_dir + '/../../conf/prole.cfg', default='') }}" + cnpg_prole_k3s_server_cfg: >- + {{ lookup( + 'ansible.builtin.ini', + 'PROLE_K3S_SERVER section=Global file=' ~ (role_path ~ '/../../../conf/prole.cfg'), + default='', + errors='ignore' + ) if _k3s_prole_cfg_stat.stat.exists else '' }} - name: Resolve k3s API URL for kubectl ansible.builtin.set_fact: diff --git a/infrastructure/roles/k3s/tasks/configure.yml b/infrastructure/roles/k3s/tasks/configure.yml index c66c730..8e3b429 100644 --- a/infrastructure/roles/k3s/tasks/configure.yml +++ b/infrastructure/roles/k3s/tasks/configure.yml @@ -12,9 +12,21 @@ ansible.builtin.set_fact: k3s_service_name: "{{ 'k3s' if k3s_role == 'server' else 'k3s-agent' }}" +- name: Check if controller has conf/prole.cfg (optional) + ansible.builtin.stat: + path: "{{ role_path }}/../../../conf/prole.cfg" + register: _k3s_prole_cfg_stat + delegate_to: localhost + - name: Load service namespace from prole.cfg (controller) ansible.builtin.set_fact: - k3s_prole_service_namespace_cfg: "{{ lookup('ansible.builtin.ini', 'SERVICE_NAMESPACE section=Global file=' + playbook_dir + '/../../conf/prole.cfg', default='') }}" + k3s_prole_service_namespace_cfg: >- + {{ lookup( + 'ansible.builtin.ini', + 'SERVICE_NAMESPACE section=Global file=' ~ (role_path ~ '/../../../conf/prole.cfg'), + default='', + errors='ignore' + ) if _k3s_prole_cfg_stat.stat.exists else '' }} changed_when: false - name: Resolve Kong namespaces from prole.cfg (avoid implicit default namespace) diff --git a/infrastructure/roles/k3s/tasks/install.yml b/infrastructure/roles/k3s/tasks/install.yml index 39e4a53..1c606ba 100644 --- a/infrastructure/roles/k3s/tasks/install.yml +++ b/infrastructure/roles/k3s/tasks/install.yml @@ -510,10 +510,23 @@ register: k3s_bin - name: Ensure k3s service state - ansible.builtin.service: - name: "{{ k3s_service_name }}" - state: "{{ 'started' if k3s_state == 'present' else 'stopped' }}" - enabled: "{{ k3s_state == 'present' }}" + block: + - name: Start/stop k3s service (best-effort) + ansible.builtin.service: + name: "{{ k3s_service_name }}" + state: "{{ 'started' if k3s_state == 'present' else 'stopped' }}" + enabled: "{{ k3s_state == 'present' }}" + register: _k3s_service_manage + failed_when: false + + - name: Wait for k3s service to become active + ansible.builtin.command: "systemctl is-active --quiet {{ k3s_service_name }}" + register: _k3s_service_active + until: _k3s_service_active.rc == 0 + retries: "{{ k3s_service_start_retries | default(60) }}" + delay: "{{ k3s_service_start_delay | default(5) }}" + changed_when: false + when: k3s_state == 'present' when: k3s_service.stat.exists or k3s_bin.stat.exists - name: Flush k3s restart handler before Kubernetes operations diff --git a/mock_val/common_core_lib.sh b/mock_val/common_core_lib.sh index 1cf5b63..65b4a3b 100644 --- a/mock_val/common_core_lib.sh +++ b/mock_val/common_core_lib.sh @@ -1,132 +1,6 @@ #!/usr/bin/env bash -# Shared helpers for common core init scripts (ArgoCD, OpenBao, OpenTofu, Garage). -# Responsibilities: -# - handle [-c|--config] early so prole_cfg.sh loads the right prole.cfg -# - parse standard actions/options -# - resolve and apply namespaces consistently +# Compatibility shim: shared shell libraries live in `lib/shell/`. +SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -# Actions supported by all common core scripts -COMMON_CORE_ACTIONS="start|stop|status|restart|initialize|update|reload" - -# Parse -c/--config before loading prole_cfg.sh so PROLE_CONF is set in time. -# Sets: -# COMMON_CORE_CONFIG_PATH - path to prole.cfg (if provided) -# COMMON_CORE_ARGS - original arguments minus -c/--config -common_core_preparse_config() { - COMMON_CORE_CONFIG_PATH="" - COMMON_CORE_ARGS=() - while [[ $# -gt 0 ]]; do - case "$1" in - -c|--config) - shift - if [[ -z "${1:-}" ]]; then - echo "ERROR: -c/--config requires a file path" >&2 - exit 2 - fi - COMMON_CORE_CONFIG_PATH="$1" - ;; - -c=*|--config=*) - COMMON_CORE_CONFIG_PATH="${1#*=}" - ;; - *) - COMMON_CORE_ARGS+=("$1") - ;; - esac - shift - done - - if [[ -n "$COMMON_CORE_CONFIG_PATH" ]]; then - if [[ ! -f "$COMMON_CORE_CONFIG_PATH" ]]; then - echo "ERROR: config file not found: $COMMON_CORE_CONFIG_PATH" >&2 - exit 2 - fi - local cfg_dir - cfg_dir=$(cd "$(dirname "$COMMON_CORE_CONFIG_PATH")" && pwd) - PROLE_CONF="$cfg_dir" - export PROLE_CONF - fi -} - -# Parse standard options and action. -# Sets (always): -# COMMON_CORE_ACTION -# COMMON_CORE_NAMESPACE -# COMMON_CORE_HELP (0/1) -# COMMON_CORE_PARSE_ERROR (empty or message) -common_core_parse_args() { - COMMON_CORE_ACTION="" - COMMON_CORE_NAMESPACE="" - COMMON_CORE_HELP=0 - COMMON_CORE_PARSE_ERROR="" - - while [[ $# -gt 0 ]]; do - case "$1" in - -m|--mode) - shift - prole_set_mode "${1:-}" - ;; - -m=*|--mode=*) - prole_set_mode "${1#*=}" - ;; - -n|--namespace) - shift - if [[ -z "${1:-}" ]]; then - COMMON_CORE_PARSE_ERROR="--namespace requires a value" - break - fi - COMMON_CORE_NAMESPACE="$1" - ;; - -n=*|--namespace=*) - COMMON_CORE_NAMESPACE="${1#*=}" - ;; - start|stop|status|restart|initialize|update|reload) - COMMON_CORE_ACTION="$1" - ;; - -h|--help) - COMMON_CORE_HELP=1 - ;; - --) - shift - break - ;; - *) - if [[ -z "$COMMON_CORE_ACTION" && "$1" != -* ]]; then - COMMON_CORE_ACTION="$1" - else - COMMON_CORE_PARSE_ERROR="Unknown argument: $1" - break - fi - ;; - esac - shift - done - - if [[ -z "$COMMON_CORE_ACTION" && "$COMMON_CORE_HELP" -eq 0 && -z "$COMMON_CORE_PARSE_ERROR" ]]; then - COMMON_CORE_PARSE_ERROR="Action is required (${COMMON_CORE_ACTIONS//|/, })" - fi -} - -common_core_usage() { - local prog="${1:-$0}" - echo "Usage: ${prog##*/} [${COMMON_CORE_ACTIONS//|/|}] [-n namespace] [--mode k3d|k3s|k8s] [-c conf/prole.cfg]" >&2 -} - -# Resolve namespace with precedence: CLI override -> SERVICE_NAMESPACE -> NAMESPACE -> provided default -common_core_resolve_namespace() { - local default_ns="${1:-default}" - local ns="${COMMON_CORE_NAMESPACE:-}" - [[ -z "$ns" && -n "${SERVICE_NAMESPACE:-}" ]] && ns="$SERVICE_NAMESPACE" - [[ -z "$ns" && -n "${NAMESPACE:-}" ]] && ns="$NAMESPACE" - [[ -z "$ns" ]] && ns="$default_ns" - echo "$ns" -} - -# Apply a resolved namespace to both NAMESPACE and SERVICE_NAMESPACE for consistency -common_core_apply_namespace() { - local ns="$1" - if [[ -n "$ns" ]]; then - NAMESPACE="$ns" - SERVICE_NAMESPACE="$ns" - export NAMESPACE SERVICE_NAMESPACE - fi -} +# shellcheck disable=SC1091 +source "$SCRIPT_DIR/../lib/shell/common_core_lib.sh" diff --git a/mock_val/init_kerberos.sh b/mock_val/init_kerberos.sh index dbe489c..bce7f7c 100755 --- a/mock_val/init_kerberos.sh +++ b/mock_val/init_kerberos.sh @@ -1011,7 +1011,12 @@ run_test() { ensure_krb5_conf_configmap apply_krb5_conf_to_test_pod - if [[ -x "$SCRIPT_DIR/init_kerberos_test.sh" ]]; then + local kerberos_check_script="$SCRIPT_DIR/../scripts/validation/check_kerberos.sh" + if [[ ! -x "$kerberos_check_script" ]]; then + kerberos_check_script="$SCRIPT_DIR/init_kerberos_test.sh" + fi + + if [[ -x "$kerberos_check_script" ]]; then local test_samba_dns="${SAMBA_DNS_SERVER:-}" if [[ "${KRB5_AD_PORT_FORWARD}" == "1" ]]; then test_samba_dns="$effective_kdc" @@ -1027,7 +1032,7 @@ run_test() { KRB5_USER="${KERBEROS_TEST_ADMIN_USER:-administrator}" KRB5_PASSWORD="$KRB5_PASSWORD" \ SAMBA_ADMIN_USER="${KERBEROS_TEST_ADMIN_USER:-administrator}" SAMBA_ADMIN_PASSWORD="$KRB5_PASSWORD" \ SAMBA_DNS_SERVER="$test_samba_dns" \ - "$SCRIPT_DIR/init_kerberos_test.sh" test; then + "$kerberos_check_script" test; then return 0 fi @@ -1062,7 +1067,7 @@ run_test() { exit 1 done else - err "init_kerberos_test.sh not found." + err "Kerberos validation script not found (expected $SCRIPT_DIR/../scripts/validation/check_kerberos.sh)." exit 1 fi diff --git a/pom.xml b/pom.xml index a95d08f..ac359dd 100644 --- a/pom.xml +++ b/pom.xml @@ -19,6 +19,8 @@ 24 1.0.0 + false + false @@ -196,6 +198,48 @@ org.springframework.boot spring-boot-maven-plugin + + true + + + + + org.codehaus.mojo + exec-maven-plugin + 3.5.0 + + + shellspec + test + + exec + + + ${skip.shellspec} + bash + + ${project.basedir}/tests/shellspec/run.sh + + + + + authority + verify + + exec + + + ${skip.authority} + mvn + + -f + ${project.basedir}/authority/pom.xml + clean + test + + + + diff --git a/prole-db/.version b/prole-db/.version index e3b5acb..615088b 100644 --- a/prole-db/.version +++ b/prole-db/.version @@ -1 +1 @@ -107 \ No newline at end of file +108 \ No newline at end of file diff --git a/scripts/validation/check_kerberos.sh b/scripts/validation/check_kerberos.sh new file mode 100755 index 0000000..ed9045a --- /dev/null +++ b/scripts/validation/check_kerberos.sh @@ -0,0 +1,582 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# check_kerberos.sh +# Purpose: +# - Run Kerberos authentication checks inside the in-cluster KDC pod + +# Initialize SCRIPT_DIR +SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +ETC_DIR=$(cd "$SCRIPT_DIR/../../etc" && pwd) +LIB_SHELL_DIR=$(cd "$SCRIPT_DIR/../../lib/shell" && pwd) + +ORIG_ARGS=("$@") + +# Load env +if [[ -n "${PROLE_HOME:-}" && -f "$PROLE_HOME/env.sh" ]]; then + set -- + # shellcheck disable=SC1090 + source "$PROLE_HOME/env.sh" + set -- "${ORIG_ARGS[@]}" +elif [[ -f "$HOME/.prole/env.sh" ]]; then + set -- + # shellcheck disable=SC1090 + source "$HOME/.prole/env.sh" + set -- "${ORIG_ARGS[@]}" +fi + +# Load config values from prole.cfg before applying defaults/CLI overrides. +# shellcheck disable=SC1090 +source "$ETC_DIR/prole_cfg.sh" + +# shellcheck disable=SC1090 +source "$LIB_SHELL_DIR/prole_env.sh" +# shellcheck disable=SC1090 +source "$LIB_SHELL_DIR/prole_secrets.sh" +# shellcheck disable=SC1090 +source "$LIB_SHELL_DIR/prole_string.sh" +# shellcheck disable=SC1090 +source "$LIB_SHELL_DIR/prole_yaml.sh" + +if [[ "${1:-}" == "--mode" || "${1:-}" == "-m" ]]; then + prole_set_mode "${2:-}" + shift 2 +elif [[ "${1:-}" == --mode=* || "${1:-}" == -m=* ]]; then + prole_set_mode "${1#*=}" + shift +fi + +ACTION=${1:-test} + +NAMESPACE="${PROLE_NAMESPACE}" +SERVICE_NAMESPACE=${SERVICE_NAMESPACE:-${NAMESPACE}} +KRB5_REALM=${KRB5_REALM:-${REALM:-}} +KRB5_KDC=${KRB5_KDC:-} +KRB5_USER=${KRB5_USER:-${KRB5_USERNAME:-}} +KRB5_PASSWORD=${KRB5_PASSWORD:-} +PROLE_KDC_NAME=${PROLE_KDC_NAME:-auth} +PROLE_KDC_SERVICE=${PROLE_KDC_SERVICE:-auth} +SAMBA_ADMIN_USER=${SAMBA_ADMIN_USER:-} +SAMBA_ADMIN_PASSWORD=${SAMBA_ADMIN_PASSWORD:-} +SAMBA_DNS_SERVER=${SAMBA_DNS_SERVER:-} +KDC_POD_READY_TIMEOUT=${KDC_POD_READY_TIMEOUT:-60} +KDC_POD_READY_RETRIES=${KDC_POD_READY_RETRIES:-5} +PROLE_KDC_PRECHECK_TIMEOUT=${PROLE_KDC_PRECHECK_TIMEOUT:-5} + +KRB5_REALM=$(prole_normalize_realm "${KRB5_REALM:-}") + +ensure_tools() { + for t in kubectl curl jq; do + command -v "$t" >/dev/null || { echo "Missing required tool: $t" >&2; exit 1; } + done +} + +ensure_namespace() { + if ! kubectl get namespace "$NAMESPACE" >/dev/null 2>&1; then + echo "Creating namespace '$NAMESPACE' ..." + kubectl create namespace "$NAMESPACE" >/dev/null 2>&1 || true + fi +} + +write_krb5_conf_to_pod() { + local kdc_ns="$1" + local pod_name="$2" + if [[ -z "$kdc_ns" || -z "$pod_name" ]]; then + return 0 + fi + if [[ -z "$KRB5_REALM" || -z "$KRB5_KDC" ]]; then + return 0 + fi + + local admin_val domain_val tmp + admin_val="${KRB5_ADMIN:-$KRB5_KDC}" + domain_val=$(printf '%s' "$KRB5_REALM" | tr '[:upper:]' '[:lower:]') + + tmp=$(mktemp) + cat >"$tmp" < /etc/krb5.conf' <"$tmp"; then + echo "WARN: Unable to write /etc/krb5.conf in ${pod_name}." >&2 + fi + rm -f "$tmp" +} + +get_ready_kdc_pod() { + local kdc_ns="$1" + kubectl -n "$kdc_ns" wait --for=condition=Ready pod -l "app=${PROLE_KDC_NAME}" --timeout="${KDC_POD_READY_TIMEOUT}s" >/dev/null 2>&1 || true + kubectl -n "$kdc_ns" get pod -l "app=${PROLE_KDC_NAME}" --field-selector=status.phase=Running -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || true +} + +wait_for_kdc_pod() { + local kdc_ns="$1" + local attempt pod + attempt=1 + while [[ $attempt -le $KDC_POD_READY_RETRIES ]]; do + pod=$(get_ready_kdc_pod "$kdc_ns") + if [[ -n "$pod" ]]; then + printf '%s' "$pod" + return 0 + fi + echo "Waiting for KDC pod '${PROLE_KDC_NAME}' to be ready... (${attempt}/${KDC_POD_READY_RETRIES})" >&2 + sleep 2 + attempt=$((attempt + 1)) + done + return 1 +} + +# Return 0 if pod is in CrashLoopBackOff (any container), else 1 +is_pod_crashloop() { + local kdc_ns="$1" + local pod_name="$2" + if [[ -z "$pod_name" ]]; then + return 1 + fi + local reason + reason=$(kubectl -n "$kdc_ns" get pod "$pod_name" -o jsonpath='{range .status.containerStatuses[*]}{.state.waiting.reason}{"\n"}{end}' 2>/dev/null | tr -d '\r' | tr -s '\n' ' ' || true) + if echo "${reason}" | grep -q "CrashLoopBackOff"; then + return 0 + fi + return 1 +} + +debug_kdc_pod() { + local kdc_ns="$1" + local pod_name="$2" + if [[ -z "$pod_name" ]]; then + return 0 + fi + echo "--- describe pod ${pod_name} ---" >&2 + kubectl -n "$kdc_ns" describe pod "$pod_name" 1>&2 || true + echo "--- last 200 log lines from ${pod_name} ---" >&2 + kubectl -n "$kdc_ns" logs "$pod_name" --tail=200 1>&2 || true +} + +kdc_exec() { + local kdc_ns="$1" + local pod_name="$2" + shift 2 + local output="" + if output=$(kubectl -n "$kdc_ns" exec "$pod_name" -- "$@" 2>&1); then + printf '%s' "$output" + return 0 + fi + if echo "$output" | grep -qi "completed pod"; then + return 2 + fi + if echo "$output" | grep -qi "not found"; then + return 2 + fi + echo "$output" >&2 + return 1 +} + +run_samba_join() { + local kdc_ns="$1" + local pod_name="$2" + local domain="$3" + local output="" + if output=$(kubectl -n "$kdc_ns" exec "$pod_name" -- \ + env SAMBA_ADMIN_USER="$SAMBA_ADMIN_USER" SAMBA_ADMIN_PASSWORD="$SAMBA_ADMIN_PASSWORD" \ + SAMBA_DNS_SERVER="$SAMBA_DNS_SERVER" SAMBA_REALM="${KRB5_REALM:-}" \ + /bin/sh -c 'realm_flag=""; [ -n "${SAMBA_REALM}" ] && realm_flag="--realm=${SAMBA_REALM}"; samba-tool domain join "'"$domain"'" MEMBER -U"${SAMBA_ADMIN_USER}%${SAMBA_ADMIN_PASSWORD}" --server="${SAMBA_DNS_SERVER}" ${realm_flag}' 2>&1); then + printf '%s' "$output" + return 0 + fi + if echo "$output" | grep -qi "completed pod"; then + return 2 + fi + if echo "$output" | grep -qi "not found"; then + return 2 + fi + if [[ -n "$output" ]]; then + echo "$output" >&2 + else + echo "samba-tool produced no output." >&2 + fi + return 1 +} + +run_kinit() { + local kdc_ns="$1" + local pod_name="$2" + local output="" + + # Prefer /etc/krb5.conf if it exists, otherwise fallback to /opt/prole-kdc/krb5.conf + local krb5_config="/etc/krb5.conf" + if ! kubectl -n "$kdc_ns" exec "$pod_name" -- ls /etc/krb5.conf >/dev/null 2>&1; then + krb5_config="/opt/prole-kdc/krb5.conf" + fi + + echo "Running kinit for ${KRB5_USER}@${KRB5_REALM} inside ${PROLE_KDC_NAME} (${pod_name}) using ${krb5_config} ..." + if output=$(printf '%s\n' "$KRB5_PASSWORD" | kubectl -n "$kdc_ns" exec -i "$pod_name" -- \ + env KRB5_CONFIG="$krb5_config" kinit "${KRB5_USER}@${KRB5_REALM}" 2>&1); then + printf '%s' "$output" + return 0 + fi + if echo "$output" | grep -qi "completed pod"; then + return 2 + fi + if echo "$output" | grep -qi "not found"; then + return 2 + fi + if [[ -n "$output" ]]; then + echo "$output" >&2 + else + echo "kinit produced no output." >&2 + fi + return 1 +} + +check_samba_connectivity() { + local kdc_ns="$1" + local pod_name="$2" + if [[ -z "$SAMBA_DNS_SERVER" ]]; then + return 0 + fi + + echo "Checking connectivity from ${PROLE_KDC_NAME} to ${SAMBA_DNS_SERVER} ..." + local ports="88 389 445 464" + local port + for port in $ports; do + local out="" + out=$(kubectl -n "$kdc_ns" exec "$pod_name" -- /bin/sh -c "timeout 3 bash -c '&1) || true + if [[ -z "$out" ]]; then + echo "OK: ${SAMBA_DNS_SERVER}:${port}" + else + echo "WARN: ${SAMBA_DNS_SERVER}:${port} unreachable: ${out}" + fi + done +} + +check_kdc_direct_connectivity() { + local kdc_ns="$1" + local pod_name="$2" + local kdc_ip="${AD_DC_IP:-${KDC_ANSIBLE_DETECTED:-${KDC_AUTO_DETECTED:-}}}" + if [[ -z "$kdc_ip" ]]; then + return 0 + fi + + echo "Checking connectivity from ${PROLE_KDC_NAME} to KDC IP ${kdc_ip} ..." + local ports="88 389 445 464" + local port + for port in $ports; do + local out="" + out=$(kubectl -n "$kdc_ns" exec "$pod_name" -- /bin/sh -c "timeout 3 bash -c '&1) || true + if [[ -z "$out" ]]; then + echo "OK: ${kdc_ip}:${port}" + else + echo "WARN: ${kdc_ip}:${port} unreachable: ${out}" + fi + done +} + +openbao_url() { + if [[ -n "${PROLE_OPENBAO_URL:-}" ]]; then + echo "$PROLE_OPENBAO_URL" + return 0 + fi + if prole_is_in_cluster; then + echo "http://openbao.${SERVICE_NAMESPACE:-${NAMESPACE:-default}}.svc.cluster.local:8200" + return 0 + fi + if curl -sS "http://127.0.0.1:8200/v1/sys/health" >/dev/null 2>&1; then + echo "http://127.0.0.1:8200" + return 0 + elif curl -sS "http://127.0.0.1:8200/v1/sys/health" >/dev/null 2>&1; then + echo "http://127.0.0.1:8200" + return 0 + else + echo "" + return 0 + fi +} + +openbao_token() { + if [[ -f "$PROLE_SERVICE/secrets/openbao-root-token" ]]; then + cat "$PROLE_SERVICE/secrets/openbao-root-token" + else + echo "${OPENBAO_ROOT_TOKEN:-}" + fi +} + +fetch_openbao_secret() { + local path="$1" + local key="$2" + local token url + token=$(openbao_token) + url=$(openbao_url) + if [[ -z "$token" || -z "$url" ]]; then + echo "" + return 0 + fi + curl -sS -H "X-Vault-Token: $token" "$url/v1/kv/data/$path" | jq -r ".data.data.\"$key\"" || echo "" +} + +resolve_krb5_password() { + if prole_secret_needs_resolution "${KRB5_PASSWORD:-}"; then + local path="prole/${NAMESPACE:-default}/kerberos" + local fetched + fetched=$(fetch_openbao_secret "$path" "password") + KRB5_PASSWORD=$(prole_secret_choose_value "${KRB5_PASSWORD:-}" "$fetched") + fi +} + +resolve_samba_vars() { + if [[ -n "${SAMBA_ADMIN_USER}" && -n "${SAMBA_ADMIN_PASSWORD}" && -n "${SAMBA_DNS_SERVER}" ]]; then + return 0 + fi + + # 1. Fallback for DNS server from prole.cfg env (AD_DC_HOST) + if [[ -z "$SAMBA_DNS_SERVER" && -n "${AD_DC_HOST:-}" ]]; then + SAMBA_DNS_SERVER="$AD_DC_HOST" + echo "Using SAMBA_DNS_SERVER=${SAMBA_DNS_SERVER} from AD_DC_HOST" + fi + + # 2. Try to resolve from Ansible inventory if possible + local root + if [[ -n "${PROLE_HOME:-}" && -d "${PROLE_HOME}" ]]; then + root="${PROLE_HOME}" + else + root="${SCRIPT_DIR}/.." + fi + + local vars_file="${root}/infrastructure/inventory/group_vars/ad_dc/vars.yml" + if [[ -f "$vars_file" ]]; then + if [[ -z "$SAMBA_DNS_SERVER" ]]; then + SAMBA_DNS_SERVER=$(prole_yaml_get_scalar "$vars_file" "samba_dns_server") + fi + if [[ -z "$SAMBA_ADMIN_USER" ]]; then + SAMBA_ADMIN_USER=$(prole_yaml_get_scalar "$vars_file" "samba_dns_admin_user") + fi + fi + + # 3. Fallback for Admin User + if [[ -z "$SAMBA_ADMIN_USER" ]]; then + if [[ -n "${AD_DC_USER:-}" ]]; then + SAMBA_ADMIN_USER="$AD_DC_USER" + echo "Using SAMBA_ADMIN_USER=${SAMBA_ADMIN_USER} from AD_DC_USER" + else + SAMBA_ADMIN_USER="administrator" + echo "Defaulting SAMBA_ADMIN_USER to administrator" + fi + fi + + # 4. Try to resolve password from Ansible Vault + if [[ -z "$SAMBA_ADMIN_PASSWORD" ]]; then + local vault_file="${root}/infrastructure/inventory/group_vars/ad_dc/vault.yml" + local vault_pass_file="" + if [[ -n "${ANSIBLE_VAULT_PASSWORD_FILE:-}" && -f "${ANSIBLE_VAULT_PASSWORD_FILE}" ]]; then + vault_pass_file="${ANSIBLE_VAULT_PASSWORD_FILE}" + elif [[ -n "${PROLE_HOME:-}" && -f "${PROLE_HOME}/.vault_pass" ]]; then + vault_pass_file="${PROLE_HOME}/.vault_pass" + elif [[ -f "${root}/.vault_pass" ]]; then + vault_pass_file="${root}/.vault_pass" + fi + + if [[ -f "$vault_file" && -n "$vault_pass_file" && -x "$(command -v ansible-vault)" ]]; then + local vault_out + vault_out=$(ansible-vault view "$vault_file" --vault-password-file "$vault_pass_file" 2>/dev/null || true) + if [[ -n "$vault_out" ]]; then + SAMBA_ADMIN_PASSWORD=$(printf '%s\n' "$vault_out" | awk -F: '/^[[:space:]]*vault_samba_dns_admin_pass[[:space:]]*:/ {sub(/^[^:]+:[[:space:]]*/, "", $0); gsub(/"/, "", $0); print $0; exit}') + fi + fi + fi + + # 5. Fallback for Password from OpenBao + if [[ -z "$SAMBA_ADMIN_PASSWORD" ]]; then + local path="prole/${NAMESPACE:-default}/ad_dc" + local fetched + fetched=$(fetch_openbao_secret "$path" "password") + if [[ -n "$fetched" && "$fetched" != "null" ]]; then + SAMBA_ADMIN_PASSWORD="$fetched" + echo "Fetched SAMBA_ADMIN_PASSWORD from OpenBao (${path})" + else + # Try kerberos path as fallback + path="prole/${NAMESPACE:-default}/kerberos" + fetched=$(fetch_openbao_secret "$path" "samba_password") + if [[ -n "$fetched" && "$fetched" != "null" ]]; then + SAMBA_ADMIN_PASSWORD="$fetched" + echo "Fetched SAMBA_ADMIN_PASSWORD from OpenBao (${path}#samba_password)" + fi + fi + fi +} + +join_samba_realm_if_needed() { + local kdc_ns="$1" + local pod_name="$2" + local domain="" + + resolve_samba_vars + + if [[ -z "$SAMBA_ADMIN_USER" || -z "$SAMBA_ADMIN_PASSWORD" || -z "$SAMBA_DNS_SERVER" ]]; then + echo "WARN: Missing Samba join info; skipping samba-tool realm join." + return 0 + fi + + check_samba_connectivity "$kdc_ns" "$pod_name" + + if [[ -n "$KRB5_REALM" ]]; then + domain=$(printf '%s' "$KRB5_REALM" | tr '[:upper:]' '[:lower:]') + fi + if [[ -z "$domain" ]]; then + domain="$SAMBA_DNS_SERVER" + fi + + if kubectl -n "$kdc_ns" exec "$pod_name" -- test -f /var/lib/samba/private/secrets.tdb >/dev/null 2>&1; then + echo "Samba already joined; skipping join." + return 0 + fi + + echo "Joining Samba realm '${domain}' (server ${SAMBA_DNS_SERVER}) ..." + local attempt=1 + while true; do + if run_samba_join "$kdc_ns" "$pod_name" "$domain"; then + return 0 + fi + if [[ $? -eq 2 ]]; then + if [[ $attempt -ge $KDC_POD_READY_RETRIES ]]; then + echo "WARN: KDC pod completed before join could run; skipping samba-tool join." >&2 + return 0 + fi + pod_name=$(wait_for_kdc_pod "$kdc_ns" || true) + if [[ -z "$pod_name" ]]; then + echo "WARN: KDC pod unavailable for samba-tool join." >&2 + return 0 + fi + attempt=$((attempt + 1)) + continue + fi + echo "WARN: samba-tool domain join failed; continuing to Kerberos test." >&2 + return 0 + done +} + +run_test() { + ensure_tools + ensure_namespace + resolve_krb5_password + + # Support both names for the toggle from prole.cfg + local enabled="${KERBEROS_ENABLED:-${ENABLED:-false}}" + if [[ "$enabled" == "false" || "$enabled" == "0" || "$enabled" == "False" ]]; then + echo "Kerberos is disabled (KERBEROS_ENABLED=$enabled). Skipping test." + return 0 + fi + + if [[ -z "$KRB5_REALM" || -z "$KRB5_USER" || -z "$KRB5_PASSWORD" || -z "$KRB5_KDC" ]]; then + echo "ERROR: Missing Kerberos configuration. Ensure KRB5_REALM, KRB5_KDC, KRB5_USER, KRB5_PASSWORD are set." >&2 + exit 1 + fi + + # Quick pre-check: if an existing 'auth' deployment is present but not Available, remove it + # to avoid starting a rollout that is likely to time out on a stale/broken replica set. + local kdc_ns + kdc_ns="${SERVICE_NAMESPACE:-${NAMESPACE:-default}}" + if kubectl -n "$kdc_ns" get deploy "$PROLE_KDC_NAME" >/dev/null 2>&1; then + # Try a fast availability wait; if it fails, treat as unhealthy and clean up before proceeding. + if ! kubectl -n "$kdc_ns" wait --for=condition=Available deploy/"$PROLE_KDC_NAME" --timeout="${PROLE_KDC_PRECHECK_TIMEOUT}s" >/dev/null 2>&1; then + echo "Detected unhealthy '$PROLE_KDC_NAME' deployment in namespace '$kdc_ns'; removing before Kerberos test rollout to avoid timeout..." >&2 + if [[ -x "$SCRIPT_DIR/init_kdc.sh" ]]; then + SERVICE_NAMESPACE="$SERVICE_NAMESPACE" "$SCRIPT_DIR/init_kdc.sh" cleanup || true + else + kubectl -n "$kdc_ns" delete deploy "$PROLE_KDC_NAME" --ignore-not-found || true + kubectl -n "$kdc_ns" delete svc "$PROLE_KDC_SERVICE" --ignore-not-found || true + kubectl -n "$kdc_ns" delete configmap prole-kdc-config --ignore-not-found || true + fi + fi + fi + + if [[ -x "$SCRIPT_DIR/init_kdc.sh" ]]; then + SERVICE_NAMESPACE="$SERVICE_NAMESPACE" KRB5_REALM="$KRB5_REALM" KRB5_KDC="$KRB5_KDC" \ + KRB5_ADMIN="$KRB5_KDC" KRB5_USER="$KRB5_USER" KRB5_PASSWORD="$KRB5_PASSWORD" \ + "$SCRIPT_DIR/init_kdc.sh" update || true + fi + + local pod_name + pod_name=$(wait_for_kdc_pod "$kdc_ns" || true) + if [[ -z "$pod_name" ]]; then + echo "ERROR: KDC pod '${PROLE_KDC_NAME}' not found in namespace '$kdc_ns'. Run init_kdc.sh update first." >&2 + exit 1 + fi + + # If the pod is crashlooping, dump logs and fail fast + if is_pod_crashloop "$kdc_ns" "$pod_name"; then + echo "ERROR: KDC pod '${pod_name}' is in CrashLoopBackOff. Dumping diagnostics..." >&2 + debug_kdc_pod "$kdc_ns" "$pod_name" + exit 1 + fi + + write_krb5_conf_to_pod "$kdc_ns" "$pod_name" + + check_kdc_direct_connectivity "$kdc_ns" "$pod_name" + + join_samba_realm_if_needed "$kdc_ns" "$pod_name" + + echo "Running kinit for ${KRB5_USER}@${KRB5_REALM} inside ${PROLE_KDC_NAME} (${pod_name}) ..." + local attempt=1 + while true; do + if run_kinit "$kdc_ns" "$pod_name"; then + break + fi + if [[ $? -eq 2 ]] || kubectl -n "$kdc_ns" get pod "$pod_name" -o jsonpath='{.status.phase}' 2>/dev/null | grep -qi "Succeeded"; then + if [[ $attempt -ge $KDC_POD_READY_RETRIES ]]; then + echo "ERROR: KDC pod completed before kinit could run." >&2 + exit 1 + fi + pod_name=$(wait_for_kdc_pod "$kdc_ns" || true) + if [[ -z "$pod_name" ]]; then + echo "ERROR: KDC pod unavailable for kinit." >&2 + exit 1 + fi + attempt=$((attempt + 1)) + continue + fi + # If the pod is crashlooping, show logs to aid troubleshooting + if is_pod_crashloop "$kdc_ns" "$pod_name"; then + echo "ERROR: KDC pod '${pod_name}' entered CrashLoopBackOff during kinit. Dumping diagnostics..." >&2 + debug_kdc_pod "$kdc_ns" "$pod_name" + fi + echo "ERROR: kinit failed for ${KRB5_USER}@${KRB5_REALM}." >&2 + exit 1 + done + + echo "Kerberos ticket cache:" + # Determine krb5 config path in the pod similar to run_kinit() + local krb5_config_in_pod="/etc/krb5.conf" + if ! kubectl -n "$kdc_ns" exec "$pod_name" -- ls /etc/krb5.conf >/dev/null 2>&1; then + krb5_config_in_pod="/opt/prole-kdc/krb5.conf" + fi + kubectl -n "$kdc_ns" exec "$pod_name" -- env KRB5_CONFIG="$krb5_config_in_pod" klist || true +} + +case "$ACTION" in + test) + run_test + ;; + cleanup) + echo "No test pods to cleanup (KDC-based test)." + ;; + *) + echo "Usage: $0 {test|cleanup}" >&2 + exit 2 + ;; +esac diff --git a/tests/etc/test_init_garage_recycles_released_pv_claimref.sh b/tests/etc/test_init_garage_recycles_released_pv_claimref.sh index c1a99f2..490feca 100644 --- a/tests/etc/test_init_garage_recycles_released_pv_claimref.sh +++ b/tests/etc/test_init_garage_recycles_released_pv_claimref.sh @@ -7,16 +7,18 @@ set -euo pipefail SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) PROLE_HOME=$(cd "$SCRIPT_DIR/../.." && pwd) SOURCE_ETC_DIR="$PROLE_HOME/etc" +SOURCE_LIB_SHELL_DIR="$PROLE_HOME/lib/shell" TMP_DIR=$(mktemp -d) trap 'rm -rf "$TMP_DIR"' EXIT WORK_DIR="$TMP_DIR/work" BIN_DIR="$TMP_DIR/bin" -mkdir -p "$WORK_DIR/etc" "$WORK_DIR/conf" "$WORK_DIR/k8s/prole" "$BIN_DIR" +mkdir -p "$WORK_DIR/etc" "$WORK_DIR/conf" "$WORK_DIR/k8s/prole" "$WORK_DIR/lib/shell" "$BIN_DIR" cp "$SOURCE_ETC_DIR/init_garage_store.sh" "$WORK_DIR/etc/init_garage_store.sh" cp "$SOURCE_ETC_DIR/common_core_lib.sh" "$WORK_DIR/etc/common_core_lib.sh" +cp "$SOURCE_LIB_SHELL_DIR/common_core_lib.sh" "$WORK_DIR/lib/shell/common_core_lib.sh" cp "$SOURCE_ETC_DIR/prole_cfg.sh" "$WORK_DIR/etc/prole_cfg.sh" chmod +x "$WORK_DIR/etc/init_garage_store.sh" diff --git a/tests/etc/test_init_kong_tmp_unbound.sh b/tests/etc/test_init_kong_tmp_unbound.sh index 5958249..f6cdf25 100644 --- a/tests/etc/test_init_kong_tmp_unbound.sh +++ b/tests/etc/test_init_kong_tmp_unbound.sh @@ -7,16 +7,18 @@ set -euo pipefail SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) PROLE_HOME=$(cd "$SCRIPT_DIR/../.." && pwd) SOURCE_ETC_DIR="$PROLE_HOME/etc" +SOURCE_LIB_SHELL_DIR="$PROLE_HOME/lib/shell" TMP_DIR=$(mktemp -d) trap 'rm -rf "$TMP_DIR"' EXIT WORK_DIR="$TMP_DIR/work" BIN_DIR="$TMP_DIR/bin" -mkdir -p "$WORK_DIR/etc" "$WORK_DIR/conf" "$BIN_DIR" +mkdir -p "$WORK_DIR/etc" "$WORK_DIR/conf" "$WORK_DIR/lib/shell" "$BIN_DIR" cp "$SOURCE_ETC_DIR/init_kong.sh" "$WORK_DIR/etc/init_kong.sh" cp "$SOURCE_ETC_DIR/common_core_lib.sh" "$WORK_DIR/etc/common_core_lib.sh" +cp "$SOURCE_LIB_SHELL_DIR/common_core_lib.sh" "$WORK_DIR/lib/shell/common_core_lib.sh" cp "$SOURCE_ETC_DIR/prole_cfg.sh" "$WORK_DIR/etc/prole_cfg.sh" chmod +x "$WORK_DIR/etc/init_kong.sh" diff --git a/tests/etc/test_init_openbao_recycles_released_pv_claimref.sh b/tests/etc/test_init_openbao_recycles_released_pv_claimref.sh index bed0c57..56eb687 100644 --- a/tests/etc/test_init_openbao_recycles_released_pv_claimref.sh +++ b/tests/etc/test_init_openbao_recycles_released_pv_claimref.sh @@ -7,16 +7,18 @@ set -euo pipefail SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) PROLE_HOME=$(cd "$SCRIPT_DIR/../.." && pwd) SOURCE_ETC_DIR="$PROLE_HOME/etc" +SOURCE_LIB_SHELL_DIR="$PROLE_HOME/lib/shell" TMP_DIR=$(mktemp -d) trap 'rm -rf "$TMP_DIR"' EXIT WORK_DIR="$TMP_DIR/work" BIN_DIR="$TMP_DIR/bin" -mkdir -p "$WORK_DIR/etc" "$WORK_DIR/conf" "$BIN_DIR" +mkdir -p "$WORK_DIR/etc" "$WORK_DIR/conf" "$WORK_DIR/lib/shell" "$BIN_DIR" cp "$SOURCE_ETC_DIR/init_openbao.sh" "$WORK_DIR/etc/init_openbao.sh" cp "$SOURCE_ETC_DIR/common_core_lib.sh" "$WORK_DIR/etc/common_core_lib.sh" +cp "$SOURCE_LIB_SHELL_DIR/common_core_lib.sh" "$WORK_DIR/lib/shell/common_core_lib.sh" cp "$SOURCE_ETC_DIR/prole_cfg.sh" "$WORK_DIR/etc/prole_cfg.sh" chmod +x "$WORK_DIR/etc/init_openbao.sh" diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.circleci/config.yml b/tests/shellspec/.vendor/shellspec-0.28.1/.circleci/config.yml new file mode 100644 index 0000000..e9e83a2 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.circleci/config.yml @@ -0,0 +1,59 @@ +version: 2 +jobs: + lint: + docker: + - image: koalaman/shellcheck-alpine:v0.7.1 + steps: + - checkout + - run: shellcheck shellspec $(find lib libexec spec examples -name '*.sh') + test: + working_directory: ~/shellspec + docker: + - image: alpine + steps: + - run: apk add --no-progress --no-cache ca-certificates + - checkout + - run: ./shellspec --task fixture:stat:prepare + - run: ./shellspec -o tap -o junit + - run: + command: | + mkdir -p ~/report/shellspec + cp report/results_junit.xml ~/report/shellspec/ + when: always + - store_test_results: + path: ~/report + - store_artifacts: + path: report + coverage: + working_directory: ~/shellspec + docker: + - image: shellspec/kcov + steps: + - checkout + - run: ./shellspec --task fixture:stat:prepare + - run: ./shellspec --kcov + - store_artifacts: + path: coverage +workflows: + version: 2 + lint_test_and_coverage: + jobs: + - lint + - test + - coverage: + requires: + - lint + - test + daily_update_schedule: + jobs: + - lint + - coverage: + requires: + - lint + triggers: + - schedule: + cron: "0 0 * * *" + filters: + branches: + only: + - master diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.cirrus.yml b/tests/shellspec/.vendor/shellspec-0.28.1/.cirrus.yml new file mode 100644 index 0000000..1624234 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.cirrus.yml @@ -0,0 +1,80 @@ +env: + FORCE_COLOR: 1 + +freebsd_task: + freebsd_instance: + matrix: + - image: freebsd-10-4-release-amd64 + - image_family: freebsd-11-4 + - image_family: freebsd-12-2 + # - image_family: freebsd-13-0-snap + install_script: pkg install -y dash bash zsh ksh93 mksh oksh + prepare_script: + - ./shellspec --task fixture:stat:prepare + script: + - contrib/all.sh contrib/various_test.sh + +# gitbash_task: +# timeout_in: 120m +# windows_container: +# image: cirrusci/windowsservercore:2019 +# os_version: 2019 +# env: +# PATH: $ProgramFiles\Git\bin;$PATH +# install_script: +# - git --version +# prepare_script: +# - bash -c "env | grep -E '^(LC_|LANG|CYGWIN|MSYS)'" +# - bash -c "mount" +# - bash -c "./shellspec --task fixture:stat:prepare" +# script: +# - bash -c "contrib/all.sh shellspec" + +# msys_task: +# timeout_in: 120m +# windows_container: +# image: cirrusci/windowsservercore:2019 +# os_version: 2019 +# env: +# PATH: C:\tools\msys64\usr\bin;$PATH +# install_script: +# - choco install -y --no-progress msys2 +# - pacman.exe -Syu --noprogressbar --noconfirm +# - pacman.exe -S --noprogressbar --noconfirm dash bash busybox mksh zsh +# - pacman.exe -Q +# prepare_script: +# - bash -c "env | grep -E '^(LC_|LANG|CYGWIN|MSYS)'" +# - bash -c "mount" +# - bash -c "./shellspec --task fixture:stat:prepare" +# script: +# - bash -c "contrib/all.sh shellspec" + +# cygwin_task: +# timeout_in: 120m +# windows_container: +# image: cirrusci/windowsservercore:2019 +# os_version: 2019 +# env: +# PATH: C:\tools\cygwin\bin;$PATH +# install_script: +# - choco install -y --no-progress cygwin cyg-get +# - cyg-get nc dash bash busybox mksh posh zsh +# - cygcheck -c +# prepare_script: +# - bash -c "env | grep -E '^(LC_|LANG|CYGWIN|MSYS)'" +# - bash -c "mount" +# - bash -c "./shellspec --task fixture:stat:prepare" +# # I don't know why but tests using below files fail in cirrus ci environment. +# - bash -c "rm -f ./spec/fixture/stat/{readable,writable}" +# script: +# - bash -c 'contrib/all.sh shellspec' + +# busybox_task: +# timeout_in: 120m +# windows_container: +# image: cirrusci/windowsservercore:2019 +# os_version: 2019 +# install_script: +# - choco install -y --no-progress busybox +# script: +# - busybox ash -c "contrib/all.sh shellspec" diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.codecov.yml b/tests/shellspec/.vendor/shellspec-0.28.1/.codecov.yml new file mode 100644 index 0000000..107545d --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.codecov.yml @@ -0,0 +1,6 @@ +coverage: + status: + project: + default: + target: 30% + patch: false diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/Dockerfile b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/Dockerfile new file mode 100644 index 0000000..ac45f66 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/Dockerfile @@ -0,0 +1,82 @@ +# Build two images with Automated Builds using Docker Hub hooks. +# See https://github.com/shellspec/shellspec/tree/master/.dockerhub/hooks + +# ====================================================================== +# source code +# ====================================================================== +FROM scratch as source +COPY shellspec LICENSE /opt/shellspec/ +COPY lib /opt/shellspec/lib +COPY libexec /opt/shellspec/libexec + +# ====================================================================== +# Kcov builder +# ====================================================================== +FROM alpine:3.12 as builder +ENV KCOV=v38 CXXFLAGS=-D__ptrace_request=int +WORKDIR /usr/local/src +RUN apk add --no-cache build-base cmake ninja python3 \ + binutils-dev curl-dev elfutils-dev +RUN wget -q https://github.com/SimonKagstrom/kcov/archive/$KCOV.tar.gz +RUN tar xzf $KCOV.tar.gz -C ./ --strip-components 1 +RUN mkdir build && cd build \ + && cmake -G Ninja .. && cmake --build . --target install + +# ====================================================================== +# Kcov image +# TAG: shellspec:kcov, shellspec:[VERSION]-kcov +# ====================================================================== +FROM alpine:3.12 as kcov +RUN apk add --no-cache bash binutils-dev curl-dev elfutils-libelf +COPY --from=builder /usr/local/bin/kcov* /usr/local/bin/ +COPY --from=builder /usr/local/share/doc/kcov /usr/local/share/doc/kcov +COPY --from=source /opt/shellspec /opt/shellspec +COPY .dockerhub/shellspec-docker-entrypoint.sh /shellspec-docker +ENV PATH /opt/shellspec/:$PATH +WORKDIR /src +ENTRYPOINT [ "shellspec" ] +ARG CREATED +ARG AUTHORS +ARG VERSION +ARG REVISION +ARG REFNAME +LABEL org.opencontainers.image.created=$CREATED \ + org.opencontainers.image.authors=$AUTHORS \ + org.opencontainers.image.url="https://shellspec.info/" \ + org.opencontainers.image.documentation="https://github.com/shellspec/shellspec" \ + org.opencontainers.image.source="https://github.com/shellspec/shellspec.git" \ + org.opencontainers.image.version=$VERSION \ + org.opencontainers.image.revision=$REVISION \ + org.opencontainers.image.vendor="shellspec" \ + org.opencontainers.image.licenses="MIT" \ + org.opencontainers.image.ref.name=$REFNAME \ + org.opencontainers.image.title="shellspec+kcov" \ + org.opencontainers.image.description="Shellspec (Alpine based with Kcov)" + +# ====================================================================== +# Standard image (default) +# TAG: shellspec:latest, shellspec:[VERSION] +# ====================================================================== +FROM alpine:3.12 as standard +COPY --from=source /opt/shellspec /opt/shellspec +COPY .dockerhub/shellspec-docker-entrypoint.sh /shellspec-docker +ENV PATH /opt/shellspec/:$PATH +WORKDIR /src +ENTRYPOINT [ "shellspec" ] +ARG CREATED +ARG AUTHORS +ARG VERSION +ARG REVISION +ARG REFNAME +LABEL org.opencontainers.image.created=$CREATED \ + org.opencontainers.image.authors=$AUTHORS \ + org.opencontainers.image.url="https://shellspec.info/" \ + org.opencontainers.image.documentation="https://github.com/shellspec/shellspec" \ + org.opencontainers.image.source="https://github.com/shellspec/shellspec.git" \ + org.opencontainers.image.version=$VERSION \ + org.opencontainers.image.revision=$REVISION \ + org.opencontainers.image.vendor="shellspec" \ + org.opencontainers.image.licenses="MIT" \ + org.opencontainers.image.ref.name=$REFNAME \ + org.opencontainers.image.title="shellspec" \ + org.opencontainers.image.description="Shellspec (Alpine based)" diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/Dockerfile.debian b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/Dockerfile.debian new file mode 100644 index 0000000..93a862e --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/Dockerfile.debian @@ -0,0 +1,85 @@ +# Build two images with Automated Builds using Docker Hub hooks. +# See https://github.com/shellspec/shellspec/tree/master/.dockerhub/hooks + +# ====================================================================== +# source code +# ====================================================================== +FROM scratch as source +COPY shellspec LICENSE /opt/shellspec/ +COPY lib /opt/shellspec/lib +COPY libexec /opt/shellspec/libexec + +# ====================================================================== +# Kcov builder +# ====================================================================== +FROM debian:10 AS builder +ENV KCOV=v38 DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +WORKDIR /usr/local/src +RUN apt-get update && apt-get install -y \ + build-essential cmake ninja-build python3 wget \ + binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev +RUN wget -q https://github.com/SimonKagstrom/kcov/archive/$KCOV.tar.gz +RUN tar xzf $KCOV.tar.gz -C ./ --strip-components 1 +RUN mkdir build && cd build \ + && cmake -G Ninja .. && cmake --build . --target install + +# ====================================================================== +# Kcov image +# TAG: shellspec-debian:kcov, shellspec-debian:[VERSION]-kcov +# ====================================================================== +FROM debian:10 as kcov +RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes \ + && apt-get update && apt-get install -y binutils libcurl4 zlib1g libdw1 \ + && apt-get clean && rm -rf /var/lib/apt/lists/* +COPY --from=builder /usr/local/bin/kcov* /usr/local/bin/ +COPY --from=builder /usr/local/share/doc/kcov /usr/local/share/doc/kcov +COPY --from=source /opt/shellspec /opt/shellspec +COPY .dockerhub/shellspec-docker-entrypoint.sh /shellspec-docker +ENV PATH /opt/shellspec/:$PATH +WORKDIR /src +ENTRYPOINT [ "shellspec" ] +ARG CREATED +ARG AUTHORS +ARG VERSION +ARG REVISION +ARG REFNAME +LABEL org.opencontainers.image.created=$CREATED \ + org.opencontainers.image.authors=$AUTHORS \ + org.opencontainers.image.url="https://shellspec.info/" \ + org.opencontainers.image.documentation="https://github.com/shellspec/shellspec" \ + org.opencontainers.image.source="https://github.com/shellspec/shellspec.git" \ + org.opencontainers.image.version=$VERSION \ + org.opencontainers.image.revision=$REVISION \ + org.opencontainers.image.vendor="shellspec" \ + org.opencontainers.image.licenses="MIT" \ + org.opencontainers.image.ref.name=$REFNAME \ + org.opencontainers.image.title="shellspec-debian+kcov" \ + org.opencontainers.image.description="Shellspec (Debian based with Kcov)" + +# ====================================================================== +# Standard image (default) +# TAG: shellspec-debian:latest, shellspec-debian:[VERSION] +# ====================================================================== +FROM debian:10 as standard +COPY --from=source /opt/shellspec /opt/shellspec +COPY .dockerhub/shellspec-docker-entrypoint.sh /shellspec-docker +ENV PATH /opt/shellspec/:$PATH +WORKDIR /src +ENTRYPOINT [ "shellspec" ] +ARG CREATED +ARG AUTHORS +ARG VERSION +ARG REVISION +ARG REFNAME +LABEL org.opencontainers.image.created=$CREATED \ + org.opencontainers.image.authors=$AUTHORS \ + org.opencontainers.image.url="https://shellspec.info/" \ + org.opencontainers.image.documentation="https://github.com/shellspec/shellspec" \ + org.opencontainers.image.source="https://github.com/shellspec/shellspec.git" \ + org.opencontainers.image.version=$VERSION \ + org.opencontainers.image.revision=$REVISION \ + org.opencontainers.image.vendor="shellspec" \ + org.opencontainers.image.licenses="MIT" \ + org.opencontainers.image.ref.name=$REFNAME \ + org.opencontainers.image.title="shellspec-debian" \ + org.opencontainers.image.description="Shellspec (Debian based)" diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/Dockerfile.scratch b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/Dockerfile.scratch new file mode 100644 index 0000000..53b012d --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/Dockerfile.scratch @@ -0,0 +1,44 @@ +# ====================================================================== +# source code +# ====================================================================== +FROM scratch as source +COPY shellspec LICENSE /opt/shellspec/ +COPY lib /opt/shellspec/lib +COPY libexec /opt/shellspec/libexec + +# ====================================================================== +# Fake kcov target to pass the test +# ====================================================================== +FROM busybox as kcov +RUN echo "#!/bin/true" > /bin/sh + +# ====================================================================== +# Use standard target to test source code +# ====================================================================== +FROM alpine as standard +ENV PATH /opt/shellspec/:$PATH +COPY --from=source /opt/shellspec /opt/shellspec + +# ====================================================================== +# Source image (default) +# TAG: shellspec-scratch:latest, shellspec-scratch:[VERSION] +# ====================================================================== +FROM scratch +COPY --from=source /opt/shellspec /opt/shellspec +ARG CREATED +ARG AUTHORS +ARG VERSION +ARG REVISION +ARG REFNAME +LABEL org.opencontainers.image.created=$CREATED \ + org.opencontainers.image.authors=$AUTHORS \ + org.opencontainers.image.url="https://shellspec.info/" \ + org.opencontainers.image.documentation="https://github.com/shellspec/shellspec" \ + org.opencontainers.image.source="https://github.com/shellspec/shellspec.git" \ + org.opencontainers.image.version=$VERSION \ + org.opencontainers.image.revision=$REVISION \ + org.opencontainers.image.vendor="shellspec" \ + org.opencontainers.image.licenses="MIT" \ + org.opencontainers.image.ref.name=$REFNAME \ + org.opencontainers.image.title="shellspec-scratch" \ + org.opencontainers.image.description="Shellspec (Scratch based)" diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/README.md b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/README.md new file mode 100644 index 0000000..58ce417 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/README.md @@ -0,0 +1,55 @@ +# ShellSpec docker images + +[ShellSpec](https://shellspec.info/) is a full-featured BDD unit testing framework for shell scripts. + +These docker images are for running ShellSpec easily and suitable for incorporating into CI. + +The tag with `kcov` means [Kcov](https://github.com/SimonKagstrom/kcov) is included. The tag `latest` is latest release version. + +## Alpine based + +![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/shellspec/shellspec) +![Docker Cloud Automated build](https://img.shields.io/docker/cloud/automated/shellspec/shellspec) +![Docker Pulls](https://img.shields.io/docker/pulls/shellspec/shellspec) + +https://hub.docker.com/r/shellspec/shellspec + +Tags: + +- shellspec/shellspec:latest +- shellspec/shellspec:kcov +- shellspec/shellspec:master +- shellspec/shellspec:master-kcov +- shellspec/shellspec:[VERSION] +- shellspec/shellspec:[VERSION]-kcov + +## Debian based + +![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/shellspec/shellspec-debian) +![Docker Cloud Automated build](https://img.shields.io/docker/cloud/automated/shellspec/shellspec-debian) +![Docker Pulls](https://img.shields.io/docker/pulls/shellspec/shellspec-debian) + +https://hub.docker.com/r/shellspec/shellspec-debian + +Tags: + +- shellspec/shellspec-debian:latest +- shellspec/shellspec-debian:kcov +- shellspec/shellspec-debian:master +- shellspec/shellspec-debian:master-kcov +- shellspec/shellspec-debian:[VERSION] +- shellspec/shellspec-debian:[VERSION]-kcov + +## Scratch based + +![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/shellspec/shellspec-scratch) +![Docker Cloud Automated build](https://img.shields.io/docker/cloud/automated/shellspec/shellspec-scratch) +![Docker Pulls](https://img.shields.io/docker/pulls/shellspec/shellspec-scratch) + +https://hub.docker.com/r/shellspec/shellspec-scratch + +Tags: + +- shellspec/shellspec-scratch:latest +- shellspec/shellspec-scratch:master +- shellspec/shellspec-scratch:[VERSION] diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/docker-compose.kcov.test.yml b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/docker-compose.kcov.test.yml new file mode 100644 index 0000000..d73d969 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/docker-compose.kcov.test.yml @@ -0,0 +1,14 @@ +version: "3.4" +services: + sut: + build: + context: .. + dockerfile: ${DOCKERFILE_BASE:-}${DOCKERFILE_PATH:-Dockerfile} + target: kcov + entrypoint: /bin/sh -eux -c + command: + - | + shellspec --version + shellspec --init spec + shellspec -f tap + kcov --version diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/docker-compose.test.yml b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/docker-compose.test.yml new file mode 100644 index 0000000..35ffbf1 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/docker-compose.test.yml @@ -0,0 +1,13 @@ +version: "3.4" +services: + sut: + build: + context: .. + dockerfile: ${DOCKERFILE_BASE:-}${DOCKERFILE_PATH:-Dockerfile} + target: standard + entrypoint: /bin/sh -eux -c + command: + - | + shellspec --version + shellspec --init spec + shellspec -f tap diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/hooks/build b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/hooks/build new file mode 100755 index 0000000..a0d3d15 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/hooks/build @@ -0,0 +1,12 @@ +#!/bin/sh -eux + +CREATED=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +VERSION=$(../shellspec --version) +REVISION=$(echo "$SOURCE_COMMIT" | cut -c-10) + +docker build "$@" -f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" .. \ + --build-arg CREATED="$CREATED" \ + --build-arg AUTHORS="$AUTHORS" \ + --build-arg VERSION="$VERSION" \ + --build-arg REVISION="$REVISION" \ + --build-arg REFNAME="$DOCKER_TAG" diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/hooks/post_build b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/hooks/post_build new file mode 100755 index 0000000..ba7c646 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/hooks/post_build @@ -0,0 +1,17 @@ +#!/bin/sh -eux + +# IMAGE_NAME ($DOCKER_REPO:$DOCKER_TAG) +# shellspec/shellspec: +# shellspec/shellspec-: + +case $DOCKER_REPO in + *-scratch) exit +esac + +# Build kcov image +case $DOCKER_TAG in + latest) IMAGE_NAME="$DOCKER_REPO:kcov" ;; + * ) IMAGE_NAME="$IMAGE_NAME-kcov" ;; +esac +DOCKER_TAG=${IMAGE_NAME#*:} +"$(dirname "$0")/build" --target kcov diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/hooks/post_push b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/hooks/post_push new file mode 100755 index 0000000..01d7a1c --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/hooks/post_push @@ -0,0 +1,16 @@ +#!/bin/sh -eux + +# IMAGE_NAME ($DOCKER_REPO:$DOCKER_TAG) +# shellspec/shellspec: +# shellspec/shellspec-: + +case $DOCKER_REPO in + *-scratch) exit +esac + +# Push kcov image +case $DOCKER_TAG in + latest) IMAGE_NAME="$DOCKER_REPO:kcov" ;; + * ) IMAGE_NAME="$IMAGE_NAME-kcov" ;; +esac +docker push "$IMAGE_NAME" diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/shellspec-docker-entrypoint.sh b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/shellspec-docker-entrypoint.sh new file mode 100755 index 0000000..12d3770 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerhub/shellspec-docker-entrypoint.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +set -eu + +if [ "${1:-}" = "-" ] && shift; then + [ $# -gt 0 ] && exec "$@" + type bash >/dev/null 2>&1 && exec /bin/bash -l + exec /bin/sh -l +fi + +if [ -e .shellspec-docker/pre-test ]; then + .shellspec-docker/pre-test +fi + +shellspec "$@" + +if [ -e .shellspec-docker/post-test ]; then + .shellspec-docker/post-test +fi diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.dockerignore b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerignore new file mode 100644 index 0000000..fddeaef --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.dockerignore @@ -0,0 +1,19 @@ +* +!.dockerhub/shellspec-docker-entrypoint.sh +!bin +!contrib/bugs.sh +!lib +!libexec +!dockerfiles/.shellspec-entrypoint.sh +!examples +!helper +!spec +!stub +helper/fixture/stat/* +!.shellspec +!shellspec +!install.sh +!LICENSE +!Makefile +!package.json +!*.sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.gitattributes b/tests/shellspec/.vendor/shellspec-0.28.1/.gitattributes new file mode 100644 index 0000000..55f8ae8 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.gitattributes @@ -0,0 +1,3 @@ +* text=auto eol=lf +helper/fixture/** -text +dockerfiles/* linguist-language=Dockerfile diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/macos-brew.yml b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/macos-brew.yml new file mode 100644 index 0000000..40b2352 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/macos-brew.yml @@ -0,0 +1,27 @@ +name: macOS Homebrew + +on: [push, pull_request] + +env: + FORCE_COLOR: 1 + +jobs: + macos-brew: + runs-on: macos-latest + if: "!contains(github.event.head_commit.message, 'ci skip')" + strategy: + matrix: + shells: + - {shell: dash, package: dash} + - {shell: bash, package: bash} + - {shell: ksh, package: ksh} + - {shell: mksh, package: mksh} + - {shell: yash, package: yash} + - {shell: zsh, package: zsh} + fail-fast: false + steps: + - uses: actions/checkout@v2 + - run: brew upgrade + - run: brew install ${{ matrix.shells.package }} + - run: ${{ matrix.shells.shell }} ./shellspec --shell "${{ matrix.shells.shell }}" --task fixture:stat:prepare + - run: SH="${{ matrix.shells.shell }}" contrib/various_test.sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/macos-catalina.yml b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/macos-catalina.yml new file mode 100644 index 0000000..e684c34 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/macos-catalina.yml @@ -0,0 +1,24 @@ +name: macOS Catalina + +on: [push, pull_request] + +env: + FORCE_COLOR: 1 + +jobs: + macos-catalina: + runs-on: macos-10.15 + if: "!contains(github.event.head_commit.message, 'ci skip')" + strategy: + matrix: + shells: + - {shell: sh} + - {shell: dash} + - {shell: bash} + - {shell: ksh} + - {shell: zsh} + fail-fast: false + steps: + - uses: actions/checkout@v2 + - run: ${{ matrix.shells.shell }} ./shellspec --shell "${{ matrix.shells.shell }}" --task fixture:stat:prepare + - run: SH="${{ matrix.shells.shell }}" contrib/various_test.sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/release.yml b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/release.yml new file mode 100644 index 0000000..a8f0f3a --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/release.yml @@ -0,0 +1,33 @@ +name: Release + +on: + push: + tags: + - '[0-9]*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Make dist archive + run: make dist + - name: Create release + id: create_release + uses: actions/create-release@v1.0.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + draft: false + prerelease: ${{ contains(github.ref, '-') }} + - name: Upload release asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: shellspec-dist.tar.gz + asset_name: shellspec-dist.tar.gz + asset_content_type: application/gzip diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/ubuntu-bionic.yml b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/ubuntu-bionic.yml new file mode 100644 index 0000000..79e26e7 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/ubuntu-bionic.yml @@ -0,0 +1,28 @@ +name: Ubuntu Bionic Beaver + +on: [push, pull_request] + +env: + FORCE_COLOR: 1 + +jobs: + ubuntu-bionic: + runs-on: ubuntu-18.04 + if: "!contains(github.event.head_commit.message, 'ci skip')" + strategy: + matrix: + shells: + - {shell: dash, package: dash} + - {shell: bash, package: bash} + - {shell: busybox ash, package: busybox} + - {shell: ksh, package: ksh} + - {shell: mksh, package: mksh} + - {shell: posh, package: posh} + - {shell: yash, package: yash} + - {shell: zsh, package: zsh} + fail-fast: false + steps: + - uses: actions/checkout@v2 + - run: sudo apt-get install -y ${{ matrix.shells.package }} + - run: sudo ${{ matrix.shells.shell }} ./shellspec --task fixture:stat:prepare + - run: SH="${{ matrix.shells.shell }}" contrib/various_test.sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/ubuntu-focal.yml b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/ubuntu-focal.yml new file mode 100644 index 0000000..34647a3 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/ubuntu-focal.yml @@ -0,0 +1,28 @@ +name: Ubuntu Focal Fossa + +on: [push, pull_request] + +env: + FORCE_COLOR: 1 + +jobs: + ubuntu-focal: + runs-on: ubuntu-20.04 + if: "!contains(github.event.head_commit.message, 'ci skip')" + strategy: + matrix: + shells: + - {shell: dash, package: dash} + - {shell: bash, package: bash} + - {shell: busybox ash, package: busybox} + - {shell: ksh, package: ksh} + - {shell: mksh, package: mksh} + - {shell: posh, package: posh} + - {shell: yash, package: yash} + - {shell: zsh, package: zsh} + fail-fast: false + steps: + - uses: actions/checkout@v2 + - run: sudo apt-get install -y ${{ matrix.shells.package }} + - run: sudo ${{ matrix.shells.shell }} ./shellspec --task fixture:stat:prepare + - run: SH="${{ matrix.shells.shell }}" contrib/various_test.sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/ubuntu-xenial.yml b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/ubuntu-xenial.yml new file mode 100644 index 0000000..9576ff5 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/ubuntu-xenial.yml @@ -0,0 +1,28 @@ +name: Ubuntu Xenial Xerus + +on: [push, pull_request] + +env: + FORCE_COLOR: 1 + +jobs: + ubuntu-xenial: + runs-on: ubuntu-16.04 + if: "!contains(github.event.head_commit.message, 'ci skip')" + strategy: + matrix: + shells: + - {shell: dash, package: dash} + - {shell: bash, package: bash} + - {shell: busybox ash, package: busybox} + - {shell: ksh, package: ksh} + - {shell: mksh, package: mksh} + - {shell: posh, package: posh} + - {shell: yash, package: yash} + - {shell: zsh, package: zsh} + fail-fast: false + steps: + - uses: actions/checkout@v2 + - run: sudo apt-get install -y ${{ matrix.shells.package }} + - run: sudo ${{ matrix.shells.shell }} ./shellspec --task fixture:stat:prepare + - run: SH="${{ matrix.shells.shell }}" contrib/various_test.sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/windows-busybox.yml b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/windows-busybox.yml new file mode 100644 index 0000000..a7756ad --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/windows-busybox.yml @@ -0,0 +1,28 @@ +name: Windows busybox + +on: [push, pull_request] + +env: + PATH: 'C:\Program Files\Git\bin;C:\Windows\System32;C:\Windows;C:\ProgramData\Chocolatey\bin' + FORCE_COLOR: 1 + +defaults: + run: + shell: cmd + +jobs: + windows-busybox: + runs-on: windows-latest + if: "!contains(github.event.head_commit.message, 'ci skip')" + strategy: + matrix: + shells: + - {shell: sh} + - {shell: ash} + - {shell: bash} + fail-fast: false + steps: + - uses: actions/checkout@v2 + - run: choco install -y --no-progress busybox + - run: busybox ${{ matrix.shells.shell }} ./shellspec --task fixture:stat:prepare + - run: busybox ${{ matrix.shells.shell }} ./shellspec diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/windows-cygwin.yml b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/windows-cygwin.yml new file mode 100644 index 0000000..fcb20da --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/windows-cygwin.yml @@ -0,0 +1,35 @@ +name: Windows Cygwin + +on: [push, pull_request] + +env: + PATH: 'C:\tools\cygwin\bin;C:\Program Files\Git\bin;C:\Windows\System32;C:\Windows;C:\Windows\System32\WindowsPowerShell\v1.0;C:\ProgramData\Chocolatey\bin' + FORCE_COLOR: 1 + +defaults: + run: + shell: cmd + +jobs: + windows-cygwin: + runs-on: windows-latest + if: "!contains(github.event.head_commit.message, 'ci skip')" + strategy: + matrix: + shells: + - {shell: sh, package: sh} + - {shell: dash, package: dash} + - {shell: bash, package: bash} + - {shell: ash, package: busybox} + - {shell: mksh, package: mksh} + - {shell: posh, package: posh} + - {shell: zsh, package: zsh} + fail-fast: false + steps: + - uses: actions/checkout@v2 + - run: choco install -y --no-progress cygwin cyg-get + - run: cyg-get nc ${{ matrix.shells.package }} + - run: cygcheck -c + - run: ${{ matrix.shells.shell }} ./shellspec --task fixture:stat:prepare + - run: ${{ matrix.shells.shell }} -c "rm helper/fixture/stat/no-permission" + - run: ${{ matrix.shells.shell }} ./shellspec diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/windows-gitbash.yml b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/windows-gitbash.yml new file mode 100644 index 0000000..a627a18 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/windows-gitbash.yml @@ -0,0 +1,27 @@ +name: Windows GitBash + +on: [push, pull_request] + +env: + PATH: 'C:\Program Files\Git\bin;C:\windows\system32;C:\windows' + FORCE_COLOR: 1 + +defaults: + run: + shell: bash + +jobs: + windows-gitbash: + runs-on: windows-latest + if: "!contains(github.event.head_commit.message, 'ci skip')" + strategy: + matrix: + shells: + - {shell: sh} + - {shell: dash} + - {shell: bash} + fail-fast: false + steps: + - uses: actions/checkout@v2 + - run: ${{ matrix.shells.shell }} ./shellspec --task fixture:stat:prepare + - run: ${{ matrix.shells.shell }} ./shellspec diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/windows-msys.yml b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/windows-msys.yml new file mode 100644 index 0000000..15d7932 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.github/workflows/windows-msys.yml @@ -0,0 +1,32 @@ +name: Windows MSYS + +on: [push, pull_request] + +env: + PATH: 'C:\msys64\usr\bin;C:\Program Files\Git\bin;C:\windows\system32;C:\windows' + FORCE_COLOR: 1 + +defaults: + run: + shell: cmd + +jobs: + windows-msys: + runs-on: windows-latest + if: "!contains(github.event.head_commit.message, 'ci skip')" + strategy: + matrix: + shells: + - {shell: sh, package: sh} + - {shell: dash, package: dash} + - {shell: bash, package: bash} + - {shell: busybox ash, package: busybox} + - {shell: mksh, package: mksh} + - {shell: zsh, package: zsh} + fail-fast: false + steps: + - uses: actions/checkout@v2 + - run: pacman.exe -Syu --noprogressbar --noconfirm + - run: pacman.exe -S --noprogressbar --noconfirm ${{ matrix.shells.package }} + - run: ${{ matrix.shells.shell }} ./shellspec --task fixture:stat:prepare + - run: ${{ matrix.shells.shell }} ./shellspec diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.gitignore b/tests/shellspec/.vendor/shellspec-0.28.1/.gitignore new file mode 100644 index 0000000..138bdd1 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.gitignore @@ -0,0 +1,7 @@ +.env +.shellspec-local +.shellspec-quick.log +/*.tar.gz +report +coverage* +ttyrecord diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.shellcheck-version b/tests/shellspec/.vendor/shellspec-0.28.1/.shellcheck-version new file mode 100644 index 0000000..63f2359 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.shellcheck-version @@ -0,0 +1 @@ +v0.7.1 diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.shellspec b/tests/shellspec/.vendor/shellspec-0.28.1/.shellspec new file mode 100644 index 0000000..d747816 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.shellspec @@ -0,0 +1,11 @@ +--require spec_helper +--require ksh_workaround +--helperdir helper +--sandbox +--skip-message moderate +--fail-no-examples +--env-from helper/env.sh +--kcov-options "--include-pattern=" +--kcov-options "--include-path=./shellspec,./install.sh,./lib,./libexec" +--kcov-options "--exclude-pattern=/.,_generated.sh" +--hide-deprecations diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/.travis.yml b/tests/shellspec/.vendor/shellspec-0.28.1/.travis.yml new file mode 100644 index 0000000..ca6617e --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/.travis.yml @@ -0,0 +1,67 @@ +language: shell +os: linux +dist: bionic +env: + global: + - PATH=${PATH}:${HOME}/kcov/bin + - CC_TEST_REPORTER_URL=https://codeclimate.com/downloads/test-reporter/test-reporter-latest-darwin-amd64 + - CC_TEST_REPORTER_ID=67e0534ee993a6bbd10ae205ef4e807956c01564564ed64738932db123b1b87a +addons: + apt: + update: true +jobs: + include: +# - os: linux # Ubuntu 12.04 +# dist: precise +# env: PACKAGES="dash bash zsh ksh mksh yash busybox" +# - os: linux # Ubuntu 14.04 +# dist: trusty +# env: PACKAGES="dash bash zsh ksh mksh yash posh busybox" +# - os: linux # Ubuntu 16.04 +# dist: xenial +# env: PACKAGES="dash bash zsh ksh mksh yash posh busybox" +# - os: linux # Ubuntu 18.04 +# dist: bionic +# env: PACKAGES="dash bash zsh ksh mksh yash posh busybox" +# - os: linux # Ubuntu 20.04 +# dist: focal +# env: PACKAGES="dash bash zsh ksh mksh yash posh busybox" +# - os: osx # macOS Homebrew +# osx_image: xcode11.5 +# env: FORMULAS="dash bash zsh ksh mksh yash" + - os: osx # macOS 10.10 Yosemite 2014-06 + osx_image: xcode6.4 + env: SHELLS="sh bash zsh ksh" + - os: osx # macOS 10.11 El Capitan 2015-06 + osx_image: xcode8 + env: SHELLS="sh bash zsh ksh" + - os: osx # macOS 10.12 Sierra 2016-06 + osx_image: xcode9.2 + env: SHELLS="sh bash zsh ksh" + - os: osx # macOS 10.13 High Sierra 2017-06 + osx_image: xcode10.1 + env: SHELLS="sh bash zsh ksh" + - os: osx # macOS 10.14 Mojave 2018-06 + osx_image: xcode10.2 + env: SHELLS="sh bash zsh ksh" +# - os: osx # macOS 10.15.4 Catalina 2020-03 +# osx_image: xcode11.5 +# env: SHELLS="sh bash zsh ksh" + - os: osx # coverage + osx_image: xcode12.2 + env: FORMULAS="bash kcov" COVERAGE=1 CODECOV=1 CC=1 +before_install: + - if [ "$PACKAGES" ]; then sudo apt-get install -y $PACKAGES; fi + - if [ "$FORMULAS" ]; then brew update; brew install $FORMULAS; fi + - if [ "$CC" ]; then curl -sSL $CC_TEST_REPORTER_URL > ./cc-test-reporter; fi + - if [ "$CC" ]; then chmod +x ./cc-test-reporter; fi + - if [ "$CC" ]; then ./cc-test-reporter before-build; fi +before_script: + - ./shellspec --shell sh --task fixture:stat:prepare +script: + - if [ ! "$COVERAGE" ]; then contrib/all.sh contrib/various_test.sh; fi + - if [ "$COVERAGE" ]; then ./shellspec --shell bash --kcov --kcov-options "--coveralls-id=${TRAVIS_JOB_ID}"; fi +after_success: + - if [ "$CODECOV" ]; then bash <(curl -s https://codecov.io/bash) -s coverage; fi + - if [ "$CC" ]; then ./cc-test-reporter format-coverage coverage/cobertura.xml -t cobertura; fi + - if [ "$CC" ]; then ./cc-test-reporter upload-coverage; fi diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/CHANGELOG.md b/tests/shellspec/.vendor/shellspec-0.28.1/CHANGELOG.md new file mode 100644 index 0000000..5530b23 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/CHANGELOG.md @@ -0,0 +1,576 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [0.28.1] - 2021-01-11 + +### Changed + +- Improved documentation. Thanks to Yohei Kawahara (#173). + +### Fixed + +- bash: Fixed an unexpected error message in self-executable specfile. +- Fixed a bug that test command cannot redefine when using "when run source" +- Fixed a bug when specified relative tmp directory path. +- Fixed option parsing + +## [0.28.0] - 2021-01-05 + +### Added + +- Added `BeforeEach` / `AfterEach` as synonym for `Before` / `After`. +- Added `FORCE_COLOR` environment variable. +- Added `--tmpdir` option. +- Added `--execdir` option to specify the directory for specfile execution. +- Added `-c` (`--chdir`) and `-C` (`--directory`) options to change directory at startup. +- Added path syntax (`*/` and `**/`) and `-L` (`--dereference`) option to match recursive directories. +- Added `--helperdir` to specify the location of `spec_helper` etc. +- Added the environment variable `SHELLSPEC_HELPERDIR` to indicate the location of `spec_helper` etc. +- Added `--reportdir` and `--covdir` options. +- Added `-O` (`--option`) option. +- Added `-I` (`--load-path`) option. +- Added `_precheck` callback and some helper functions to `spec_helper` for pre-checking. +- Added `_loaded` callback to be called after `spec_helper` loading. + +### Changed + +- Replaced with a new option parser [getoptions](https://github.com/ko1nksm/getoptions) which supports the standard option syntax. +- Replaced `--keep-tempdir` with `--keep-tmpdir`. +- Specifying a file in the shellspec's argument is now ignored if it does not match `--pattern`. +- Filled in system-out and system-err in junit xml. +- Allowed run the tests from any subdirectory. +- The `-D` option has been deprecated (Replace with the `--default-path` option). +- The environment variable `SHELLSPEC_SPECDIR` has been deprecated since there is not always a single directory for specfiles. +- Rename `.shellspec-profiler.log` to `profiler.log` for profiler log. +- Accept `banner.md` as a banner file +- `Include` and `import` (`shellspec_import`) can now pass arguments. +- The delimiter of the environment variable `SHELLSPEC_REQUIRES` has been changed from `:` to space. +- Improved documentation. Thanks to ldicarlo (#117, #119), Antoni Marcinek (#120, #139), Stuart R. Jefferys (#155), Leon Stafford (#159). + +### Removed + +- Removed `--kcov-common-options` option. + +### Fixed + +- bash 4.1 - 4.3: Fixed a bug that `run script` could not get the exit status. +- zsh < 4.2.0: Fixed a bug when extendedglob is enabled. +- Fixed possibility of I/O error in satisfy matcher (GitHub Actions only?). +- Fixed a bug in which zsh on macOS occasionally exits with exit code 147 (SIGCONT). +- Fixed several bugs related to the Windows path for busybox-w32. +- Fixed a bug when using metacharacters for tags. + +## [0.27.2] - 2020-10-28 + +### Fixed + +- Fixed a bug that didn't cause an error if there are fixed examples. + +## [0.27.1] - 2020-09-30 + +### Removed + +- Drop support for posh 0.8.5 due to signal handling broken. + +### Fixed + +- Fixed gray color. +- Fixed broken `--warning-as-failure`. +- Fixed a bug that can not CTRL-C with posh. + +## [0.27.0] - 2020-09-25 + +### Added + +- **Added `be exported` and `be readonly` matchers.** +- Added `%printf` and `%sleep` directives. + +### Changed + +- **Improved TAP formatter.** + - Supports `TODO` and `SKIP` directives. + - Use `Bail out!` on error. + - Added error details. +- `BeforeAll` / `AfterAll`: Avoid crashes due to hook errors. +- `Before` / `After`: Improved hook error handling. +- `BeforeCall` / `AfterCall`, `BeforeRun` / `AfterRun`: Minor changes. + +### Removed + +- Drop support for dash 0.5.3 due to unstable bug. +- Drop support for busybox < 1.20.0 due to unstable bug. + +### Fixed + +- Fixed a bug that "Parameter is not set" error in word modifier. +- Fixed a bug that satisfy matcher succeed even syntax error. +- Fixed a bug that can not CTRL-C with parallel execution on zsh. +- shellspec-syntax-check.sh: Some minor bug fixes. + +## [0.26.1] - 2020-07-13 + +### Added + +- **Added `--docker` option.** (EXPERIMENTAL) + +## [0.26.0] - 2020-07-12 + +### Added + +- **Added `Mock` helper (command-based mock).** +- **Added `%preserve` directive.** +- **Added `--sandbox`, `--sandbox-path` option.** +- Added `--path` option. + +### Fixed + +- Workaround when the Windows version of `sort.exe` is executed. + +## [0.25.0] - 2020-06-21 + +### Added + +- **Coverage support for zsh and ksh.** (#62) +- Respect `NO_COLOR` environment variable. +- Support [busybox-w32](https://frippery.org/busybox/) ash for windows. +- **Added `Assert` expectation to assert side effects of system environment.** +- Added `Dump` helper - dump stdout, stderr and status for debugging. +- Added `line` and `word` subject. (`of stdout (output)` can be omitted now) +- Added `--log-file` option to specify log file for `%logger` and trace. +- **Implement `--xtrace` (`--xtrace-only`) feature.** + +### Changed + +- Upgrade to alpine 3.12 for docker image and officially release `shellspec/kcov` docker image. +- Separate a file descriptor for reporting and stdout to able to use `echo` in specfile. +- Minor specification change of `result` modifier and `satisfy` matcher. +- `-r` option is now a short option for `--repair`, not `--require`. +- Use [debian/eol(https://hub.docker.com/r/debian/eol/) docker images for old debian tests. + +### Fixed + +- Before/After hooks should not consume stdin data (#82) + +## [0.24.3] - 2020-06-06 + +### Fixed + +- Fixes `BeforeAll` / `AfterAll` to share states + +## [0.24.2] - 2020-05-27 + +### Fixed + +- Fixed a bug "SHELLSPEC_GROUP_ID: unbound variable" +- Fixes when ran by "bash shellcpec" and "ksh shellspec" + +## [0.24.1] - 2020-05-22 + +### Fixed + +- Fixed broken `Todo`. +- Fixed a bug that caused an error when "--kcov" was specified and /dev/tty no be writable. (#67 Alexander Reitzel) +- Fixed a bug when enabled extendedglob for zsh. + +## [0.24.0] - 2020-05-11 + +### Added + +- Add `BeforeAll` and `AfterAll`. (#7) +- Expand parameter within Data helper. (#57) +- Add test for [GWSH shell](https://github.com/hvdijk/gwsh). +- Add manual test for OpenBSD ksh on OpenBSD 6.6. +- Add manual test for NetBSD sh on NetBSD 9.0. + +### Removed + +- Removed `match` matcher. Use `match pattern` matcher instead. +- Remove tests for unstable old shells (Bus Error, Bad address, Memory fault, etc). + - CI test for pdksh 5.2.14 on FreeBSD. + - Docker test for pdksh 5.2.14 on Debian 2.2r7. + - Docker test for ksh 93q on Debian 3.1r8. +- Remove tests for FreeBSD 13.0-current (Unstable due to work in progress). + +## [0.23.0] - 2020-04-02 + +### Added + +- New **quick execution** and related options (`--quick`, `--repair`, `--next`). +- New **failures formatter**. +- Support **self-executable specfile**. (#40) +- Add `--pending-message` and `--quiet` option. +- Add short options for focus and filters. +- Add `-w` short options for `--warning-as-failure`. +- Add `--boost` (joke) option. +- Reporter: Displays comments of 'temporary skip' and 'temporary pending'. +- Support windows line endings. (#45) +- Syntax check for missing `End` of parameters. +- shellspec --init: generate ignore file for cvs. + +### Changed + +- Run the specfile specified by arguments even not end with `_spec.sh`. +- Formatter: Change fixed color. +- Formatter: Change mark for fixed and pending of progress formatter. + +### Fixed + +- Fixed `--pattern` option to avoid syntax error. +- Return exit status code on the specfile properly. +- Fixed a bug that `start with` and `end with` match glob pattern. +- Formatter: Fixed not display correctly of documentation formatter when description is empty. +- Fixed an issue installer.sh fails in some environments. (#43) + +### Deprecated + +- Use `--require` long option instead of `-r` short option. + +## [0.22.0] - 2020-02-22 + +### Added + +- Improve kcov version detection. +- Colored TAP formatter. (#34 Kylie McClain) +- Added `--show-deprecations` and `--hide-deprecations` options. + +### Changed + +- New **kcov integration**. + - Do not create translated specfile in project directory. + - Suppress unnecessary coverage measurement to improve testing speed. + - Added `--coverage-report-info` to add extra information to coverage report. +- make install compatible with BSD and macOS. +- Suppress unnecessary before/after hooks of skipped examples. +- install.sh: Install to under $HOME/.local by default +- Use $HOME/.config if not defined XDG_CONFIG_HOME + +### Deprecated + +- `--kcov-common-options` is deprecated, merge into `--kcov-options`. +- Deprecates the `match` matcher due to cause many syntax errors. Use `match pattern` matcher instead. + +### Fixed + +- Fixed broken test in docker on Linux. +- Fixed `--example` option to avoid syntax error. +- Append to LOGFILE instead of overwriting. + +## [0.21.0] - 2020-01-30 + +### Added + +- Provide **docker images**. +- Provide **distribution archive**. +- Available ArchLinux package. (#15 Damien Flament) + +### Changed + +- docs: Improve English quality. (#16 Damien Flament) + +## [0.20.2] - 2019-08-24 + +### Fixed + +- Fixed wrong SHELLSPEC_TMPBASE +- Fixed for bug that some shell can not call external command same name as builtin. + +## [0.20.1] - 2019-08-19 + +### Fixed + +- Fixed for solaris. + +## [0.20.0] - 2019-08-18 + +### Added + +- Add **parameterized example**. (`Parameters` helper) +- Add `Set` helper for set shell option +- Add `BeforeCall` / `AfterCall` helper. +- Add `BeforeRun` / `AfterRun` helper. +- Use `hexdump` if `od` does not exist. + +### Changed + +- Redesign `run` evaluation. [**major breaking change**] + - Change the behavior to close to the `run` of bats. + - New `run` evaluation allows the execution of functions and commands. + - Use `run command` to execute only the commands. (old `run` -> use `run command`) + - Merge `invoke` evaluation to `run` evaluation. (old `invoke` -> use `run`) + - Merge `execute` evaluation to `run` evaluation. (old `execute` -> use `run source`) +- Export %const values to the translation process + +### Removed + +- Drop support for posh 0.10.2 and similar versions as the handling of the shell flag is broken. + +### Fixed + +- Fixed bug for related with tag. +- Fixed bug where coverage might not work on macOS. + +## [0.19.1] - 2019-07-23 + +### Added + +- Support install via make, bpkg, basher + +## [0.19.0] - 2019-07-22 + +### Added + +- Add installer (It has not been officially released, but you can used it already). +- Testing for **single script file** (Add `execute` evaluation, `Intercept` and `__SOURCED__` variable). +- Add `--keep-tempdir` option. +- Add `Data < ` syntax. + +### Removed + +- Drop support for busybox 1.1.3 and similar versions as it can not redefine builtin commands. +- Drop support for ash 0.3.8 and similar versions as it can not use retrun in sourced script. +- Remove `call`/`invoke` `` syntax. + +## [0.18.0] - 2019-07-09 + +### Added + +- **Profiler feature** (`--profile`) +- Time attribute for JUnit XML. + +## [0.17.0] - 2019-07-06 + +### Added + +- **Coverage reporting**. +- Add `--fail-low-coverage` option. + +## [0.16.0] - 2019-07-03 + +### Added + +- **Coverage** support (kcov integration) +- Add **JUnit formatter** and **report generator**. +- Add `--warning-as-failure` option. +- Support [Unofficial Bash Strict Mode](http://redsymbol.net/articles/unofficial-bash-strict-mode/). +- Support for [Schily Bourne Shell](http://schilytools.sourceforge.net/bosh.html) (`bosh`, `pbosh`). + +### Changed + +- Change `--skip-message none` to `--skip-message verbose`. + +### Removed + +- Remove `--warnings` option. + +## [0.15.0] - 2019-05-26 + +### Added + +- Add `be empty directory` (alias: `be empty dir`) matcher. + +### Changed + +- Rename `be empty` matcher to `be empty file` matcher. [breaking change] + +### Fixed + +- Fixed bug that `be empty` (renamed to `be empty file`) matcher matches not exists file, etc. +- Ensure call & invoke start with errno zero (#2 Rowan Thorpe) + +## [0.14.0] - 2019-05-15 + +### Added + +- Add `--random` option. + +### Changed + +- Improve `--example`, `--tag` option. + +## [0.13.1] - 2019-05-13 + +### Fixed + +- Fixed bug when --dry-run mode. +- Fixed documentation formatter. + +## [0.13.0] - 2019-05-12 + +### Added + +- Add `--list examples:id` option. +- Add `*_spec.sh:@ID` syntax the specify id with the filename. +- Add `--pattern`, `--example`, `--tag`, `--default-path` filter option. + +### Changed + +- Change `Logger` Helper to `%logger` directive. +- Merge `--list-specfiles`, `--list-examples` options to `--list` option. +- Redesign reporter to improve performance, maintainability. + +## [0.12.0] - 2019-04-26 + +### Added + +- Add `--list-specfiles`, `--list-examples` option. +- Add `--env-from` option. +- Add tests that for array if supported shells. + +### Changed + +- Change `--count` option output includes the number of specfiles. +- Change to the banner show only on shellspec-runner. + +## [0.11.3] - 2019-04-24 + +### Fixed + +- Fixed broken parallel executor. + +## [0.11.2] - 2019-04-23 + +### Fixed + +- Fixed bug that does not work with zsh 5.4.2. + +## [0.11.1] - 2019-04-21 + +### Fixed + +- Fixed ignored specified line number when parallel execution. +- Fixed documentation formatter when supplied multiple specfiles. + +## [0.11.0] - 2019-04-20 + +### Added + +- Run **the example by line number**. (`*_spec.sh:#`) +- Run **focused groups / examples**. (`fDescribe`, `fContext`, `fExample`, `fSpecify`, `fIt`) +- Add `--count` option for count the number of examples without running. + +## [0.10.0] - 2019-04-17 + +### Added + +- Support **parallel execution**. (`--jobs` option) + +### Changed + +- Separete syntax checker into tools. +- Improve syntax checker. +- Improve error handling. +- Improve ctrl-c handling. + +### Removed + +- Remove `Def` helper. (use `%putsn`, `%puts` directive instead) + +## [0.9.0] - 2019-03-30 + +### Added + +- Add `--syntax-check` option for syntax check of the specfile. + +### Changed + +- Change timing of loading external script by 'Include'. [breaking change] + +### Fixed + +- Fix for translation speed slowdown. + +### Removed + +- Remove shorthand of the variable subject. + +## [0.8.0] - 2019-03-26 + +### Added + +- Add `Constant definition`. +- Add `Data` helper, `Embedded text`. +- Add `Def` helper. +- Add `Logger` helper. +- Add `result` modifier. +- Add `Include` helper. +- Add shorthand for `function` subject and `variable` subject. +- Add failed message for `Before`/`After` each hook. + +### Changed + +- Change behavior of `line` and `lines` modifier to like "grep -c" not "wc -l". +- Change `function` subject to alias for `value` subject. +- Improve handling unexpected errors. +- Improve examples. + +### Removed + +- Remove `It` statement and change `It` is alias of `Example` now. +- Remove `Set` / `Unset` helper. +- Remove `Debug` helper. +- Remove `string` subject. +- Remove `exit status` subject. (use `status` subject) + +## [0.7.0] - 2019-03-08 + +### Added + +- Added `lines` modifier. + +## [0.6.0] - 2019-02-19 + +### Added + +- Added `match` matcher. + +## [0.5.0] - 2019-02-06 + +### Added + +- Initial public release. + +[Unreleased]: https://github.com/shellspec/shellspec/compare/0.28.1...HEAD +[0.28.1]: https://github.com/shellspec/shellspec/compare/0.28.0...0.28.1 +[0.28.0]: https://github.com/shellspec/shellspec/compare/0.27.2...0.28.0 +[0.27.2]: https://github.com/shellspec/shellspec/compare/0.27.1...0.27.2 +[0.27.1]: https://github.com/shellspec/shellspec/compare/0.27.0...0.27.1 +[0.27.0]: https://github.com/shellspec/shellspec/compare/0.26.1...0.27.0 +[0.26.1]: https://github.com/shellspec/shellspec/compare/0.26.0...0.26.1 +[0.26.0]: https://github.com/shellspec/shellspec/compare/0.25.0...0.26.0 +[0.25.0]: https://github.com/shellspec/shellspec/compare/0.24.3...0.25.0 +[0.24.3]: https://github.com/shellspec/shellspec/compare/0.24.2...0.24.3 +[0.24.2]: https://github.com/shellspec/shellspec/compare/0.24.1...0.24.2 +[0.24.1]: https://github.com/shellspec/shellspec/compare/0.24.0...0.24.1 +[0.24.0]: https://github.com/shellspec/shellspec/compare/0.23.0...0.24.0 +[0.23.0]: https://github.com/shellspec/shellspec/compare/0.22.0...0.23.0 +[0.22.0]: https://github.com/shellspec/shellspec/compare/0.21.0...0.22.0 +[0.21.0]: https://github.com/shellspec/shellspec/compare/0.20.2...0.21.0 +[0.20.2]: https://github.com/shellspec/shellspec/compare/0.20.1...0.20.2 +[0.20.1]: https://github.com/shellspec/shellspec/compare/0.20.0...0.20.1 +[0.20.0]: https://github.com/shellspec/shellspec/compare/0.19.0...0.20.0 +[0.19.1]: https://github.com/shellspec/shellspec/compare/0.19.0...0.19.1 +[0.19.0]: https://github.com/shellspec/shellspec/compare/0.18.0...0.19.0 +[0.18.0]: https://github.com/shellspec/shellspec/compare/0.17.0...0.18.0 +[0.17.0]: https://github.com/shellspec/shellspec/compare/0.16.0...0.17.0 +[0.16.0]: https://github.com/shellspec/shellspec/compare/0.15.0...0.16.0 +[0.15.0]: https://github.com/shellspec/shellspec/compare/0.14.0...0.15.0 +[0.14.0]: https://github.com/shellspec/shellspec/compare/0.13.1...0.14.0 +[0.13.1]: https://github.com/shellspec/shellspec/compare/0.13.0...0.13.1 +[0.13.0]: https://github.com/shellspec/shellspec/compare/0.12.0...0.13.0 +[0.12.0]: https://github.com/shellspec/shellspec/compare/0.11.3...0.12.0 +[0.11.3]: https://github.com/shellspec/shellspec/compare/0.11.2...0.11.3 +[0.11.2]: https://github.com/shellspec/shellspec/compare/0.11.1...0.11.2 +[0.11.1]: https://github.com/shellspec/shellspec/compare/0.11.0...0.11.1 +[0.11.0]: https://github.com/shellspec/shellspec/compare/0.10.0...0.11.0 +[0.10.0]: https://github.com/shellspec/shellspec/compare/0.9.0...0.10.0 +[0.9.0]: https://github.com/shellspec/shellspec/compare/0.8.0...0.9.0 +[0.8.0]: https://github.com/shellspec/shellspec/compare/0.7.0...0.8.0 +[0.7.0]: https://github.com/shellspec/shellspec/compare/0.6.0...0.7.0 +[0.6.0]: https://github.com/shellspec/shellspec/compare/0.5.0...0.6.0 +[0.5.0]: https://github.com/shellspec/shellspec/commits/0.5.0 diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/CONTRIBUTING.md b/tests/shellspec/.vendor/shellspec-0.28.1/CONTRIBUTING.md new file mode 100644 index 0000000..3c1ed20 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/CONTRIBUTING.md @@ -0,0 +1,16 @@ +# CONTRIBUTING + +## For developer + +1. To understand the [architecture](docs/architecture.md) +2. About [reporter](docs/reporter.md) +3. About various [shells](docs/shells.md) +4. How to [test](docs/test.md) + +### About specfile translation process + +The specfile is a valid shell script, but a translation process is performed to implement the scope, +line number etc. Each example group block and example block is translated to commands in a subshell. +Therefore changes inside those blocks do not affect the outside of the block. In other words it realizes +local variables and local functions in the specfile. This is very useful for describing a structured spec. +If you are interested in how to translate, use the `--translate` option. diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/LICENSE b/tests/shellspec/.vendor/shellspec-0.28.1/LICENSE new file mode 100644 index 0000000..977b5e4 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Koichi Nakashima + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/Makefile b/tests/shellspec/.vendor/shellspec-0.28.1/Makefile new file mode 100644 index 0000000..2cde5ca --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/Makefile @@ -0,0 +1,66 @@ +PREFIX ?= /usr/local +BINDIR := $(PREFIX)/bin +LIBDIR := $(PREFIX)/lib + +GETOPTIONSCLI := getoptions-cli --indent=2 --shellcheck +OPTPARSERDIR := lib/libexec/optparser + +.PHONY: coverage test dist build release + +all: test check + +dist: LICENSE shellspec lib libexec + tar -czf shellspec-dist.tar.gz $^ --transform 's,^,shellspec/,' + +install: + install -d "$(BINDIR)" "$(LIBDIR)" + install stub/shellspec "$(BINDIR)/shellspec" + find lib libexec -type d -exec install -d "$(LIBDIR)/shellspec/{}" \; + find LICENSE lib -type f -exec install -m 644 {} "$(LIBDIR)/shellspec/{}" \; + find shellspec libexec -type f -exec install {} "$(LIBDIR)/shellspec/{}" \; + +uninstall: + rm -rf "$(BINDIR)/shellspec" "$(LIBDIR)/shellspec" + +package: + contrib/make_package_json.sh > package.json + +optparser: + @printf "getoptions: " + @$(GETOPTIONSCLI) --version + $(GETOPTIONSCLI) $(OPTPARSERDIR)/parser_definition.sh \ + optparser_parse SHELLSPEC optparser_error \ + > $(OPTPARSERDIR)/parser_definition_generated.sh + +demo: + ttyrec -e "ghostplay contrib/demo.sh" + seq2gif -l 5000 -h 32 -w 139 -p win -i ttyrecord -o docs/demo.gif + gifsicle -i docs/demo.gif -O3 -o docs/demo.gif + +coverage: + contrib/coverage.sh --pull + +check: + contrib/check.sh --pull + +metrics: + contrib/metrics.sh + +build: + contrib/build.sh .dockerhub/Dockerfile shellspec + contrib/build.sh .dockerhub/Dockerfile shellspec kcov + contrib/build.sh .dockerhub/Dockerfile.debian shellspec-debian + contrib/build.sh .dockerhub/Dockerfile.debian shellspec-debian kcov + contrib/build.sh .dockerhub/Dockerfile.scratch shellspec-scratch + +test: + ./shellspec + +test_all: + contrib/all.sh shellspec + +test_in_docker: + contrib/test_in_docker.sh --pull dockerfiles/* -- shellspec -j 2 + +release: + contrib/release.sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/README.md b/tests/shellspec/.vendor/shellspec-0.28.1/README.md new file mode 100644 index 0000000..edb62b9 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/README.md @@ -0,0 +1,2122 @@ +# ShellSpec + +ShellSpec is a **full-featured BDD unit testing framework** for dash, bash, ksh, zsh and **all POSIX shells** that provides first-class features such as code coverage, mocking, parameterized test, parallel execution and more. It was developed as a dev/test tool for **cross-platform shell scripts and shell script libraries**. ShellSpec is a new modern testing framework released in 2019, but it's already stable enough. With lots of practical CLI features and simple yet powerful syntax, it provides you with a fun shell script test environment. + +[![GitHub Actions Status](https://img.shields.io/github/workflow/status/shellspec/shellspec/Release?label=GithubActions&style=flat-square)](https://github.com/shellspec/shellspec/actions) +[![Travis CI](https://img.shields.io/travis/com/shellspec/shellspec/master.svg?label=TravisCI&style=flat-square)](https://travis-ci.com/shellspec/shellspec) +[![Cirrus CI](https://img.shields.io/cirrus/github/shellspec/shellspec.svg?label=CirrusCI&style=flat-square)](https://cirrus-ci.com/github/shellspec/shellspec) +[![Circle CI](https://img.shields.io/circleci/build/github/shellspec/shellspec.svg?label=CircleCI&style=flat-square)](https://circleci.com/gh/shellspec/shellspec) +[![Docker Cloud Automated build](https://img.shields.io/docker/cloud/automated/shellspec/shellspec?style=flat-square&label=DockerHub)![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/shellspec/shellspec?style=flat-square&label=builds)](https://hub.docker.com/r/shellspec/shellspec)
+[![Kcov](https://img.shields.io/badge/dynamic/json.svg?label=Kcov&query=percent_covered&suffix=%25&url=https%3A%2F%2Fcircleci.com%2Fapi%2Fv1.1%2Fproject%2Fgithub%2Fshellspec%2Fshellspec%2Flatest%2Fartifacts%2F0%2Fcoverage%2Fcoverage.json%3Fbranch%3Dmaster&style=flat-square)](https://circleci.com/api/v1.1/project/github/shellspec/shellspec/latest/artifacts/0/coverage/index.html?branch=master) +[![Coveralls](https://img.shields.io/coveralls/github/shellspec/shellspec.svg?label=Coveralls&style=flat-square)](https://coveralls.io/github/shellspec/shellspec?branch=master) +[![Code Climate](https://img.shields.io/codeclimate/coverage/shellspec/shellspec?label=CodeClimate&style=flat-square)](https://codeclimate.com/github/shellspec/shellspec) +[![Codecov](https://img.shields.io/codecov/c/github/shellspec/shellspec.svg?label=Codecov&style=flat-square)](https://codecov.io/gh/shellspec/shellspec) +[![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/shellspec/shellspec?label=CodeFactor&style=flat-square)](https://www.codefactor.io/repository/github/shellspec/shellspec) +[![GitHub top language](https://img.shields.io/github/languages/top/shellspec/shellspec.svg?style=flat-square)](https://github.com/shellspec/shellspec/search?l=Shell) +[![GitHub release](https://img.shields.io/github/release/shellspec/shellspec.svg?style=flat-square)](https://github.com/shellspec/shellspec/releases/latest) +[![License](https://img.shields.io/github/license/shellspec/shellspec.svg?style=flat-square)](https://github.com/shellspec/shellspec/blob/master/LICENSE) + +[![bash](https://img.shields.io/badge/bash-≥2.03-lightgrey.svg?style=flat)](https://www.gnu.org/software/bash/) +[![bosh](https://img.shields.io/badge/bosh-≥2018%2F10%2F07-lightgrey.svg?style=flat)](http://schilytools.sourceforge.net/bosh.html) +[![busybox](https://img.shields.io/badge/busybox-≥1.20.0-lightgrey.svg?style=flat)](https://www.busybox.net/) +[![dash](https://img.shields.io/badge/dash-≥0.5.4-lightgrey.svg?style=flat)](http://gondor.apana.org.au/~herbert/dash/) +[![ksh](https://img.shields.io/badge/ksh-≥93s-lightgrey.svg?style=flat)](http://kornshell.org) +[![mksh](https://img.shields.io/badge/mksh-≥R28-lightgrey.svg?style=flat)](http://www.mirbsd.org/mksh.htm) +[![posh](https://img.shields.io/badge/posh-≥0.3.14-lightgrey.svg?style=flat)](https://salsa.debian.org/clint/posh) +[![yash](https://img.shields.io/badge/yash-≥2.29-lightgrey.svg?style=flat)](https://yash.osdn.jp/) +[![zsh](https://img.shields.io/badge/zsh-≥3.1.9-lightgrey.svg?style=flat)](https://www.zsh.org/) + +---- + +**Version 0.28.0** has a lot of enhancements in the CLI. It is basically compatible, but there are some changes that you need to be aware of. See [Migration Guide to Version 0.28.0](https://github.com/shellspec/shellspec/wiki/Migration-Guide-to-Version-0.28.0) for details. + +---- + +**Thank you for your interest in ShellSpec. Please visit 🚩[the official website](https://shellspec.info/) to know the impressive features!** + +Let's have fun testing your shell scripts! (Try [Online Demo](https://shellspec.info/demo) on your browser). + +[![demo](docs/demo.gif)](https://shellspec.info/demo) + +[![Coverage report](docs/coverage.png)](https://circleci.com/api/v1.1/project/github/shellspec/shellspec/latest/artifacts/0/coverage/index.html?branch=master) + +**Latest Update.** + +See [CHANGELOG.md](CHANGELOG.md) + +NOTE: This documentation contains unreleased features. Check them in the changelog. + +---- + +## Table of Contents + +- [Supported shells and platforms](#supported-shells-and-platforms) +- [Requirements](#requirements) +- [Installation](#installation) + - [Web installer (for developers)](#web-installer-for-developers) + - [Package manager](#package-manager) + - [Manual installation](#manual-installation) + - [Distribution archive (runtime only)](#distribution-archive-runtime-only) +- [Tutorial](#tutorial) +- [ShellSpec CLI](#shellspec-cli) + - [runs specfile using `/bin/sh` by default](#runs-specfile-using-binsh-by-default) + - [command options](#command-options) +- [Project directory](#project-directory) + - [Typical directory structure](#typical-directory-structure) + - [Options file](#options-file) + - [`.shellspec` - project options file](#shellspec---project-options-file) + - [`.shellspec-local` - user custom options file](#shellspec-local---user-custom-options-file) + - [`.shellspec-basedir` - specfile execution base directory](#shellspec-basedir---specfile-execution-base-directory) + - [`.shellspec-quick.log` - quick execution log](#shellspec-quicklog---quick-execution-log) + - [`report/` - report file directory](#report---report-file-directory) + - [`coverage/` - coverage reports directory](#coverage---coverage-reports-directory) + - [`spec/` - (default) specfiles directory](#spec---default-specfiles-directory) + - [\ (default: `spec/`)](#helperdir-default-spec) + - [`spec_helper.sh` - (default) helper file for specfile](#spec_helpersh---default-helper-file-for-specfile) + - [`banner[.md]` - banner file displayed at test execution](#bannermd---banner-file-displayed-at-test-execution) + - [`support/` - directory for support files](#support---directory-for-support-files) + - [`bin` - directory for support commands](#bin---directory-for-support-commands) +- [Specfile (test file)](#specfile-test-file) + - [Example](#example) + - [About DSL](#about-dsl) + - [Execution directory](#execution-directory) + - [Embedded shell scripts](#embedded-shell-scripts) + - [Translation process](#translation-process) +- [DSL syntax](#dsl-syntax) + - [Basic structure](#basic-structure) + - [`Describe`, `Context`, `ExampleGroup` - example group block](#describe-context-examplegroup---example-group-block) + - [`It`, `Specify`, `Example` - example block](#it-specify-example---example-block) + - [`Todo` - one liner empty example](#todo---one-liner-empty-example) + - [`When` - evaluation](#when---evaluation) + - [`call` - call a shell function (without subshell)](#call---call-a-shell-function-without-subshell) + - [`run` - run a command (within subshell)](#run---run-a-command-within-subshell) + - [`command` - runs an external command](#command---runs-an-external-command) + - [`script` - runs a shell script](#script---runs-a-shell-script) + - [`source` - runs a script by `.` (dot) command](#source---runs-a-script-by--dot-command) + - [About executing aliases](#about-executing-aliases) + - [`The` - expectation](#the---expectation) + - [Subjects](#subjects) + - [Modifiers](#modifiers) + - [Matchers](#matchers) + - [Language chains](#language-chains) + - [`Assert` - expectation for custom assertion](#assert---expectation-for-custom-assertion) + - [Pending, skip and focus](#pending-skip-and-focus) + - [`Pending` - pending example](#pending---pending-example) + - [`Skip` - skip example](#skip---skip-example) + - [`if` - conditional skip](#if---conditional-skip) + - ['x' prefix for example group and example](#x-prefix-for-example-group-and-example) + - [`xDescribe`, `xContext`, `xExampleGroup` - skipped example group](#xdescribe-xcontext-xexamplegroup---skipped-example-group) + - [`xIt`, `xSpecify`, `xExample` - skipped example](#xit-xspecify-xexample---skipped-example) + - ['f' prefix for example group and example](#f-prefix-for-example-group-and-example) + - [`fDescribe`, `fContext`, `fExampleGroup` - focused example group](#fdescribe-fcontext-fexamplegroup---focused-example-group) + - [`fIt`, `fSpecify`, `fExample` - focused example](#fit-fspecify-fexample---focused-example) + - [About temporary pending and skip](#about-temporary-pending-and-skip) + - [Hooks](#hooks) + - [`BeforeEach` (`Before`), `AfterEach` (`After`) - example hook](#beforeeach-before-aftereach-after---example-hook) + - [`BeforeAll`, `AfterAll` - example group hook](#beforeall-afterall---example-group-hook) + - [`BeforeCall`, `AfterCall` - call evaluation hook](#beforecall-aftercall---call-evaluation-hook) + - [`BeforeRun`, `AfterRun` - run evaluation hook](#beforerun-afterrun---run-evaluation-hook) + - [Helpers](#helpers) + - [`Dump` - dump stdout, stderr and status for debugging](#dump---dump-stdout-stderr-and-status-for-debugging) + - [`Include` - include a script file](#include---include-a-script-file) + - [`Set` - set shell option](#set---set-shell-option) + - [`Path`, `File`, `Dir` - path alias](#path-file-dir---path-alias) + - [`Data` - pass data as stdin to evaluation](#data---pass-data-as-stdin-to-evaluation) + - [`Parameters` - parameterized example](#parameters---parameterized-example) + - [`Mock` - create a command-based mock](#mock---create-a-command-based-mock) + - [`Intercept` - create an intercept point](#intercept---create-an-intercept-point) +- [Directives](#directives) + - [`%const` (`%`) - constant definition](#const----constant-definition) + - [`%text` - embedded text](#text---embedded-text) + - [`%puts` (`%-`), `%putsn` (`%=`) - output a string (with newline)](#puts---putsn----output-a-string-with-newline) + - [`%printf` - alias for printf](#printf---alias-for-printf) + - [`%sleep` - alias for sleep](#sleep---alias-for-sleep) + - [`%preserve` - preserve variables](#preserve---preserve-variables) + - [`%logger` - debug output](#logger---debug-output) + - [`%data` - define parameter](#data---define-parameter) +- [Mocking](#mocking) + - [Function-based mock](#function-based-mock) + - [Command-based mock](#command-based-mock) +- [Support commands](#support-commands) + - [Execute the actual command within a mock function](#execute-the-actual-command-within-a-mock-function) + - [Make mock not mandatory in sandbox mode](#make-mock-not-mandatory-in-sandbox-mode) + - [Resolve command incompatibilities](#resolve-command-incompatibilities) +- [Tagging](#tagging) +- [About testing external commands](#about-testing-external-commands) +- [How to test a single file shell script](#how-to-test-a-single-file-shell-script) + - [Using `run script`](#using-run-script) + - [Using `run source`](#using-run-source) + - [Testing shell functions](#testing-shell-functions) + - [`__SOURCED__`](#__sourced__) + - [Intercepting](#intercepting) + - [`Intercept`](#intercept) + - [`test || __() { :; }`](#test--__---) + - [`__`](#__) +- [spec_helper](#spec_helper) + - [`_precheck`](#module_precheck) + - [`minimum_version`](#minimum_version) + - [`error`, `warn`, `info`](#error-warn-info) + - [`abort`](#abort) + - [`setenv`, `unsetenv`](#setenv-unsetenv) + - [environment variables](#environment-variables) + - [`_loaded`](#module_loaded) + - [`_configure`](#module_configure) + - [`import`](#import) + - [`before_each`, `after_each`](#before_each-after_each) + - [`before_all`, `after_all`](#before_all-after_all) +- [Self-executable specfile](#self-executable-specfile) +- [Use with Docker](#use-with-docker) +- [Extension](#extension) + - [Custom subject, modifier and matcher](#custom-subject-modifier-and-matcher) +- [For developers](#for-developers) + - [Subprojects](#subprojects) + - [ShellMetrics - Cyclomatic Complexity Analyzer for shell scripts](#shellmetrics---cyclomatic-complexity-analyzer-for-shell-scripts) + - [ShellBench - A benchmark utility for POSIX shell comparison](#shellbench---a-benchmark-utility-for-posix-shell-comparison) + - [Related projects](#related-projects) + - [getoptions - An elegant option parser and generator for shell scripts](#getoptions---an-elegant-option-parser-and-generator-for-shell-scripts) + - [readlinkf - readlink -f implementation for shell scripts](#readlinkf---readlink--f-implementation-for-shell-scripts) + - [Inspired frameworks](#inspired-frameworks) + - [Contributions](#contributions) + +## Supported shells and platforms + +- [bash][bash]_>=2.03_, [bosh/pbosh][bosh]_>=2018/10/07_, [posh][posh]_>=0.3.14_, [yash][yash]_>=2.29_, [zsh][zsh]_>=3.1.9_ +- [dash][dash]_>=0.5.4_, [busybox][busybox] ash_>=1.20.0_, [busybox-w32][busybox-w32], [GWSH][gwsh]_>=20190627_ +- ksh88, [ksh93][ksh93]_>=93s_, [ksh2020][ksh2020], [mksh/lksh][mksh]_>=R28_, [pdksh][pdksh]_>=5.2.14_ +- [FreeBSD sh][freebsdsh], [NetBSD sh][netbsdsh], [NetBSD ksh][netbsdksh], [OpenBSD ksh][openbsdksh], [loksh][loksh], [oksh][oksh] + +[bash]: https://www.gnu.org/software/bash/ +[bosh]: http://schilytools.sourceforge.net/bosh.html +[busybox]: https://www.busybox.net/ +[busybox-w32]: https://frippery.org/busybox/ +[dash]: http://gondor.apana.org.au/~herbert/dash/ +[gwsh]: https://github.com/hvdijk/gwsh +[ksh93]: http://kornshell.org +[ksh2020]: https://github.com/ksh-community/ksh +[mksh]: http://www.mirbsd.org/mksh.htm +[posh]: https://salsa.debian.org/clint/posh +[yash]: https://yash.osdn.jp/ +[zsh]: https://www.zsh.org/ +[netbsdsh]: http://cvsweb.netbsd.org/bsdweb.cgi/src/bin/sh/ +[netbsdksh]: http://cvsweb.netbsd.org/bsdweb.cgi/src/bin/ksh/ +[freebsdsh]: https://www.freebsd.org/cgi/man.cgi?sh(1) +[openbsdksh]: https://man.openbsd.org/ksh.1 +[pdksh]: https://web.archive.org/web/20160918190548/http://www.cs.mun.ca:80/~michael/pdksh/ +[loksh]: https://github.com/dimkr/loksh +[oksh]: https://github.com/ibara/oksh + +| Platform | Test | +| ---------------------------------------------------------------- | -------------------------------------------------- | +| Linux (Debian, Ubuntu, Fedora, CentOS, Alpine, Busybox, OpenWrt) | [GitHub Actions][Actions] or [Docker][Docker] | +| macOS (Default installed shells, Homebrew) | [GitHub Actions][Actions] or [Travis CI][TravisCI] | +| Windows (Git bash, msys2, cygwin, busybox-w32, WSL) | [GitHub Actions][Actions] | +| BSD (FreeBSD, OpenBSD, NetBSD) | [Cirrus CI][CirrusCI] (FreeBSD) or Manual (Others) | +| Unix (Solaris, AIX) | Manual only | + +[Actions]: https://github.com/shellspec/shellspec/actions +[TravisCI]: https://travis-ci.com/shellspec/shellspec +[CirrusCI]: https://cirrus-ci.com/github/shellspec/shellspec +[Docker]: dockerfiles + +[Tested version details](docs/shells.md) + +## Requirements + +### POSIX-compliant commands + +ShellSpec uses shell built-in commands and only few basic [POSIX-compliant commands][utilities] to +support wide range of environments (except `kcov` for optional code coverage). + +[utilities]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html + +Currently used external (not shell builtins) commands: + +- `cat`, `date`, `env`, `ls`, `mkdir`, `od` (or not POSIX `hexdump`), `rm`, `sleep`, `sort`, `time` +- `ps` (use to auto-detect shells in environments that don't implement procfs) +- `ln`, `mv` (use only when generating coverage report) +- `kill`, `printf` (most shells except some are built-in) + +## Installation + +### Web installer (for developers) + +#### Install the latest release version + +```sh +curl -fsSL https://git.io/shellspec | sh +``` + +or + +```sh +wget -O- https://git.io/shellspec | sh +``` + +NOTE: `https://git.io/shellspec` is redirected to [install.sh](https://github.com/shellspec/shellspec/raw/master/install.sh) + +The installation using the web installer is mainly intended for development use. +For CI, it is recommended to use a specific version (tag) in git or archives to avoid unexpected failures. + +
+Advanced installation / upgrade + +#### Automatic installation + +```sh +curl -fsSL https://git.io/shellspec | sh -s -- --yes +``` + +#### Install the specified version + +```sh +curl -fsSL https://git.io/shellspec | sh -s 0.19.1 +``` + +#### Upgrade to the latest release version + +```sh +curl -fsSL https://git.io/shellspec | sh -s -- --switch +``` + +#### Switch to the specified version + +```sh +curl -fsSL https://git.io/shellspec | sh -s 0.18.0 --switch +``` + +
+ +
+Uninstall + +#### How to uninstall + +1. Delete the ShellSpec executable file [default: `$HOME/.local/bin/shellspec`]. +2. Delete the ShellSpec installation directory [default: `$HOME/.local/lib/shellspec`]. + +
+ +
+Other usage + +### Other usage + +```console +$ curl -fsSL https://git.io/shellspec | sh -s -- --help +Usage: [sudo] ./install.sh [VERSION] [OPTIONS...] + or : wget -O- https://git.io/shellspec | [sudo] sh + or : wget -O- https://git.io/shellspec | [sudo] sh -s -- [OPTIONS...] + or : wget -O- https://git.io/shellspec | [sudo] sh -s VERSION [OPTIONS...] + or : curl -fsSL https://git.io/shellspec | [sudo] sh + or : curl -fsSL https://git.io/shellspec | [sudo] sh -s -- [OPTIONS...] + or : curl -fsSL https://git.io/shellspec | [sudo] sh -s VERSION [OPTIONS...] + +VERSION: + Specify install version and method + + e.g + 1.0.0 Install 1.0.0 from git + master Install master from git + 1.0.0.tar.gz Install 1.0.0 from tar.gz archive + . Install from local directory + +OPTIONS: + -p, --prefix PREFIX Specify prefix [default: $HOME/.local] + -b, --bin BIN Specify bin directory [default: /bin] + -d, --dir DIR Specify installation directory [default: /lib/shellspec] + -s, --switch Switch version (requires installation via git) + -l, --list List available versions (tags) + --pre Include pre-release + --fetch FETCH Force command to use when installing from archive (curl or wget) + -y, --yes Automatic yes to prompts + -h, --help You're looking at it +``` + +
+ +### Package manager + +
+Arch Linux + +Installation on Arch Linux from the AUR [ShellSpec package](https://aur.archlinux.org/packages/shellspec/) using `aura`: + +```console +# Install the latest stable version +$ aura -A shellspec +``` + +
+ +
+Homebrew / Linuxbrew + +```console +# Install the latest stable version +$ brew tap shellspec/shellspec +$ brew install shellspec +``` + +
+ +
+basher / bpkg + +Installation with [basher](https://github.com/basherpm/basher) + +**The officially supported version is ShellSpec 0.19.1 and later.** + +```console +# Install from master branch +$ basher install shellspec/shellspec + +# To specify a version (example: 0.19.1) +$ basher install shellspec/shellspec@0.19.1 +``` + +Installation with [bpkg](https://github.com/bpkg/bpkg) + +**The officially supported version is ShellSpec 0.19.1 and later.** + +```console +# Install from master branch +$ bpkg install shellspec/shellspec + +# To specify a version (example: 0.19.1) +$ bpkg install shellspec/shellspec@0.19.1 +``` + +
+ +### Manual installation + +
+git / archive (source code) + +Download from git or archive and create a symbolic link. + +From git + +```console +$ cd /SOME/WHERE/TO/INSTALL +$ git clone https://github.com/shellspec/shellspec.git + +$ ln -s /SOME/WHERE/TO/INSTALL/shellspec/shellspec /EXECUTABLE/PATH/ +``` + +From archive + +```console +$ cd /SOME/WHERE/TO/INSTALL +$ wget https://github.com/shellspec/shellspec/archive/{VERSION}.tar.gz +$ tar xzvf shellspec-{VERSION}.tar.gz + +$ ln -s /SOME/WHERE/TO/INSTALL/shellspec-{VERSION}/shellspec /EXECUTABLE/PATH/ +``` + +Executable path: e.g. `/usr/local/bin/`, `$HOME/bin/` + +
+ +
+Use make instead of symbolic link creation + +Download from git or archive and use `make` command. + +**How to install.** + +Install to `/usr/local/bin` and `/usr/local/lib` + +```sh +sudo make install +``` + +Install to `$HOME/bin` and `$HOME/lib` + +```sh +make install PREFIX=$HOME +``` + +**How to uninstall.** + +```sh +sudo make uninstall +``` + +```sh +make uninstall PREFIX=$HOME +``` + +
+ +
+For environments that do not support symbolic links + +Download from git or archive and create the following `shellspec` file instead of the symbolic link. + +```console +$ cat<<'HERE'>/EXECUTABLE/PATH/shellspec +#!/bin/sh +exec /SOME/WHERE/TO/INSTALL/shellspec/shellspec "$@" +HERE +$ chmod +x /EXECUTABLE/PATH/shellspec +``` + +
+ +### Distribution archive (runtime only) + +See [Releases](https://github.com/shellspec/shellspec/releases) page if you want to download distribution archive. + +## Tutorial + +**Just create your project directory and run `shellspec --init` to setup your project** + +```console +# Create your project directory, for example "hello". +$ mkdir hello +$ cd hello + +# Initialize +$ shellspec --init + create .shellspec + create spec/spec_helper.sh + +# Write your first specfile (of course you can use your favorite editor) +$ cat<<'HERE'>spec/hello_spec.sh +Describe 'hello.sh' + Include lib/hello.sh + It 'says hello' + When call hello ShellSpec + The output should equal 'Hello ShellSpec!' + End +End +HERE + +# Create lib/hello.sh +$ mkdir lib +$ touch lib/hello.sh + +# It will fail because the hello function is not implemented. +$ shellspec + +# Write hello function +$ cat<<'HERE'>lib/hello.sh +hello() { + echo "Hello ${1}!" +} +HERE + +# It will success! +$ shellspec +``` + +## ShellSpec CLI + +### runs specfile using `/bin/sh` by default + +ShellSpec CLI runs specfiles with the shell running `shellspec`. +Usually it is `/bin/sh` that is the shebang of `shellspec`. If you run `bash shellspec`, it will be bash. +`Include` files from specfile will be executed in the same shell as well. + +The purpose of this specification is to allow ShellSpec to easily change multiple types of shells +and enable the development of cross-platform shell scripts that support multiple shells and environments. + +If you want to test with a specific shell, use the `-s` (`--shell`) option. +You can specify the default shell in the `.shellspec` file. + +NOTE: If you execute a **shell script file** (not a shell function) from within the specfile, +its shebang will be respected. Because in that case, it will be run as an external command. +The `-s` (`--shell`) option also has no effect. +If you are testing a external shell script file, you can use `When run script` or `When run source`. +These ignore the shebang of external shell script file and run in the same shell that runs specfile. + +### command options + +NOTE: Since version 0.28.0, [getoptions](https://github.com/ko1nksm/getoptions) is used to parse options, +so all POSIX and GNU compatible option syntax can be used. For example, you can abbreviate a long option. + +See more info: [ShellSpec CLI](docs/cli.md) + +```console +$ shellspec -h +Usage: shellspec [ -c ] [-C ] [options...] [files or directories...] + + Using + instead of - for short options causes reverses the meaning + + -s, --shell SHELL Specify a path of shell [default: "auto" (the shell running shellspec)] + --require MODULE Require a MODULE (shell script file) + -O, --options PATH Specify the path to an additional options file + -I, --load-path PATH Specify PATH to add to $SHELLSPEC_LOAD_PATH (may be used more than once) + --helperdir DIRECTORY The directory to load helper files (spec_helper.sh, etc) [default: "spec"] + --path PATH Set PATH environment variable at startup + --{no-}sandbox Force the use of the mock instead of the actual command + --sandbox-path PATH Make PATH the sandbox path instead of empty [default: empty] + --execdir @LOCATION[/DIR] Specify the execution directory of each specfile | [default: @project] + -e, --env NAME[=VALUE] Set environment variable + --env-from ENV-SCRIPT Set environment variable from shell script file + -w, --{no-}warning-as-failure Treat warning as failure [default: enabled] + --{no-}fail-fast[=COUNT] Abort the run after first (or COUNT) of failures [default: disabled] + --{no-}fail-no-examples Fail if no examples found [default: disabled] + --{no-}fail-low-coverage Fail on low coverage [default: disabled] + --failure-exit-code CODE Override the exit code used when there are failing specs [default: 101] + --error-exit-code CODE Override the exit code used when there are fatal errors [default: 102] + -p, --{no-}profile Enable profiling and list the slowest examples [default: disabled] + --profile-limit N List the top N slowest examples [default: 10] + --{no-}boost Increase the CPU frequency to boost up testing speed [default: disabled] + --log-file LOGFILE Log file for %logger directive and trace [default: "/dev/tty"] + --tmpdir TMPDIR Specify temporary directory [default: $TMPDIR, $TMP or "/tmp"] + --keep-tmpdir Do not cleanup temporary directory [default: disabled] + + The following options must be specified before other options and cannot be specified in the options file + + -c, --chdir Change the current directory to the first path of arguments at the start + -C, --directory DIRECTORY Change the current directory at the start + + **** Execution **** + + -q, --{no-}quick Run not-passed examples if it exists, otherwise run all [default: disabled] + -r, --repair, --only-failures Run failure examples only (Depends on quick mode) + -n, --next-failure Run failure examples and abort on first failure (Depends on quick mode) + -j, --jobs JOBS Number of parallel jobs to run [default: 0 (disabled)] + --random TYPE[:SEED] Run examples by the specified random type | <[none]> [specfiles] [examples] + -x, --xtrace Run examples with trace output of evaluation enabled [default: disabled] + -X, --xtrace-only Run examples with trace output only enabled [default: disabled] + --dry-run Print the formatter output without running any examples [default: disabled] + + **** Output **** + + --{no-}banner Show banner if exist "/banner[.md]" [default: enabled] + --reportdir DIRECTORY Output directory of the report [default: "report"] + -f, --format FORMATTER Choose a formatter for display | <[p]> [d] [t] [j] [f] [null] [debug] + -o, --output FORMATTER Choose a generator(s) to generate a report file(s) [default: none] + --{no-}color Enable or disable color [default: enabled if the output is a TTY] + --skip-message VERBOSITY Mute skip message | <[verbose]> [moderate] [quiet] + --pending-message VERBOSITY Mute pending message | <[verbose]> [quiet] + --quiet Equivalent of --skip-message quiet --pending-message quiet + --(show|hide)-deprecations Show or hide deprecations details [default: show] + + **** Ranges / Filters / Focus **** + + You can run selected examples by specified the line numbers or ids + + shellspec path/to/a_spec.sh:10 # Run the groups or examples that includes lines 10 + shellspec path/to/a_spec.sh:@1-5 # Run the 5th groups/examples defined in the 1st group + shellspec a_spec.sh:10:@1:20:@2 # You can mixing multiple line numbers and ids with join by ":" + + -F, --focus Run focused groups / examples only + -P, --pattern PATTERN Load files matching pattern [default: "*_spec.sh"] + -E, --example PATTERN Run examples whose names include PATTERN + -T, --tag TAG[:VALUE] Run examples with the specified TAG + --default-path PATH Set the default path where looks for examples [default: "spec"] + + You can specify the path recursively by prefixing it with the pattern "*/" or "**/" + (This is not glob patterns and requires quotes. It is also available with --default-path) + + shellspec "*/spec" # The pattern "*/" matches 1 directory + shellspec "**/spec" # The pattern "**/" matches 0 and more directories + shellspec "*/*/**/test_spec.sh" # These patterns can be specified multiple times + + -L, --dereference Dereference all symlinks in in the above pattern [default: disabled] + + **** Coverage **** + + --covdir DIRECTORY Output directory of the Coverage Report [default: coverage] + --{no-}kcov Enable coverage using kcov [default: disabled] + --kcov-path PATH Specify kcov path [default: kcov] + --kcov-options OPTIONS Additional Kcov options (coverage limits, coveralls id, etc) + + **** Utility **** + + --init [TEMPLATE...] Initialize your project with ShellSpec | [spec] [git] [hg] [svn] + --gen-bin [@COMMAND...] Generate test support commands in "/support/bin" + --count Count the number of specfiles and examples + --list LIST List the specfiles/examples | [specfiles] [examples(:id|:lineno)] + --syntax-check Syntax check of the specfiles without running any examples + --translate Output translated specfile + --task [TASK] Run the TASK or Show the task list if TASK is not specified + --docker DOCKER-IMAGE Run tests in specified docker image (EXPERIMENTAL) + -v, --version Display the version + -h, --help -h: short help, --help: long help +``` + +## Project directory + +All specfiles for ShellSpec must be under the project directory. The root of the project directory +must have a `.shellspec` file. This file is that specify the default options to be used in +the project, but an empty file is required even if the project has no options. + +NOTE: The `.shellspec` file was described in the documentation as a required file for some time, +but ShellSpec worked without it. Starting with version 0.28.0, this file is checked and will be +required in future versions. + +You can easily create the necessary files by executing the `shellspec --init` command in an existing directory. + +### Typical directory structure + +This is the typical directory structure. Version 0.28.0 allows many of these to be changed by specifying options, supporting a more flexible [directory structure](docs/directory_structure.md). + +```text + directory +ā”œā”€ .shellspec [mandatory] +ā”œā”€ .shellspec-local [optional] Ignore from version control +ā”œā”€ .shellspec-quick.log [optional] Ignore from version control +ā”œā”€ report/ [optional] Ignore from version control +ā”œā”€ coverage/ [optional] Ignore from version control +│ +ā”œā”€ bin/ +│ ā”œā”€ your_script1.sh +│ : +ā”œā”€ lib/ +│ ā”œā”€ your_library1.sh +│ : +│ +ā”œā”€ spec/ (also ) +│ ā”œā”€ spec_helper.sh [recommended] +│ ā”œā”€ banner[.md] [optional] +│ ā”œā”€ support/ [optional] +│ │ +│ ā”œā”€ bin/ +│ │ ā”œā”€ your_script1_spec.sh +│ │ : +│ ā”œā”€ lib/ +│ │ ā”œā”€ your_library1_spec.sh +``` + +### Options file + +To change the default options for the `shellspec` command, create options file(s). +Files are read in the order shown below, options defined last take precedence. + +1. `$XDG_CONFIG_HOME/shellspec/options` +2. `$HOME/.shellspec-options` (version >= 0.28.0) or `$HOME/.shellspec` (deprecated) +3. `/.shellspec` +4. `/.shellspec-local` (Do not store in VCS such as git) + +Specify your default options with `$XDG_CONFIG_HOME/shellspec/options` or `$HOME/.shellspec-options`. +Specify default project options with `.shellspec` and overwrite to your favorites with `.shellspec-local`. + +### `.shellspec` - project options file + +Specifies the default options to use for the project. + +### `.shellspec-local` - user custom options file + +Override the default options used by the project with your favorites. + +### `.shellspec-basedir` - specfile execution base directory + +Used to specify the directory in which the specfile will be run. +See [directory structure](docs/directory_structure.md) or `--execdir` option for details. + +### `.shellspec-quick.log` - quick execution log + +If this file is present, Quick mode will be enabled and the log of Quick execution will be recorded. +It created automatically when `--quick` option is specified. +If you want to turn off Quick mode, delete it. + +### `report/` - report file directory + +The output location for reports generated by the `--output` or `--profile` options. +This can be changed with the `--reportdir` option. + +### `coverage/` - coverage reports directory + +The output location for coverage reports. +This can be changed with the `--covdir` option. + +### `spec/` - (default) specfiles directory + +By default, it is assumed that all specfiles are store under the `spec` directory, +but it is possible to create multiple directories with different names. + +NOTE: In Version <= 0.27.x, the `spec` directory was the only directory that contained the specfiles. + +### \ (default: `spec/`) + +The directory to store `spec_helper.sh` and other files. +By default, the `spec` directory also serves as `HELPERDIR` directory, +but you can change it to another directory with the `--helperdir` option. + +#### `spec_helper.sh` - (default) helper file for specfile + +The `spec_helper.sh` is loaded to specfile by the `--require spec_helper` option. +This file is used to define global functions, initial setting for examples, custom matchers, etc. + +#### `banner[.md]` - banner file displayed at test execution + +If the file `/banner` or `/banner.md` exists, Display a banner when +the `shellspec` command is executed. It can be used to display information about the tests. +The `--no-banner` option can be used to disable this behavior. + +#### `support/` - directory for support files + +This directory can be used to store files such as custom matchers and tasks. + +##### `bin` - directory for support commands + +This directory is used to store [support commands](#support-commands). + +## Specfile (test file) + +In ShellSpec, you write your tests in a specfile. +By default, specfile is a file ending with `_spec.sh` under the `spec` directory. + +The specfile is executed using the `shellspec` command, but it can also be executed directly. +See [self-executable specfile](#self-executable-specfile) for details. + +### Example + +```sh +Describe 'lib.sh' # example group + Describe 'bc command' + add() { echo "$1 + $2" | bc; } + + It 'performs addition' # example + When call add 2 3 # evaluation + The output should eq 5 # expectation + End + End +End +``` + +**The best place to learn how to write a specfile is the +[examples/spec](examples/spec) directory. You should take a look at it !** +*(Those examples include failure examples on purpose.)* + +### About DSL + +ShellSpec has its own DSL to write tests. It may seem like a distinctive code because DSL starts +with a capital letter, but the syntax is compatible with shell scripts, and you can embed +shell functions and use [ShellCheck](https://github.com/koalaman/shellcheck) to check the syntax. + +You may feel rejected by this DSL, but It starts with a capital letter to avoid confusion with +the command, and it does a lot more than you think, such as realizing scopes, getting +shell-independent line numbers, and workarounds for bugs in some shells. + +### Execution directory + +Since version 0.28.0, the current directory when run a specfile is the project root directory by default. Even if you run a specfile from a any subdirectory in the project directory, +It is the project root directory. +Before 0.27.x, it was the current directory when the `shellspec` is executed. + +You can change this directory (location) by using the `--execdir @LOCATION[/DIR]` option. +You can choose from the following locations and specify a path relative to the location if necessary. +However, you cannot specify a directory outside the project directory. + +- @project Where the ".shellspec" file is located (project root) [default] +- @basedir Where the ".shellspec" or ".shellspec-basedir" file is located +- @specfile Where the specfile is located + +If basedir is specified, the parent directory is searched from the directory containing the specfile +to be run, and the first directory where `.shellspec-basedir` or `.shellspec` is found is used as +the execution directory. This is useful if you want to have a separate directory for each +utilities (command) you want to test. + +NOTE: You will need to change under the project directory or use the `-c` (`--chdir`) or +`-C` (`--directory`) option before running specfile. + +### Embedded shell scripts + +You can embed shell function (or shell script code) in the specfile. +This shell function can be used for test preparation and complex testing. + +Note that the specfile implements the scope using subshell. +Shell functions defined in the specfile can only be used within blocks (e.g. `Describe`, `It`, etc). + +If you want to use a global function, you can define it in `spec_helper.sh`. + +### Translation process + +The specfile will not be executed directly by the shell, but will be translated into a regular +shell script and output to a temporary directory (default: `/tmp`) before being executed. + +The translation process is simple in that it only replaces forward-matched words (DSLs), with a few +exceptions. If you are interested in the translated code, you can see with `shellspec --translate`. + +## DSL syntax + +### Basic structure + +#### `Describe`, `Context`, `ExampleGroup` - example group block + +`ExampleGroup` is a block for grouping example groups or examples. +`Describe` and `Context` are alias for `ExampleGroup`. +It can be nested and they can contain example groups or examples. + +```sh +Describe 'is example group' + Describe 'is nestable' + ... + End + + Context 'is used to facilitate understanding depending on the context' + ... + End +End +``` + +The example groups can be optionally tagged. See [Tagging](#tagging) for details. + +```sh +Describe 'is example group' tag1:value1 tag2:value2 ... +``` + +#### `It`, `Specify`, `Example` - example block + +`Example` is a block for writing evaluation and expectations. +`It` and `Specify` are alias for `Example`. + +An example is composed by up to one evaluation and multiple expectations. + +```sh +add() { echo "$1 + $2" | bc; } + +It 'performs addition' # example + When call add 2 3 # evaluation + The output should eq 5 # expectation + The status should be success # another expectation +End +``` + +The examples can be optionally tagged. See [Tagging](#tagging) for details. + +```sh +It 'performs addition' tag1:value1 tag2:value2 ... +``` + +#### `Todo` - one liner empty example + +`Todo` is the same as the empty example and is treated as [pending](#pending---pending-example) example. + +```sh +Todo 'will be used later when we write a test' + +It 'is an empty example, the same as Todo' +End +``` + +#### `When` - evaluation + +Evaluation executes shell function or command for verification. +Only one evaluation can be defined for each example and also can be omitted. + +See more details of [Evaluation](docs/references.md#evaluation) + +NOTE: [About executing aliases](#about-executing-aliases) + +##### `call` - call a shell function (without subshell) + +It calls a function without subshell. +Practically, it can also run commands. + +```sh +When call add 1 2 # call `add` shell function with two arguments. +``` + +##### `run` - run a command (within subshell) + +It runs a command within subshell. Practically, it can also call a shell function. +The command does not have to be a shell script. + +NOTE: This is not supporting coverage measurement. + +```sh +When run touch /tmp/foo # run `touch` command. +``` + +Some commands below are specially handled by ShellSpec. + +###### `command` - runs an external command + +It runs a command, respecting shebang. +It can not call shell function. The command does not have to be a shell script. + +NOTE: This is not supporting coverage measurement. + +```sh +When run command touch /tmp/foo # run `touch` command. +``` + +###### `script` - runs a shell script + +It runs a shell script, ignoring shebang. The script has to be a shell script. +It will be executed in another instance of the same shell as the current shell. + +```sh +When run script my.sh # run `my.sh` script. +``` + +###### `source` - runs a script by `.` (dot) command + +It sources a shell script, ignoring its shebang. The script has to be a shell script. +It is similar to `run script`, but with some differences. +Unlike `run script`, function-based mock is available. + +```sh +When run source my.sh # source `my.sh` script. +``` + +##### About executing aliases + +If you want to execute aliases, you need a workaround using `eval`. + +```sh +alias alias-name='echo this is alias' +When call alias-name # alias-name: not found + +# eval is required +When call eval alias-name + +# When using embedded shell scripts +foo() { eval alias-name; } +When call foo +``` + +#### `The` - expectation + +Expectation begins with `The` which does the verification. +The basic syntax is as follows: + +```sh +The output should equal 4 +``` + +Use `should not` for the opposite verification. + +```sh +The output should not equal 4 +``` + +##### Subjects + +The subject is the target of the verification. + +```sh +The output should equal 4 + | + +-- subject +``` + +There are `output` (`stdout`), `error` (`stdout`), `status`, `variable`, `path`, etc. subjects. + +Please refer to the [Subjects](docs/references.md#subjects) for more details. + +##### Modifiers + +The modifier concretizes the target of the verification (subject). + +```sh +The line 2 of output should equal 4 + | + +-- modifier +``` + +The modifiers are chainable. + +```sh +The word 1 of line 2 of output should equal 4 +``` + +If the modifier argument is a number, you can use an ordinal numeral instead of a number. + +```sh +The first word of second line of output should equal 4 +``` + +There are `line`, `word`, `length`, `contents`, `result`, etc. modifiers. +The `result` modifier is useful for making the result of a user-defined function the subject. + +Please refer to the [Modifiers](docs/references.md#modifiers) for more details. + +##### Matchers + +The matcher is the verification. + +```sh +The output should equal 4 + | + +-- matcher +``` + +There are many matchers such as string matcher, status matcher, variable matchers and stat matchers. +The `satisfy` matcher is useful for verification with user-defined function. + +Please refer to the [Matchers](docs/references.md#matchers) for more details. + +##### Language chains + +ShellSpec supports *language chains* like [chai.js](https://www.chaijs.com/). +It only improves readability, does not affect the expectation: `a`, `an`, `as`, `the`. + +The following two sentences have the same meaning: + +```sh +The first word of second line of output should valid number + +The first word of the second line of output should valid as a number +``` + +#### `Assert` - expectation for custom assertion + +The `Assert` is yet another expectation to verify with a user-defined function. +It is designed for verification of side effects, not the result of the evaluation. + +```sh +still_alive() { + ping -c1 "$1" >/dev/null +} + +Describe "example.com" + It "responses" + Assert still_alive "example.com" + End +End +``` + +### Pending, skip and focus + +#### `Pending` - pending example + +`Pending` is similar to `Skip`, but the test passes if the verification fails, +and the test fails if the verification succeeds. This is useful if you want to +specify that you will implement something later. + +```sh +Describe 'Pending' + Pending "not implemented" + + hello() { :; } + + It 'will success when test fails' + When call hello world + The output should "Hello world" + End +End +``` + +#### `Skip` - skip example + +Use `Skip` to skip executing the example. + +```sh +Describe 'Skip' + Skip "not exists bc" + + It 'is always skip' + ... + End +End +``` + +##### `if` - conditional skip + +Use `Skip if` if you want to skip conditionally. + +```sh +Describe 'Conditional skip' + not_exists_bc() { ! type bc >/dev/null 2>&1; } + Skip if "not exists bc" not_exists_bc + + add() { echo "$1 + $2" | bc; } + + It 'performs addition' + When call add 2 3 + The output should eq 5 + End +End +``` + +#### 'x' prefix for example group and example + +##### `xDescribe`, `xContext`, `xExampleGroup` - skipped example group + +`xDescribe`, `xContext`, `xExampleGroup` are skipped example group blocks. +Execution of examples contained in these blocks is skipped. + +```sh +Describe 'is example group' + xDescribe 'is skipped example group' + ... + End +End +``` + +##### `xIt`, `xSpecify`, `xExample` - skipped example + +`xIt`, `xSpecify`, `xExample` are skipped example blocks. +Execution of the example is skipped. + +```sh +xIt 'is skipped example' + ... +End +``` + +#### 'f' prefix for example group and example + +##### `fDescribe`, `fContext`, `fExampleGroup` - focused example group + +`fDescribe`, `fContext`, `fExampleGroup` are focused example group blocks. +Only the examples included in these will be executed when the `--focus` option is specified. + +```sh +Describe 'is example group' + fDescribe 'is focues example group' + ... + End +End +``` + +##### `fIt`, `fSpecify`, `fExample` - focused example + +`fIt`, `fSpecify`, `fExample` are focused example blocks. +Only these examples will be executed when the `--focus` option is specified. + +```sh +fIt 'is focused example' + ... +End +``` + +#### About temporary pending and skip + +The pending and skip without message is "temporary pending" and "temporary skip". +"x"-prefixed example groups and examples are treated as a temporary skip. + +The non-temporary pending and skip (with message) is used when it takes a long time to resolve. +It may be committed to a version control system. The temporary pending and skip is used during the current work. +We do not recommend committing it to a version control system. + +These two types differ in the display of the report. Refer to `--skip-message` and `--pending-message` options. + +```sh +# Temporary pending and skip +Pending +Skip +Skip # this comment will be displayed in the report +Todo +xIt + ... +End + +# Non-temporary pending and skip +Pending "reason" +Skip "reason" +Skip if "reason" condition +Todo "It will be implemented" +``` + +### Hooks + +#### `BeforeEach` (`Before`), `AfterEach` (`After`) - example hook + +You can specify commands to be executed before / after each example by `BeforeEach` (`Before`), `AfterEach` (`After`). + +NOTE: `BeforeEach` and `AfterEach` are supported in version 0.28.0 and later. +Previous versions should use `Before` and `After` instead. + +NOTE: `AfterEach` is for cleanup and not for assertions. + +```sh +Describe 'example hook' + setup() { :; } + cleanup() { :; } + BeforeEach 'setup' + AfterEach 'cleanup' + + It 'is called before and after each example' + ... + End + + It 'is called before and after each example' + ... + End +End +``` + +#### `BeforeAll`, `AfterAll` - example group hook + +You can specify commands to be executed before / after all examples by `BeforeAll` and `AfterAll` + +```sh +Describe 'example all hook' + setup() { :; } + cleanup() { :; } + BeforeAll 'setup' + AfterAll 'cleanup' + + It 'is called before/after all example' + ... + End + + It 'is called before/after all example' + ... + End +End +``` + +#### `BeforeCall`, `AfterCall` - call evaluation hook + +You can specify commands to be executed before / after call evaluation by `BeforeCall` and `AfterCall` + +NOTE: These hooks were originally created to test ShellSpec itself. +Please use the `BeforeEach` / `AfterEach` hooks whenever possible. + +```sh +Describe 'call evaluation hook' + setup() { :; } + cleanup() { :; } + BeforeCall 'setup' + AfterCall 'cleanup' + + It 'is called before/after call evaluation' + When call hello world + ... + End +End +``` + +#### `BeforeRun`, `AfterRun` - run evaluation hook + +You can specify commands to be executed before / after run evaluation +(`run`, `run command`, `run script` and `run source`) by `BeforeRun` and `AfterRun` + +These hooks are executed in the same subshell as the "run evaluation". +Therefore, you can access the variables after executing the evaluation. + +NOTE: These hooks were originally created to test ShellSpec itself. +Please use the `BeforeEach` / `AfterEach` hooks whenever possible. + +```sh +Describe 'run evaluation hook' + setup() { :; } + cleanup() { :; } + BeforeRun 'setup' + AfterRun 'cleanup' + + It 'is called before/after run evaluation' + When run hello world + ... + End +End +``` + +### Helpers + +#### `Dump` - dump stdout, stderr and status for debugging + +Dump stdout, stderr and status of the evaluation. It is useful for debugging. + +```sh +When call echo hello world +Dump # stdout, stderr and status +``` + +#### `Include` - include a script file + +Include a shell script to test. + +```sh +Describe 'lib.sh' + Include lib.sh # hello function defined + + Describe 'hello()' + It 'says hello' + When call hello ShellSpec + The output should equal 'Hello ShellSpec!' + End + End +End +``` + +#### `Set` - set shell option + +Set shell option before executing each example. +The shell option name is the long name of `set` or the name of `shopt`: + +NOTE: Use `Set` instead of the `set` command because the `set` command +may not work as expected in some shells. + +```sh +Describe 'Set helper' + Set 'errexit:off' 'noglob:on' + + It 'sets shell options before executiong the example' + When call foo + End +End +``` + +#### `Path`, `File`, `Dir` - path alias + +`Path` is used to define a short pathname alias. +`File` and `Dir` are aliases for `Path`. + +```sh +Describe 'Path helper' + Path hosts-file="/etc/hosts" + + It 'defines short alias for long path' + The path hosts-file should be exists + End +End +``` + +#### `Data` - pass data as stdin to evaluation + +You can use the Data Helper which inputs data from stdin for evaluation. +The input data is specified after `#|` in the `Data` or `Data:expand` block. + +```sh +Describe 'Data helper' + It 'provides with Data helper block style' + Data # Use Data:expand instead if you want expand variables. + #|item1 123 + #|item2 456 + #|item3 789 + End + When call awk '{total+=$2} END{print total}' + The output should eq 1368 + End +End +``` + +You can also use a file, function or string as data sources. + +See more details of [Data](docs/references.md##data) + +#### `Parameters` - parameterized example + +Parameterized test (aka Data Driven Test) is used to run the same test with +different parameters. `Parameters` defines its parameters. + +```sh +Describe 'example' + Parameters + "#1" 1 2 3 + "#2" 1 2 3 + End + + Example "example $1" + When call echo "$(($2 + $3))" + The output should eq "$4" + End +End +``` + +In addition to the default `Parameters`, three styles are supported: +`Parameters:value`, `Parameters:matrix` and `Parameters:dynamic`. + +See more details of [Parameters](docs/references.md#parameters) + +NOTE: You can also cooperate the `Parameters` and `Data:expand` helpers. + +#### `Mock` - create a command-based mock + +See [Command-based mock](#command-based-mock) + +#### `Intercept` - create an intercept point + +See [Intercept](#intercept) + +## Directives + +Directives are instructions that can be used in embedded shell scripts. +It is used to solve small problems of shell scripts in testing. + +This is like a shell function, but not a shell function. +Therefore, the supported grammar is limited and can only be used at the +beginning of a function definition or at the beginning of a line. + +```sh +foo() { %puts "foo"; } # supported + +bar() { + %puts "bar" # supported +} + +baz() { + any command; %puts "baz" # not supported +} +``` + +### `%const` (`%`) - constant definition + +`%const` (`%` is short hand) directive defines a constant value. The characters +which can be used for variable names are uppercase letters `[A-Z]`, digits +`[0-9]` and underscore `_` only. It can not be defined inside an example +group nor an example. + +The value is evaluated during the specfile translation process. +So you can access ShellSpec variables, but you can not access variable or +function in the specfile. + +This feature assumes use with conditional skip. The conditional skip may run +outside of the examples. As a result, sometimes you may need variables defined +outside of the examples. + +### `%text` - embedded text + +You can use the `%text` directive instead of a hard-to-use heredoc with +indented code. The input data is specified after `#|`. + +```sh +Describe '%text directive' + It 'outputs texts' + output() { + echo "start" # you can write code here + %text + #|aaa + #|bbb + #|ccc + echo "end" # you can write code here + } + + result() { %text + #|start + #|aaa + #|bbb + #|ccc + #|end + } + + When call output + The output should eq "$(result)" + The line 3 of output should eq 'bbb' + End +End +``` + +### `%puts` (`%-`), `%putsn` (`%=`) - output a string (with newline) + +`%puts` (put string) and `%putsn` (put string with newline) can be used instead +of (not portable) echo. Unlike echo, it does not interpret escape sequences +regardless of the shell. `%-` is an alias of `%puts`, `%=` is an alias of +`%putsn`. + +### `%printf` - alias for printf + +This is the same as `printf`, but it can be used in the sandbox mode because the path has been resolved. + +### `%sleep` - alias for sleep + +This is the same as `sleep`, but it can be used in the sandbox mode because the path has been resolved. + +### `%preserve` - preserve variables + +Use `%preserve` directive to preserve the variables in subshells and external shell script. + +In the following cases, `%preserve` is required because variables are not preserved. + +- `When run` evaluation - It runs in a subshell. +- Command-based mock (`Mock`) - It is an external shell script. +- Function-based Mock called by command substitution + +```sh +Describe '%preserve directive' + It 'preserves variables' + func() { foo=1; bar=2; baz=3; } + preserve() { %preserve bar baz:BAZ; } + AfterRun preserve + + When run func + The variable foo should eq 1 # This will be failure + The variable bar should eq 2 # This will be success + The variable BAZ should eq 3 # Preserved to different variable (baz:BAZ) + End +End +``` + +### `%logger` - debug output + +Output log messages to the log file (default: `/dev/tty`) for debugging. + +### `%data` - define parameter + +See `Parameters`. + +## Mocking + +There are two ways to create a mock, (shell) function-based mock and (external) command-based mock. +The function-based mock is usually recommended for performance reasons. +Both can be overwritten with an internal block and will be restored when the block ends. + +### Function-based mock + +The (shell) function-based mock is simply (re)defined with shell function. + +```sh +Describe 'function-based mock' + get_next_day() { echo $(($(date +%s) + 86400)); } + + date() { + echo 1546268400 + } + + It 'calls the date function' + When call get_next_day + The stdout should eq 1546354800 + End +End +``` + +### Command-based mock + +The (external) command-based mock creates a temporary mock shell script and runs as an external command. +This is slow, but there are some advantages over the function-based mock. + +- Can be use invalid characters as the shell function name. + - e.g `docker-compose` (`-` cannot be used as a function name in POSIX) +- Can be invoke a mocked command from an external command (not limited to shell script). + +A command-based mock creates an external shell script with the contents of a `Mock` block, +so there are some restrictions. + +- It is not possible to mock shell functions or shell built-in functions. +- It is not possible to call shell functions outside the `Mock` block. + - Exception: Can be called exported (`export -f`) functions. (bash only) +- To reference variables outside the `Mock` block, they must be exported. +- To return a variable from a Mock block, you need to use the `%preserve` directive. + +```sh +Describe 'command-based mock' + get_next_day() { echo $(($(date +%s) + 86400)); } + + Mock date + echo 1546268400 + End + + It 'runs the mocked date command' + When call get_next_day + The stdout should eq 1546354800 + End +End +``` + +NOTE: To achieve this feature, a directory for mock commands is included at the beginning of the `PATH`. + +## Support commands + +### Execute the actual command within a mock function + +Support commands are helper commands that can be used in the specfile. +For example, it can be used in a mock function to execute the actual command. +It is recommended that the support command name be the actual command name prefixed with `@`. + +```sh +Describe "Support commands example" + touch() { + @touch "$@" # @touch executes actual touch command + echo "$1 was touched" + } + + It "touch a file" + When run touch "file" + The output should eq "file was touched" + The file "file" should be exist + End +End +``` + +Support commands are generated in the `spec/support/bin` directory by the `--gen-bin` option. +For example run `shellspec --gen-bin @touch` to generate the `@touch` command. + +This is the main purpose, but support commands are just shell scripts, so they can +also be used for other purposes. You can freely edit the support command script. + +### Make mock not mandatory in sandbox mode + +The sandbox mode forces the use of mocks. However, you may not want to require mocks for some commands. +For example, `printf` is a built-in command in many shells and does not require a mock in the sandbox mode for these shells. But +there are shells where it is an external command and then it requires to be mocked. + +To allow `printf` to be called without mocking in certain cases, +create a support command named `printf` (`shellspec --gen-bin printf`). + +### Resolve command incompatibilities + +Some commands have different options between BSD and GNU. +If you handle the difference in the specfile, the test will be hard to read. +You can solve it with the support command. + +```sh +#!/bin/sh -e +# Command name: @sed +. "$SHELLSPEC_SUPPORT_BIN" +case $OSTYPE in + *darwin*) invoke gsed "$@" ;; + *) invoke sed "$@" ;; +esac +``` + +## Tagging + +The example groups or examples can be tagged, and the `--tag` option can be used to filter the examples to be run. +The tag name and tag value are separated by `:`, and the tag value is optional. You can use any character if quoted. + +```sh +Describe "Checking something" someTag:someVal + It "does foo" tagA:val1 + ... + It "does bar" tagA:val2 + ... + It "does baz" tagA + ... +End +``` + +1. Everything nested inside a selected element is selected in parent elements. e.g. `--tag someTag` will select everything above. +2. Specifying a tag but no value selects everything with that tag whether or not it has a value, e.g. `--tag tagA` will select everything above. +3. Specifying multiple tags will select the union of everything tagged, e.g. `--tag tagA:val1,tagA:val2` will select `does foo` and `does bar`. +4. Tests included multiple times are not a problem, e.g. `--tag someTag,tagA,tagA:val1` just selects everything. +5. If no tag matches, nothing will be run, e.g. `--tag tagA:` runs nothing (it does not match baz above, as empty values are not the same as no value). +6. The --tag option can be used multiple times, e.g. `--tag tagA:val1 --tag tagA:val2` works the same as `--tag tagA:val1,tagA:val2` + +## About testing external commands + +ShellSpec is a testing framework for shell scripts, but it can be used to test anything that can be executed as an external command, even if it is written in another language. Even shell scripts can be tested as external commands. + +If you are testing a shell script as an external command, please note the following. + +- It will be executed in the shell specified by the shebang not the shell running the specfile. +- The coverage of the shell script will not be measured. +- Cannot refer to variables inside the shell script. +- Shell built-in commands cannot be mocked. +- Functions defined inside the shell script cannot be mocked. +- Only command-based mock can be used (if the script is calling an external command). +- Interceptor is not available. + +To get around these limitations, use `run script` or `run source`. See [How to test a single file shell script](#how-to-test-a-single-file-shell-script). + +## How to test a single file shell script + +If the shell script consists of a single file, unit testing becomes difficult. +However, there are many such shell scripts. + +ShellSpec has the ability to testing in such cases with only few modifications to the shell script. + +### Using `run script` + +Unlike the case of executing as an [external command](#about-testing-external-commands), it has the following features. + +- It will run in the same shell (but another process) that is running specfile. +- The coverage of the shell script will be measured. + +There are limitations as follows. + +- Cannot refer to variables inside the shell script. +- Shell built-in commands cannot be mocked. +- Functions defined inside the shell script cannot be mocked. +- Only command-based mock can be used (if the script is calling an external command). +- Interceptor is not available. + +### Using `run source` + +It is even less limitations than `run script` and has the following features. + +- It will run in the same shell and same process that is running specfile. +- The coverage of the shell script will be measured. +- Can be refer to variables inside the shell script. +- Function-based mock and command-based mock are available. +- Interceptor is available. +- Shell built-in commands can be mocked. +- Functions defined inside the shell script can be mocked using interceptor. + +However, since it is simulated using the `.` command, there are some differences in behavior. +For example, the value of `$0` is different. + +NOTE: Mocking of shell built-in commands can be done before `run source`. However, if you are using +interceptor, mocking of the `test` command must be done in the `____` function. + +### Testing shell functions + +#### `__SOURCED__` + +This is the way to test shell functions defined in a shell script. + +Loading a script with `Include` defines a `__SOURCED__` variable available in the sourced script. +If the variable `__SOURCED__` is defined, please return from the shell script. + +```sh +#!/bin/sh +# hello.sh + +hello() { echo "Hello $1"; } + +# This is the writing style presented by ShellSpec, which is short but unfamiliar. +# Note that it returns the current exit status (could be non-zero). +${__SOURCED__:+return} + +# The above means the same as below. +# ${__SOURCED__:+x} && return $? + +# If you don't like the coding style, you can use the general writing style. +# if [ "${__SOURCED__:+x}" ]; then +# return 0 +# fi + +hello "$1" +``` + +```sh +Describe "hello.sh" + Include "./hello.sh" + + Describe "hello()" + It "says hello" + When call hello world + The output should eq "Hello world" + End + End +End +``` + +### Intercepting + +Interceptor is a feature that allows you to intercept your shell script in the middle of its execution. +This makes it possible to mock functions that cannot be mocked in advance at arbitrary timing, +and to make assertions by retrieving the state of during script execution. + +It is a powerful feature, but avoid using it as possible, because it requires you to modify your code +and may reduce readability. Normally, it is not a good idea to modify the code just for testing, +but in some cases, there is no choice but to use this. + +```sh +#!/bin/sh +# ./today.sh + +# When run directly without testing, the "__()" function does nothing. +test || __() { :; } + +# the "now()" function is defined here, so it can't be mocked in advance. +now() { date +"%Y-%m-%d %H:%M:%S"; } + +# The function you want to test +today() { + now=$(now) + echo "${now% *}" +} + +# I want to mock the "now()" function here. +__ begin __ + +today=$(today) +echo "Today is $today" + +__ end __ +``` + +```sh +Describe "today.sh" + Intercept begin + __begin__() { + now() { echo "2021-01-01 01:02:03"; } + } + __end__() { + # The "run source" is run in a subshell, so you need to use "%preserve" + # to preserve variables + %preserve today + } + + It "gets today's date" + When run source ./today.sh + The output should eq "Today is 2021-01-01" + The variable today should eq "2021-01-01" + End +End +``` + +#### `Intercept` + +Usage: `Intercept [...]` + +Specify the name(s) to intercept. + +NOTE: I will change `Intercept` to `Interceptors` to make it a declarative DSL. + +#### `test || __() { :; }` + +Define the `__` function that does nothing except when run as a test (via ShellSpec). +This allows you to run it as a production without changing the code. + +The `test` command is the shell built-in `test` command. This command returns false (non-zero) +when called with no arguments. This will allow who are not familiar with ShellSpec to will +understand what the result will be, even if they don't know what the code is for. +Of course, it is good practice to comment on what the code is for + +When run via ShellSpec, the `test` command is redefined and returns true "only once" when called +with no arguments. After that, it will return to its original behavior. This means that this code +needs to be executed only once, at the start of the shell script. + +#### `__` + +Usage: `__ [arguments...] __` + +This is where the process is intercepted. You can define more than one. +If the name matches the name specified in `Intercept`, the `____` function will be called. + +Note that if the name is not specified in `Intercept`, nothing will be done, +but the exit status will be changed to 0. + +## spec_helper + +The `spec_helper` can be used to set shell options for all specfiles, +define global functions,check the execution shell, load custom matchers, etc. + +The `spec_helper` is the default module name. It can be changed to any other name, and multiple +modules can be used. Only characters accepted by POSIX as identifiers can be used in module names. +The file name of the module must be the module name with the extension `.sh` appended. +It is loaded from `SHELLSPEC_LOAD_PATH` using the `--require` option. + +The following is a typical `spec_helper`. The following three callback functions are available. + +```sh +# Filename: spec/spec_helper.sh + +set -eu + +spec_helper_precheck() { + minimum_version "0.28.0" + if [ "$SHELL_TYPE" != "bash" ]; then + abort "Only bash is supported." + fi +} + +spec_helper_loaded() { + : # In most cases, you won't use it. +} + +spec_helper_configure() { + import 'support/custom_matcher' + before_each "global_before_each_hook" +} + +# User-defined global function +global_before_each_hook() { + : +} + +# In version <= 0.27.x, only shellspec_spec_helper_configure was available. +# This callback function is still supported but deprecated in the future. +# Please rename it to spec_helper_configure. +# shellspec_spec_helper_configure() { +# : +# } +``` + +The `spec_helper` will be loaded at least twice. The first time is at precheck phase, +which is executed in a separate process before the specfile execution. +The second time will be load at the beginning of the specfile execution. +If you are using parallel execution, it will be loaded every specfile. + +Within each callback function, there are several helper functions available. These functions are +not available outside of the callback function. Also, these callback functions will be removed +automatically when `spec_helper` is finished loading. (User-defined functions will not be removed.) + +### `_precheck` + +This callback function will be invoked only once before loading specfiles. +Exit with `exit` or `abort`, or `return` non-zero to exit without executing specfiles. +Inside this function, `set -eu` is executed, so an explicit return on error is not necessary. + +Since it is invoked in a separate process from specfiles, changes made in +this function will not be affected in specfiles. + +#### `minimum_version` + +- Usage: `minimum_version ` + +Specifies the minimum version of ShellSpec that the specfile supports. The version format is +[semantic version](https://semver.org/). Pre-release versions have a lower precedence than +the associated normal version, but comparison between pre-release versions is not supported. +The build metadata will simply be ignored. + +NOTE: Since `_precheck` is only available in 0.28.0 or later, +it can be executed with earlier ShellSpecs even if minimum_version is specified. +To avoid this, you can implement a workaround using `--env-from`. + +```sh +# spec/env.sh +# Add `--env-from spec/env.sh` to `.shellspec` +major_minor=${SHELLSPEC_VERSION%".${SHELLSPEC_VERSION#*.*.}"} +if [ "${major_minor%.*}" -eq 0 ] && [ "${major_minor#*.}" -lt 28 ]; then + echo "ShellSpec version 0.28.0 or higher is required." >&2 + exit 1 +fi +``` + +#### `error`, `warn`, `info` + +- Usage: `error [messages...]` +- Usage: `warn [messages...]` +- Usage: `info [messages...]` + +Outputs a message according to the type. You can also use `echo` or `printf`. + +#### `abort` + +- Usage: `abort [messages...]` +- Usage: `abort [messages...]` + +Display an error message and `exit`. If the exit status is omitted, it is `1`. +You can also exit with exit. `exit 0` will exit normally without executing the specfiles. + +#### `setenv`, `unsetenv` + +- Usage: `setenv [name=value...]` +- Usage: `unset [name...]` + +You can use `setenv` or `unsetenv` to pass or remove environment variables from precheck to specfiles. + +#### environment variables + +The following environment variables are defined. + +- `VERSION` - ShellSpec Version +- `SHELL_TYPE` - Currently running shell type (e.g. `bash`) +- `SHELL_VERSION` - Currently running shell version (e.g. `4.4.20(1)-release`) + +NOTE: Be careful not to confuse `SHELL_TYPE` with the environment variable `SHELL`. +The environment variable `SHELL` is the user login shell, not the currently running shell. +It is a variable set by the system, and which unrelated to ShellSpec. + +### `_loaded` + +It is called after loading the shellspec's general internal functions, +but before loading the core modules (subject, modifire, matcher, etc). +If parallel execution is enabled, it may be called multiple times in isolated processes. +Internal functions starting with `shellspec_` can also be used, but be aware that they may change. + +This was created to perform [workarounds](helper/ksh_workaround.sh) for specific shells in order to +test ShellSpec itself. Other than that, I have not come up with a case where this is +absolutely necessary, but if you have one, please let me know. + +### `_configure` + +This callback function will be called after core modules (subject, modifire, matcher, etc) has been loaded. +If parallel execution is enabled, it may be called multiple times in isolated processes. +Internal functions starting with `shellspec_` can also be used, but be aware that they may change. +It can be used to set global hooks, load custom matchers, etc., and override core module functions. + +#### `import` + +- Usage: `import [arguments...]` + +Import a custom module from `SHELLSPEC_LOAD_PATH`. + +#### `before_each`, `after_each` + +- Usage: `before_each [hooks...]` +- Usage: `after_each [hooks...]` + +Register hooks to be executed before and after every example. +It is the same as executing `BeforeEach`/`AfterEach` at the top of all specfiles. + +#### `before_all`, `after_all` + +- Usage: `before_all [hooks...]` +- Usage: `after_all [hooks...]` + +Register hooks to be executed before and after all example. +It is the same as executing `BeforeAll`/`AfterAll` at the top of all specfiles. + +NOTE: This is a hook that is called before and after each specfile, not before and after all specfiles. + +## Self-executable specfile + +Add `eval "$(shellspec - -c) exit 1"` to the top of the specfile and give execute permission +to the specfile. You can use `/bin/sh`, `/usr/bin/env bash`, etc. for shebang. +The specfile will be run in the shell written in shebang. + +```sh +#!/bin/sh + +eval "$(shellspec - -c) exit 1" + +# Use the following if version <= 0.27.x +# eval "$(shellspec -)" + +Describe "bc command" + bc() { echo "$@" | command bc; } + + It "performs addition" + When call bc "2+3" + The output should eq 5 + End +End +``` + +The `-c` option is available since 0.28.0, and you can also pass other options. +If you run the specfile directly, `--pattern` will be automatically set to `*`. +These options will be ignored if run via `shellspec` command. + +The use of `shellspec` as shebang is deprecated because it is not portable. + +```awk +#!/usr/bin/env shellspec -c +Linux does not allow passing options + +#!/usr/bin/env -S shellspec -c +The -S option requires GNU Core Utilities 8.30 (2018-07-01) or later. +``` + +## Use with Docker + +You can run ShellSpec without installation using Docker. ShellSpec and +specfiles run in a Docker container. + +See [How to use ShellSpec with Docker](docs/docker.md). + +## Extension + +### Custom subject, modifier and matcher + +You can create custom subject, custom modifier and custom matcher. + +See [examples/spec/support/custom_matcher.sh](examples/spec/support/custom_matcher.sh) for custom matcher. + +NOTE: If you want to verify using shell function, you can use [result](docs/references.md#result) modifier or +[satisfy](docs/references.md#satisfy) matcher. You don't need to create a custom matcher, etc. + +## For developers + +### Subprojects + +#### ShellMetrics - Cyclomatic Complexity Analyzer for shell scripts + +URL: [https://github.com/shellspec/shellmetrics](https://github.com/shellspec/shellmetrics) + +#### ShellBench - A benchmark utility for POSIX shell comparison + +URL: [https://github.com/shellspec/shellbench](https://github.com/shellspec/shellbench) + +### Related projects + +#### getoptions - An elegant option parser and generator for shell scripts + +URL: [https://github.com/ko1nksm/getoptions](https://github.com/ko1nksm/getoptions) + +#### readlinkf - readlink -f implementation for shell scripts + +URL: [https://github.com/ko1nksm/readlinkf](https://github.com/ko1nksm/readlinkf) + +### Inspired frameworks + +- [RSpec](https://rspec.info/) - Behaviour Driven Development for Ruby +- [Jest](https://jestjs.io/]) - Delightful JavaScript Testing +- [Mocha](https://mochajs.org/) - the fun, simple, flexible JavaScript test framework +- [Jasmine](https://jasmine.github.io/) - Behavior-Driven JavaScript +- [Ginkgo](https://onsi.github.io/ginkgo/) - A Golang BDD Testing Framework +- [JUnit 5](https://junit.org/junit5/) - The programmer-friendly testing framework for Java + +### Contributions + +All contributions are welcome! + +ShellSpec uses a peculiar coding style to assure high performance, +reliability and portability, and the external commands allowed to use are greatly restricted. + +We recommend that you create WIP PR early or offer suggestions in discussions to avoid ruining your work. + +See [CONTRIBUTING.md](CONTRIBUTING.md) diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/bin/shellspec b/tests/shellspec/.vendor/shellspec-0.28.1/bin/shellspec new file mode 120000 index 0000000..06a6c60 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/bin/shellspec @@ -0,0 +1 @@ +../shellspec \ No newline at end of file diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/all.sh b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/all.sh new file mode 100755 index 0000000..bb12c44 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/all.sh @@ -0,0 +1,67 @@ +#!/bin/sh + +# Run in all shells + +# This script is for development purposes. +# It provide as is, do not any support. +# It may change without notice. + +# Example of use +# contrib/all.sh +# contrib/all.sh shellspec example/addition_spec.sh +# contrib/all.sh -c 'echo ok' + +set -eu + +: "${TARGET:=sh,ash,dash,bash,zsh,pdksh,ksh,ksh93,mksh,oksh,yash,posh,busybox ash}" + +readlinkf() { + [ ${1:+x} ] || return 1; p=$1; until [ "${p%/}" = "$p" ]; do p=${p%/}; done + [ -e "$p" ] && p=$1; [ -d "$1" ] && p=$p/; set 10 "$PWD" "${OLDPWD:-}" + CDPATH="" cd -L "$2" && while [ "$1" -gt 0 ]; do set "$1" "$2" "$3" "${p%/*}" + [ "$p" = "$4" ] || { CDPATH="" cd -L "${4:-/}" || break; p=${p##*/}; } + [ ! -L "$p" ] && p=${PWD%/}${p:+/}$p && set "$@" "${p:-/}" && break + set $(($1-1)) "$2" "$3" "$p"; p=$(ls -dl "$p") || break; p=${p#*" $4 -> "} + done 2>/dev/null; cd -L "$2" && OLDPWD=$3 && [ ${5+x} ] && printf '%s\n' "$5" +} + +each_shells() { + callback=$1 IFS=, + shift + for shell in $TARGET; do + shell_path='' real_path='' + # shellcheck disable=SC2230 + shell_path=$(which "${shell%% *}" 2>/dev/null) || shell_path='' + [ -L "${shell_path%% *}" ] && real_path=$(readlinkf "${shell_path%% *}") + $callback "$@" + done +} + +info() { + info=$shell_path + [ "$info" ] && info="$info${real_path:+ -> }$real_path" + printf '%8s : %s\n' "${shell%% *}" "${info:-----}" +} + +run() { + if [ "$shell_path" ]; then + echo "--------------------------------------------------" + echo "$shell : $shell_path${real_path:+ -> }$real_path" + echo "$shell" "$@" + echo "--------------------------------------------------" + eval "SH=\$shell $shell \"\$@\"" + else + echo "--------------------------------------------------" + echo "$shell : Skip, shell not found" + echo "--------------------------------------------------" + echo + fi +} + +uname -a +echo "==================================================" +( each_shells info ) +echo "==================================================" +if [ $# -gt 0 ]; then + ( each_shells run "$@" ) +fi diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/bugs.sh b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/bugs.sh new file mode 100755 index 0000000..6f05fbb --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/bugs.sh @@ -0,0 +1,409 @@ +#!/bin/sh +# shellcheck disable=SC2004,SC2015,SC2016,SC2034,SC2086,SC2091,SC2123,SC2181,SC2194 + +# Bugs and compatibility check for shell + +# This script is for development purposes. +# It provide as is, do not any support. +# It may change without notice. + +# Example of use +# contrib/bugs.sh +# bash contrib/bugs.sh +# contrib/test_in_docker.sh [Dockerfile] -- bash contrib/bugs.sh + +affect() { echo "[affect] $title"; } +no_problem() { echo "[------] $title"; } +skip() { echo "[skip ] $title [skip reason: $1]"; } + +if { file=$(mktemp -t tmp.XXXXXX); } 2>/dev/null; then + maketemp() { mktemp -t tmp.XXXXXX; } + rm "$file" +else + maketemp() { mktemp tmp.XXXXXX; } +fi + +( + title="01: set -e option is reset (posh)" + set -eu + foo() { eval 'return 0'; } + foo + case $- in + *e*) no_problem ;; + *) affect ;; + esac +) + +( + title="02: double quoted string treated as a pattern (posh)" + string="abc[d]" + pattern="c[d]" + case $string in + *"$pattern"*) no_problem ;; + *) affect ;; + esac +) + +( + title="03: @: parameter not set (posh, ksh <= around 93s)" + if (set -u; : "$@") 2>/dev/null; then no_problem; else affect; fi +) + +return_true() { false; } +( + title="04: function not overrite (ksh)" + return_true() { true; } + if return_true; then no_problem; else affect; fi +) + +( + title="05: exit not return exit code (zsh <= around 4.2.5)" + foo() { (exit 123) &&:; }; foo + if [ $? -eq 123 ]; then no_problem; else affect; fi +) + +( + title="06: abort if unset not the defined variable (bash <= around 2.05a, zsh <= around 4.2.5, ksh <= around 93s)" + ok=$( + set -e + unset not_defined_variable + echo 1 + ) + if [ "$ok" ]; then no_problem; else affect; fi +) + +( + title="07: limited arithmetic expansion (dash <= around 0.5.4, old ash)" + i=0 + ok=$(eval 'i=$((i+1))' 2>/dev/null; echo 1) + if [ "$ok" ]; then no_problem; else affect; fi +) + +( + title="08: Unsupported trap (posh: around 0.8.5)" + if (trap '' INT) 2>/dev/null; then no_problem; else affect; fi +) + +( + title="09: different split by IFS (zsh, posh <= around 0.6.13)" + [ "${ZSH_VERSION:-}" ] && emulate -R sh + string="1,2," + IFS=',' + set -- $string + if [ $# -eq 2 ]; then no_problem; else affect; fi +) + +( + title="10: variable reference in the same line (dash <= around 0.5.5)" + i=1 + i=$(($i+1)) j=$i + if [ "$j" -eq 2 ]; then no_problem; else affect; fi +) + +( + title="11: command time -p output LF at first (solaris)" + if (command time echo) >/dev/null 2>/dev/null; then + command time -p printf '' 2>&1 | { + IFS= read -r line + if [ "$line" ]; then no_problem; else affect; fi + } + else + skip 'time command not found' + fi +) + +( + title="12: cat not ignore set -e (zsh = around 5.4.2)" + ( + set -e + nagative() { false; } + if false; then :; else nagative && : || :; fi + ) + [ $? -eq 0 ] && no_problem || affect +) + +( + title="13: many unset cause a Segmentation fault (mksh = around 39)" + ( + i=0 + while [ $i -lt 30000 ]; do + unset v ||: + i=$(($i+1)) + done + ) 2>/dev/null + [ $? -eq 0 ] && no_problem || affect +) + +( + title="14: here document does not expand parameters (ash = around 0.3.8)" + set -- value + foo() { cat; } + result=$(foo<"$file" + ret=$(cat "$file") + rm "$file" + + case $ret in + *bad\ nzombie*) affect ;; + *) no_problem ;; + esac +) + +( + title='23: can not read after reading null character (yash = around 2.46)' + file=$(maketemp) + printf 'foo\0bar' > "$file" + IFS= read -r ret < "$file" + IFS= read -r ret </dev/null) ||: + [ "$ch" = "A" ] && no_problem || affect +) + +( + title='26: Segmentation fault in eval (ksh 93q, 93r)' + ( + ( + str="" i=0 + step1() { + if (eval ':' 2>/dev/null); then :; fi + return 0 + } + step2() { set --; eval "$(:)"; } + step3() { eval "str=\${str#}"; } + step1 + step2 + while [ $i -lt 100 ]; do + step3 # 10 Segmentation fault "$@ + i=$(($i+1)) + done + ) & + wait $! # wait is not related this bug, it just prevent fail. + ) 2>/dev/null + [ $? = 0 ] && no_problem || affect +) + +( + title='27: set -C not working (posh = around 0.10.2)' + file=$(maketemp) + (set -C; : > "$file") 2>/dev/null &&: + ret=$? + rm "$file" + [ $ret -ne 0 ] && no_problem || affect +) + +( + title='28: variable expansion not working within the double qoute (posh >= 0.8.5)' + a='foobar' b='bar' + [ "${a%"$b"*}" = "foo" ] && no_problem || affect +) + +( + title='29: case will be aborted when exit status is error (mksh <= 35.2, pdksh 5.2.14 on debian 2.2)' + foo() { set -e; case 1 in (*) false &&: ;; esac; echo ok; } + ret=$(foo) + [ "$ret" = "ok" ] && no_problem || affect +) + +( + title='30: eval interpret invalid -- option (posh = around 0.3.14)' + ret=$(eval echo -- foo) + [ "$ret" = "-- foo" ] && no_problem || affect +) + +( + title='31: ${v%%=*} not working (zsh <= around 4.3.17)' + kv="key=value" + (ret="${kv%%=*}"; [ "$ret" = "key" ]) 2>/dev/null &&: + [ $? = 0 ] && no_problem || affect +) + +( + title='32: last readonly always display "is read only" in subshell (ksh 93q, 93r)' + ( + # readonly A # => not display + # readonly B # => display "B is read only" + readonly A; (readonly B) 2>/dev/null + [ $? = 0 ] && no_problem || affect + ) &&: +) 2>/dev/null + +( + title='33: fails when use readonly with value (pdksh 5.2.14 on debian 2.2)' + message=$( ( readonly value=123 ) 2>&1 ) + [ "$message" ] && affect || no_problem +) + +( + title='34: built-in commands can not redefine (busybox = around 1.1.3)' + whoami() { echo nobody; } + [ "$(whoami)" = nobody ] && no_problem || affect +) + +( + title='35: exit status is not 127 when command not found (zsh <= around 4.0.4)' + no-such-command 2>/dev/null &&: + [ $? = 127 ] && no_problem || affect +) + +( + title='36: exit status is not 127 when command not found and PATH='' (bash <= 4.3)' + no-such-command 2>/dev/null &&: + if [ $? = 1 ]; then + skip 'affected #35' + else + set -e + PATH='' + no-such-command 2>/dev/null &&: + [ $? = 127 ] && no_problem || affect + fi +) + +( + title='37: wrong parse command substitution (bosh/posh = 20181030,20190311)' +$( +cat << HERE +HERE +) + ret=$( printf a; printf b ) + [ "$ret" = "ab" ] && no_problem || affect +) + +( + title='38: Freeze in pipe processing (bosh/posh = 20181030,20190311)' + + printf '1\n2\n' | cat | while read -r line; do + # /usr/bin/printf '%s' "$line" # freeze + printf '%s' "$line" # not freeze + done > /dev/null + + [ -e /usr/bin/printf ] && printf=/usr/bin/printf || printf=/bin/printf + + file=$(maketemp) + # Code for detection. Output one line only. + { echo 1; echo 2; } | { + while IFS= read -r line; do + echo "$line" + done | cat | while read -r line; do + $printf '%s' "$line" + done + } > $file + ret=$(cat "$file") + rm "$file" + [ "$ret" = "1" ] && affect || no_problem +) + +( + title='39: can not set -e options with eval (pdksh, mksh, posh)' + set -e + eval "set +e" + case $- in + *e*) affect ;; + *) no_problem ;; + esac +) + +( + title='40: can not return exit status from subshell (bash 4.1.5, 4.2)' + ret() { return $1; } + foo() { set -e; ret 123; } + set +e + (foo) + [ $? = 123 ] && no_problem || affect +) + +echo Done diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/build.sh b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/build.sh new file mode 100755 index 0000000..a977e12 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/build.sh @@ -0,0 +1,66 @@ +#!/bin/sh + +set -eu + +info() { + printf '\033[32m%s\033[0m\n' "$*" +} + +if [ -e .env ]; then + default_compose_project_name=shellspec + while read -r line; do + case $line in (COMPOSE_PROJECT_NAME=*) + default_compose_project_name='' + esac + done < .env + if [ "$default_compose_project_name" ]; then + : "${COMPOSE_PROJECT_NAME:=$default_compose_project_name}" + export COMPOSE_PROJECT_NAME + fi +fi + +target=${3:-} + +export DOCKERFILE_BASE AUTHORS +DOCKERFILE_BASE="$(dirname "$1")/" +AUTHORS="$(git config user.name) <$(git config user.email)>" + +# Emulate Docker Hub environment variables +export DOCKERFILE_PATH DOCKER_TAG IMAGE_NAME SOURCE_COMMIT +DOCKERFILE_PATH=$(basename "$1") +DOCKER_TAG=${3:-latest} +IMAGE_NAME=$2:$DOCKER_TAG +SOURCE_COMMIT=$(git rev-parse HEAD) + +test="docker-compose${target:+.}$target.test.yml" +docker-compose -f ".dockerhub/$test" up --build --abort-on-container-exit + +case $1 in + /*) DOCKERFILE_PATH=$1 ;; + *) DOCKERFILE_PATH=$PWD/$1 ;; +esac + +cd .dockerhub +if [ "$target" ]; then + hooks/build --target "$target" +else + hooks/build +fi +size=$(docker inspect -f "{{.Size}}" "$IMAGE_NAME") +if [ "$size" -le $((1024 * 1024)) ]; then + size="$(echo "scale=2; $size / 1024" | bc) KB" +else + size="$(echo "scale=2; $size / 1024 / 1024" | bc) MB" +fi +labels=$( + #shellcheck disable=SC2016 + format='{{range $k, $v := .Config.Labels}}{{printf "%s: %s\n" $k $v}}{{end}}' + #shellcheck disable=SC2005 + echo "$(docker inspect -f "$format" "$IMAGE_NAME")" +) + +info "============================================================" +info "Build succeeded: $IMAGE_NAME (size: $size)" +info "------------------------------------------------------------" +echo "$labels" +info "============================================================" diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/builtins.sh b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/builtins.sh new file mode 100755 index 0000000..0eb4ae3 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/builtins.sh @@ -0,0 +1,165 @@ +#!/bin/sh + +# Detect builtin commands + +# This script is for development purposes. +# It provide as is, do not any support. +# It may change without notice. + +set -eu + +PATH=":" + +check() { + while read -r cmd && cmd=${cmd%% *}; do + if type "$cmd" >/dev/null 2>&1; then + if [ -x /usr/bin/printf ]; then + /usr/bin/printf "%s " "$cmd" + else + /bin/printf "%s " "$cmd" + fi + fi + done + echo +} + +if ! type : >/dev/null 2>&1; then + # not implements type (posh) + type() { + case $1 in (. | exit | type) return 0; esac + $1 + } +fi + +check</dev/null 2>&1; then + echo "You need docker to run shellcheck" >&2 + exit 1 +fi + +echo "Checking scripts by shellcheck..." + +tag="shellspec:shellcheck" + +trap 'exit 1' INT +trap 'docker rmi "$tag" >/dev/null 2>&1' EXIT + +# Do not use volume because can not be used on VolFs(lxfs) of WSL. +shellcheck_version=$(cat .shellcheck-version) +set -- -t "$tag" --build-arg "VERSION=$shellcheck_version" +[ "$PULL" ] && set -- "$@" --pull +docker build "$@" -f dockerfiles/.shellcheck . +docker run -i --rm "$tag" shellcheck --version +docker run -i --rm "$tag" shellcheck -C $(sources; helpers; specs; examples) + +[ "$package_json_status" -ne 0 ] && exit "$package_json_status" + +echo "ok" diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo.sh b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo.sh new file mode 100755 index 0000000..8c61331 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +#ghostplay silent +# ttyrec -e "ghostplay contrib/demo.sh" +# seq2gif -l 5000 -h 32 -w 139 -p win -i ttyrecord -o demo.gif +# seq2gif -l 5000 -h 19 -w 83 -p win -i ttyrecord -o sns.gif +GP_HOSTNAME=ubuntu +highlight() { + command highlight -l -O xterm256 --syntax "$1" +} +#ghostplay end + +shellspec + +#ghostplay sleep 3 + +# Parallel execution +shellspec --jobs 4 + +#ghostplay sleep 3 + +cd contrib/demo + +#ghostplay sleep 1 + +cat spec/demo_spec.sh | highlight sh + +#ghostplay sleep 3 + +# It has one failure +shellspec + +#ghostplay sleep 5 + +# Dry run with documentation formatter +shellspec --dry-run --format documentation + +#ghostplay sleep 5 + +# Coverage and generate junit xml +shellspec --kcov --output junit + +#ghostplay sleep 5 + +cat report/results_junit.xml | highlight xml + +#ghostplay sleep 3 + +cd profile + +# Profiler +shellspec --profile --format documentation diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/.shellspec b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/.shellspec new file mode 100644 index 0000000..c99d2e7 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/.shellspec @@ -0,0 +1 @@ +--require spec_helper diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/mylib.sh b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/mylib.sh new file mode 100644 index 0000000..e414aec --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/mylib.sh @@ -0,0 +1,15 @@ +add() { + echo $(($1 * $2)) # bug: should be '+' +} + +sub() { + echo $(($1 - $2)) +} + +mul() { + echo $(($1 * $2)) +} + +div() { + echo $(($1 / $2)) +} diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/profile/.shellspec b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/profile/.shellspec new file mode 100644 index 0000000..ec117e0 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/profile/.shellspec @@ -0,0 +1,2 @@ +--require spec_helper +# --kcov-common-options "--path-strip-level=1 --include-path=. --include-pattern=.sh --exclude-pattern=/spec/,/coverage/,/report/" diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/profile/spec/profile_spec.sh b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/profile/spec/profile_spec.sh new file mode 100644 index 0000000..6a5eea4 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/profile/spec/profile_spec.sh @@ -0,0 +1,26 @@ +Describe "Profiler example" + Example "1: sleep 0.1 (line 2)" + When call sleep 0.1 + The status should be success + End + + Example "2: sleep 0.4 (line 7)" + When call sleep 0.4 + The status should be success + End + + Example "3: sleep 0.3 (line 12)" + When call sleep 0.3 + The status should be success + End + + Example "4: sleep 0.2 (line 17)" + When call sleep 0.2 + The status should be success + End + + Example "5: sleep 0.5 (line 22)" + When call sleep 0.5 + The status should be success + End +End diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/profile/spec/spec_helper.sh b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/profile/spec/spec_helper.sh new file mode 100644 index 0000000..4db5c9c --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/profile/spec/spec_helper.sh @@ -0,0 +1,14 @@ +#shellcheck shell=sh + +# set -eu + +# shellspec_redefinable function_name +# +# shellspec_redefinable is workaround for ksh (Version AJM 93u+ 2012-08-01) +# ksh can not redefine existing function in some cases inside of sub shell. +# If you have trouble in redefine function on ksh, try using shellspec_redefinable. + +shellspec_spec_helper_configure() { + # shellspec_import 'support/custom_matcher' + : +} diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/spec/demo_spec.sh b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/spec/demo_spec.sh new file mode 100644 index 0000000..c7c643e --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/spec/demo_spec.sh @@ -0,0 +1,17 @@ +Describe 'example' + Describe 'bc command' + It 'performs addition' + Data '2 + 3' + When call bc + The output should eq 5 + End + End + + Describe 'add() function' + Include ./mylib.sh # add() function defined + It 'performs addition' + When call add 2 3 + The output should eq 5 + End + End +End diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/spec/spec_helper.sh b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/spec/spec_helper.sh new file mode 100644 index 0000000..ea7cfc0 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/demo/spec/spec_helper.sh @@ -0,0 +1,10 @@ +#shellcheck shell=sh + +# set -eu + +# shellspec_redefinable function_name + +shellspec_spec_helper_configure() { + # shellspec_import 'support/custom_matcher' + : +} diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/helpers/Dockerfile b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/helpers/Dockerfile new file mode 100644 index 0000000..fd11204 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/helpers/Dockerfile @@ -0,0 +1,10 @@ +FROM alpine +RUN apk add --no-cache gcc libc-dev +ADD https://github.com/ncopa/su-exec/archive/v0.2.tar.gz / +COPY ./src/ ./src +RUN gcc --static ./src/mksock.c -o /usr/local/bin/mksock \ + && gcc --static ./src/invokesh.c -o /usr/local/bin/invokesh \ + && cp ./src/fake-nc.sh /usr/local/bin/nc \ + && tar xzf v0.2.tar.gz \ + && gcc -static /su-exec-0.2/su-exec.c -o /usr/local/bin/su-exec \ + && chmod ug+s /usr/local/bin/su-exec diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/helpers/src/fake-nc.sh b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/helpers/src/fake-nc.sh new file mode 100755 index 0000000..34cb6c1 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/helpers/src/fake-nc.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +for i in "$@"; do + shift + case $i in (-*) continue; esac + set -- "$@" "$i" +done + +mksock "$@" diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/helpers/src/invokesh.c b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/helpers/src/invokesh.c new file mode 100644 index 0000000..a4eb713 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/helpers/src/invokesh.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include +#include + +#define max_size 256 + +int main(int argc, char *argv[]) +{ + FILE *fp; + if ((fp = fopen("/etc/invokesh.conf", "r")) == NULL) { + return EXIT_FAILURE; + } + + char bin[max_size]; + if ( fgets(bin, max_size, fp) == NULL ) { + fclose(fp); + return EXIT_FAILURE; + } + + char *newline; + if ((newline = strchr(bin, '\n')) != NULL) { + *newline = '\0'; + } + + fclose(fp); + + argv[0] = bin; + execvp(bin, argv); + fprintf(stderr, "invokesh: %s: %s\n", bin, strerror(errno)); + return errno; +} diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/helpers/src/mksock.c b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/helpers/src/mksock.c new file mode 100644 index 0000000..f3475c4 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/helpers/src/mksock.c @@ -0,0 +1,32 @@ +#include +#include +#include +#include +#include + +#define UNIX_PATH_MAX 108 + +int main(int argc, char *argv[]) +{ + int sock; + struct sockaddr_un addr; + + if (argc < 2) { + return 1; + } + + if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { + return 1; + } + + addr.sun_family = AF_UNIX; + strncpy(addr.sun_path, argv[1], UNIX_PATH_MAX); + + if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) == -1) { + return 1; + } + + close(sock); + + return 0; +} diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/installer_test.sh b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/installer_test.sh new file mode 100755 index 0000000..adb37b0 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/installer_test.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +# Environment for installer test + +# This script is for development purposes. +# It provide as is, do not any support. +# It may change without notice. + +set -eu + +[ $# -eq 0 ] && set -- general + +case ${1:-} in ( general | make | bpkg | basher | brew) ;; (*) +cat <<'USAGE' +Usage: installer_test.sh [ general | make | bpkg | basher | brew] +USAGE + exit 0 +esac + +iid='' iidfile=$(mktemp -t shellspec.XXXXXXXX) +dockerfile="dockerfiles/.installer-test" + +cleanup() { + [ -f "$iidfile" ] && rm "$iidfile" + [ "$iid" ] && docker rmi "$iid" > /dev/null +} +trap 'exit 1' INT +trap 'cleanup' EXIT + +docker build --target="${1}_installer" -t "shellspec:${1}_installer" - < "$dockerfile" +sleep 5 +docker build --target=test --build-arg "TYPE=$1" --iidfile "$iidfile" . -f "$dockerfile" +iid=$(cat "$iidfile") +shift +docker run -it --rm "$iid" "$@" diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/make_package_json.sh b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/make_package_json.sh new file mode 100755 index 0000000..c4f4dcb --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/make_package_json.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +version() { + ./shellspec --version +} + +files() { + echo "[" + files="$(find bin lib libexec \( -type f -o -type l \) -exec echo " \"{}\"," \; | sort)" + echo "${files%,}" + echo " ]" +} + +cat<&2 + exit 1 + fi +esac + +docker_run() { + docker run -it --rm --entrypoint=/shellspec-docker "$@" +} + +# You can override docker_run() with initrc to changes options, +# pass environment variables, etc. +if [ -e .shellspec-docker/initrc ]; then + . .shellspec-docker/initrc +fi + +docker_run -u "$UID:$GID" -v "$PWD:/src" "$SHELLSPEC_DOCKER" "$@" diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/test_in_docker.sh b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/test_in_docker.sh new file mode 100755 index 0000000..0d20f9f --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/test_in_docker.sh @@ -0,0 +1,152 @@ +#!/bin/sh + +# Run tests in docker + +# This script is for development purposes. +# It provide as is, do not any support. +# It may change without notice. + +set -eu + +if [ $# -eq 0 ]; then +cat <<'USAGE' +Usage: test_in_docker.sh [Dockerfile..] [-- COMMAND] + +Run tests in docker + +Examples + contrib/test_in_docker.sh dockerfiles/* + contrib/test_in_docker.sh dockerfiles/debian-9-* + contrib/test_in_docker.sh dockerfiles/*-o # ends with -o is supported os + contrib/test_in_docker.sh dockerfiles/*bash* -- contrib/bugs.sh + +To delete all shellspec images + docker rmi $(docker images shellspec -q) +USAGE + exit 0 +fi + +LF=" +" + +failures='' count=0 failures_count=0 total_count=0 + +main() { + options="" pull='' shift_count=0 + for arg in "$@"; do + shift_count=$((shift_count + 1)) + case $arg in + --) break ;; + -*) + [ "$arg" = "--pull" ] && pull=1 + options="${options}${arg} " + ;; + *) total_count=$((total_count + 1)) + esac + done + + cd contrib/helpers + docker build ${pull:+--pull} -t shellspec:helpers . | grayout + cd "$OLDPWD" + + for arg in "$@"; do + shift "$shift_count" + shift_count=0 + case $arg in + --) break ;; + -*) continue ;; + esac + run "$arg" "$@" + done +} + +finished() { + if [ -f "$iidfile" ]; then + rm "$iidfile" ||: + fi + + if [ "$failures" ]; then + echo >&2 + echo "Failures:" >&2 + echo "$failures" >&2 + fi +} + +info() { + printf '\033[1;35m%s\033[0m\n' "$*" >&2 +} + +grayout() { + while IFS= read -r line; do + printf '\033[1;2;37m\033[90m%s\033[0m\n' "$line" >&2 + done +} + +iidfile=$(mktemp -t shellspec.XXXXXXXX) +trap 'finished; exit 1' INT +trap 'finished' EXIT + +run() { + dockerfile=$1 + shift + + info "======================================================================" + info "$dockerfile:" "$@" + count=$((count + 1)) + os="${dockerfile##*/}" + os="${os#.}" + os="${os%-!}" + image="shellspec:$os" + old_image=$(docker images -q --no-trunc "$image") + + # shellcheck disable=SC2086 + docker build --iidfile "$iidfile" $options - < "$dockerfile" | grayout + base_image=$(cat "$iidfile") + + info "Create image from base image: $base_image" + docker build --iidfile "$iidfile" -t "$image" --build-arg "IMAGE=$base_image" . -f "dockerfiles/.shellspec" | grayout + new_image=$(cat "$iidfile") + + if [ "$old_image" ] && [ "$old_image" != "$new_image" ]; then + info "Delete old image $old_image" + docker rmi "$old_image" >/dev/null ||: + fi + info + info "Starting $dockerfile:" "$@" + info + docker run -it --rm "$image" "$@" &&: + xs=$? + info + if [ "$xs" -ne 0 ]; then + failures="${failures}- ${os} [$xs]${LF}" + failures_count=$((failures_count + 1)) + fi + summary + info +} + +summary() { + [ "$xs" -eq 0 ] && color="\033[32m" || color="\033[31m" + [ "$failures_count" -eq 0 ] && fcolor="\033[32m" || fcolor="\033[31m" + set -- "$count" "$total_count" "$failures_count" + printf "${color}##############################\n\033[m" + printf "${color}# exit status: %3d #\n\033[m" "$xs" + printf "${color}# ${fcolor}%3d / %3d (failures: %3d)${color} #\n\033[m" "$@" + printf "${color}##############################\n\033[m" + if [ "$failures" ]; then + echo "$failures" + fi +} >&2 + +start=$(date) start_sec=$(date +%s) +main "$@" +end=$(date) end_sec=$(date +%s) +sec=$((end_sec - start_sec)) + +echo "$start" >&2 +echo "$end" >&2 +echo "Done. $count tests, $sec sec ($((sec / 60)) min)" >&2 + +if [ "$failures" ]; then + exit 1 +fi diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/contrib/various_test.sh b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/various_test.sh new file mode 100755 index 0000000..04647df --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/contrib/various_test.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +set -eu + +: "${SH:=sh}" + +# Workaround for GitHub Actions (SIGPIPE) +# In GitHub Actions, SIGPIPE seems to be set to SIG_IGN and if the process exits +# before receiving all STDIN data, it will result in Broken PIPE or I/O will be output +head() { + command head "$@" + cat >/dev/null +} + +shellspec() { + set -- $SH shellspec --shell "$SH" "$@" + echo '$' "$@" >&2 + "$@" +} + +shellspec --banner --output progress --output documentation --output tap --output junit --output failures +shellspec --no-banner --skip-message quiet -j 3 +shellspec --no-banner --skip-message quiet $(shellspec --list specfiles | head -n 5) +shellspec --no-banner --skip-message quiet $(shellspec --list examples:lineno | head -n 5) +shellspec --no-banner --skip-message quiet spec/general_spec.sh:40:60:80:100 +shellspec --no-banner --skip-message quiet spec/libexec --profile +shellspec --syntax-check +shellspec --count +shellspec --task +shellspec --task hello:shellspec diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-3.0r6-ash-0.3.8-fail b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-3.0r6-ash-0.3.8-fail new file mode 100644 index 0000000..aeef5b4 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-3.0r6-ash-0.3.8-fail @@ -0,0 +1,4 @@ +FROM debian/eol:woody-slim +RUN groupadd user && useradd -m user -g user \ + && apt-get update && apt-get -y install ash +ENV SH=/bin/ash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-3.0r6-busybox-0.60.2-fail b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-3.0r6-busybox-0.60.2-fail new file mode 100644 index 0000000..df5e807 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-3.0r6-busybox-0.60.2-fail @@ -0,0 +1,5 @@ +FROM debian/eol:woody-slim +RUN groupadd user && useradd -m user -g user \ + && apt-get update && apt-get -y install busybox \ + && ln -s /bin/busybox /bin/ash +ENV SH=/bin/ash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-3.1r8-busybox-0.60.5-fail b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-3.1r8-busybox-0.60.5-fail new file mode 100644 index 0000000..8be761f --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-3.1r8-busybox-0.60.5-fail @@ -0,0 +1,5 @@ +FROM debian/eol:sarge-slim +RUN groupadd user && useradd -m user -g user \ + && apt-get update && apt-get -y install busybox-static \ + && ln -s /bin/busybox /bin/ash +ENV SH=/bin/ash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-3.1r8-ksh-93q-! b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-3.1r8-ksh-93q-! new file mode 100644 index 0000000..61b0677 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-3.1r8-ksh-93q-! @@ -0,0 +1,5 @@ +FROM debian/eol:sarge-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN groupadd user && useradd -m user -g user \ + && apt-get update && apt-get -y install ksh +ENV SH=/bin/ksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-4.0r9-busybox-1.1.3-! b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-4.0r9-busybox-1.1.3-! new file mode 100644 index 0000000..a9898e7 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-4.0r9-busybox-1.1.3-! @@ -0,0 +1,7 @@ +FROM debian/eol:etch-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && sed '/updates/s/^/# /' -i /etc/apt/sources.list \ + && apt-get update && apt-get -y install busybox \ + && /bin/busybox --install -s +ENV SH=/bin/ash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-4.0r9-dash-0.5.3-! b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-4.0r9-dash-0.5.3-! new file mode 100644 index 0000000..775a355 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-4.0r9-dash-0.5.3-! @@ -0,0 +1,6 @@ +FROM debian/eol:etch-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && sed '/updates/s/^/# /' -i /etc/apt/sources.list \ + && apt-get update && apt-get -y install dash +ENV SH=/bin/dash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-4.0r9-ksh-93r-! b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-4.0r9-ksh-93r-! new file mode 100644 index 0000000..2f2bdbb --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-4.0r9-ksh-93r-! @@ -0,0 +1,6 @@ +FROM debian/eol:etch-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && sed '/updates/s/^/# /' -i /etc/apt/sources.list \ + && apt-get update && apt-get -y install ksh +ENV SH=/bin/ksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-5.0.10-busybox-1.10.2-! b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-5.0.10-busybox-1.10.2-! new file mode 100644 index 0000000..3487d02 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.debian-5.0.10-busybox-1.10.2-! @@ -0,0 +1,6 @@ +FROM debian/eol:lenny-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y --force-yes install busybox \ + && /bin/busybox --install -s +ENV SH=/bin/ash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.installer-test b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.installer-test new file mode 100644 index 0000000..1bc2cd0 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.installer-test @@ -0,0 +1,61 @@ +ARG TYPE="general" + +FROM alpine as general_installer +RUN apk --no-cache add git curl +RUN echo 'cd $(dirname $(which _$1)); mv _$1 $1' > /usr/local/bin/enable \ + && echo 'cd $(dirname $(which $1)); mv $1 _$1' > /usr/local/bin/disable \ + && chmod +x /usr/local/bin/* +RUN echo '#!/bin/sh' > /entrypoint.sh \ + && echo 'echo You can use enable/disable [COMMAND]' >> /entrypoint.sh \ + && echo 'exec "$@"' >> /entrypoint.sh \ + && chmod +x /entrypoint.sh +ENV PATH $PATH:/root/bin +WORKDIR /root +ENTRYPOINT [ "/entrypoint.sh" ] +CMD [ "/bin/sh" ] + +FROM alpine as make_installer +RUN apk --no-cache add make +WORKDIR /root/shellspec + +FROM alpine as bpkg_installer +RUN apk --no-cache add bash git curl make coreutils +RUN curl -sLo- http://get.bpkg.sh | PREFIX=/usr/local bash +RUN echo '#!/bin/sh' > /entrypoint.sh \ + && echo 'echo Usage: bpkg install shellspec/shellspec' >> /entrypoint.sh \ + && echo 'echo Usage: bpkg install shellspec/shellspec@0.19.0' >> /entrypoint.sh \ + && echo 'echo Usage: bpkg install shellspec/shellspec -g' >> /entrypoint.sh \ + && echo 'exec "$@"' >> /entrypoint.sh \ + && chmod +x /entrypoint.sh +ENTRYPOINT [ "/entrypoint.sh" ] +WORKDIR /root/project +CMD [ "/bin/bash", "-l" ] + +FROM alpine as basher_installer +RUN apk --no-cache add bash git +RUN git clone https://github.com/basherpm/basher.git ~/.basher +RUN echo 'export PATH="$HOME/.basher/bin:$PATH"' >> ~/.bash_profile +RUN echo 'eval "$(basher init -)"' >> ~/.bash_profile +RUN echo '#!/bin/sh' > /entrypoint.sh \ + && echo 'echo Usage: basher install shellspec/shellspec' >> /entrypoint.sh \ + && echo 'echo Usage: basher install shellspec/shellspec@0.19.0' >> /entrypoint.sh \ + && echo 'echo Usage: basher link ./shellspec shellspec/shellspec' >> /entrypoint.sh \ + && echo 'exec "$@"' >> /entrypoint.sh \ + && chmod +x /entrypoint.sh +ENTRYPOINT [ "/entrypoint.sh" ] +WORKDIR /root +CMD [ "/bin/bash", "-l" ] + +FROM linuxbrew/brew as brew_installer +RUN echo '#!/bin/sh' > /entrypoint.sh \ + && echo 'echo "Usage: brew tap shellspec/shellspec"' >> /entrypoint.sh \ + && echo 'echo " brew install shellspec"' >> /entrypoint.sh \ + && echo 'echo " brew test shellspec"' >> /entrypoint.sh \ + && echo 'exec "$@"' >> /entrypoint.sh \ + && chmod +x /entrypoint.sh +ENTRYPOINT [ "/entrypoint.sh" ] +CMD [ "/bin/bash", "-l" ] + +FROM shellspec:${TYPE}_installer as test +COPY ./install.sh /root/ +COPY ./ /root/shellspec diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.shellcheck b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.shellcheck new file mode 100644 index 0000000..feb9c83 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.shellcheck @@ -0,0 +1,3 @@ +ARG VERSION=latest +FROM koalaman/shellcheck-alpine:$VERSION +COPY ./ ./ diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.shellspec b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.shellspec new file mode 100644 index 0000000..c5c0d14 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.shellspec @@ -0,0 +1,21 @@ +ARG IMAGE + +FROM shellspec:helpers as helpers + +FROM $IMAGE +COPY --from=helpers /usr/local/bin/* /usr/local/bin/ +WORKDIR /shellspec +RUN chmod ug+s /usr/local/bin/su-exec \ + && echo "--no-banner" > /home/user/.shellspec-options \ + && if [ "$KCOV" ]; then echo "--kcov" >> /home/user/.shellspec-options; fi \ + && ln -s /shellspec/shellspec /usr/local/bin/shellspec \ + && echo "$SH" > /etc/invokesh.conf \ + && [ "$SH" = "/bin/sh" ] || ln -snf /usr/local/bin/invokesh /bin/sh + +ENTRYPOINT [ "/entrypoint.sh" ] +CMD [ "shellspec" ] + +COPY ./dockerfiles/.shellspec-entrypoint.sh /entrypoint.sh +COPY --chown=user:user ./ /shellspec +RUN chmod 777 /shellspec +USER user diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.shellspec-entrypoint.sh b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.shellspec-entrypoint.sh new file mode 100755 index 0000000..d0716f5 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/.shellspec-entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +if [ "$1" = "shellspec" ]; then + ( + export SUDO_GID=$(id -g) SUDO_UID=$(id -u) + su-exec root shellspec --task fixture:stat:prepare + ) +fi + +exec "$@" diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/alpine-3.12.3-bash-5.0.17 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/alpine-3.12.3-bash-5.0.17 new file mode 100644 index 0000000..fba52e6 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/alpine-3.12.3-bash-5.0.17 @@ -0,0 +1,3 @@ +FROM alpine:3.12.3 +RUN adduser -D user && apk add --no-cache bash +ENV SH=/bin/bash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/alpine-3.12.3-loksh-6.7.1 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/alpine-3.12.3-loksh-6.7.1 new file mode 100644 index 0000000..68bb0f2 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/alpine-3.12.3-loksh-6.7.1 @@ -0,0 +1,3 @@ +FROM alpine:3.12.3 +RUN adduser -D user && apk add --no-cache loksh +ENV SH=/bin/ksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/alpine-3.12.3-sh-1.31.1 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/alpine-3.12.3-sh-1.31.1 new file mode 100644 index 0000000..400089b --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/alpine-3.12.3-sh-1.31.1 @@ -0,0 +1,3 @@ +FROM alpine:3.12.3 +RUN adduser -D user +ENV SH=/bin/ash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/alpine-edge-loksh-6.8.1 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/alpine-edge-loksh-6.8.1 new file mode 100644 index 0000000..fd80a8b --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/alpine-edge-loksh-6.8.1 @@ -0,0 +1,3 @@ +FROM alpine:edge +RUN adduser -D user && apk add --no-cache loksh +ENV SH=/bin/ksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/alpine-edge-oksh-6.8.1 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/alpine-edge-oksh-6.8.1 new file mode 100644 index 0000000..c1dbdc0 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/alpine-edge-oksh-6.8.1 @@ -0,0 +1,4 @@ +FROM alpine:edge +RUN echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories +RUN adduser -D user && apk add --no-cache oksh@testing +ENV SH=/bin/oksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/busybox-1.32.0-sh-1.32.0 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/busybox-1.32.0-sh-1.32.0 new file mode 100644 index 0000000..4d4ce6f --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/busybox-1.32.0-sh-1.32.0 @@ -0,0 +1,3 @@ +FROM busybox:1.32.0 +RUN adduser -D user +ENV SH=/bin/ash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/centos-7.9.2009-sh-4.2.46 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/centos-7.9.2009-sh-4.2.46 new file mode 100644 index 0000000..aa817a8 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/centos-7.9.2009-sh-4.2.46 @@ -0,0 +1,3 @@ +FROM centos:7.9.2009 +RUN useradd -m user +ENV SH=/bin/sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/centos-8.3.2011-sh-4.4.19 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/centos-8.3.2011-sh-4.4.19 new file mode 100644 index 0000000..d8b91e0 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/centos-8.3.2011-sh-4.4.19 @@ -0,0 +1,3 @@ +FROM centos:8.3.2011 +RUN useradd -m user +ENV SH=/bin/sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/centos-8.3.2011-zsh-5.5.1 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/centos-8.3.2011-zsh-5.5.1 new file mode 100644 index 0000000..c842a3e --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/centos-8.3.2011-zsh-5.5.1 @@ -0,0 +1,4 @@ +FROM centos:8.3.2011 +RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial +RUN useradd -m user && yum -y install zsh +ENV SH=/usr/bin/zsh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-bash-5.0.3 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-bash-5.0.3 new file mode 100644 index 0000000..bc6ce91 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-bash-5.0.3 @@ -0,0 +1,4 @@ +FROM debian:10.7-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user +ENV SH=/bin/bash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-busybox-1.30.1 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-busybox-1.30.1 new file mode 100644 index 0000000..76696dd --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-busybox-1.30.1 @@ -0,0 +1,6 @@ +FROM debian:10.7-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install busybox \ + && /bin/busybox --install -s +ENV SH=/bin/ash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-dash-0.5.10.2 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-dash-0.5.10.2 new file mode 100644 index 0000000..8369738 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-dash-0.5.10.2 @@ -0,0 +1,4 @@ +FROM debian:10.7-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user +ENV SH=/bin/dash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-ksh-93u b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-ksh-93u new file mode 100644 index 0000000..9f3d30e --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-ksh-93u @@ -0,0 +1,5 @@ +FROM debian:10.7-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install ksh +ENV SH=/bin/ksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-lksh-57 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-lksh-57 new file mode 100644 index 0000000..a657b79 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-lksh-57 @@ -0,0 +1,5 @@ +FROM debian:10.7-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install mksh +ENV SH=/bin/lksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-mksh-57 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-mksh-57 new file mode 100644 index 0000000..f305600 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-mksh-57 @@ -0,0 +1,5 @@ +FROM debian:10.7-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install mksh +ENV SH=/bin/mksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-posh-0.13.2 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-posh-0.13.2 new file mode 100644 index 0000000..82a8167 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-posh-0.13.2 @@ -0,0 +1,5 @@ +FROM debian:10.7-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install posh procps +ENV SH=/usr/bin/posh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-yash-2.48 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-yash-2.48 new file mode 100644 index 0000000..2c7ca9f --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-yash-2.48 @@ -0,0 +1,5 @@ +FROM debian:10.7-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install yash +ENV SH=/usr/bin/yash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-zsh-5.7.1 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-zsh-5.7.1 new file mode 100644 index 0000000..d5c106d --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-10.7-zsh-5.7.1 @@ -0,0 +1,5 @@ +FROM debian:10.7-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install zsh +ENV SH=/usr/bin/zsh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-2.2r7-bash-2.03 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-2.2r7-bash-2.03 new file mode 100644 index 0000000..f550cc8 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-2.2r7-bash-2.03 @@ -0,0 +1,3 @@ +FROM debian/eol:potato-slim +RUN groupadd user && useradd -m user -g user +ENV SH=/bin/bash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-2.2r7-pdksh-5.2.14 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-2.2r7-pdksh-5.2.14 new file mode 100644 index 0000000..e78b23c --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-2.2r7-pdksh-5.2.14 @@ -0,0 +1,4 @@ +FROM debian/eol:potato-slim +RUN groupadd user && useradd -m user -g user \ + && apt-get update && apt-get -y install pdksh +ENV SH=/usr/bin/ksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-2.2r7-sh-2.03 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-2.2r7-sh-2.03 new file mode 100644 index 0000000..d1da5c4 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-2.2r7-sh-2.03 @@ -0,0 +1,3 @@ +FROM debian/eol:potato-slim +RUN groupadd user && useradd -m user -g user +ENV SH=/bin/sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-2.2r7-zsh-3.1.9 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-2.2r7-zsh-3.1.9 new file mode 100644 index 0000000..68f6f30 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-2.2r7-zsh-3.1.9 @@ -0,0 +1,4 @@ +FROM debian/eol:potato-slim +RUN groupadd user && useradd -m user -g user \ + && apt-get update && apt-get -y install zsh +ENV SH=/usr/bin/zsh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.0r6-bash-2.05a b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.0r6-bash-2.05a new file mode 100644 index 0000000..4830e8a --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.0r6-bash-2.05a @@ -0,0 +1,3 @@ +FROM debian/eol:woody-slim +RUN groupadd user && useradd -m user -g user +ENV SH=/bin/bash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.0r6-pdksh-5.2.14 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.0r6-pdksh-5.2.14 new file mode 100644 index 0000000..73ac08b --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.0r6-pdksh-5.2.14 @@ -0,0 +1,4 @@ +FROM debian/eol:woody-slim +RUN groupadd user && useradd -m user -g user \ + && apt-get update && apt-get -y install pdksh +ENV SH=/usr/bin/ksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.0r6-sh-2.05a b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.0r6-sh-2.05a new file mode 100644 index 0000000..48bfc45 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.0r6-sh-2.05a @@ -0,0 +1,3 @@ +FROM debian/eol:woody-slim +RUN groupadd user && useradd -m user -g user +ENV SH=/bin/sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.0r6-zsh-4.0.4 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.0r6-zsh-4.0.4 new file mode 100644 index 0000000..945be16 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.0r6-zsh-4.0.4 @@ -0,0 +1,4 @@ +FROM debian/eol:woody-slim +RUN groupadd user && useradd -m user -g user \ + && apt-get update && apt-get -y install zsh +ENV SH=/usr/bin/zsh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.1r8-bash-2.05b b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.1r8-bash-2.05b new file mode 100644 index 0000000..7e51265 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.1r8-bash-2.05b @@ -0,0 +1,4 @@ +FROM debian/eol:sarge-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN groupadd user && useradd -m user -g user +ENV SH=/bin/bash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.1r8-dash-0.5.2 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.1r8-dash-0.5.2 new file mode 100644 index 0000000..8eb7500 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.1r8-dash-0.5.2 @@ -0,0 +1,5 @@ +FROM debian/eol:sarge-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN groupadd user && useradd -m user -g user \ + && apt-get update && apt-get -y install dash +ENV SH=/bin/dash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.1r8-pdksh-5.2.14 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.1r8-pdksh-5.2.14 new file mode 100644 index 0000000..c015d0c --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.1r8-pdksh-5.2.14 @@ -0,0 +1,5 @@ +FROM debian/eol:sarge-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN groupadd user && useradd -m user -g user \ + && apt-get update && apt-get -y install pdksh +ENV SH=/bin/pdksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.1r8-posh-0.3.14 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.1r8-posh-0.3.14 new file mode 100644 index 0000000..9fb8ee7 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.1r8-posh-0.3.14 @@ -0,0 +1,5 @@ +FROM debian/eol:sarge-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN groupadd user && useradd -m user -g user \ + && apt-get update && apt-get -y install posh +ENV SH=/bin/posh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.1r8-sh-2.05b b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.1r8-sh-2.05b new file mode 100644 index 0000000..2c46505 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.1r8-sh-2.05b @@ -0,0 +1,4 @@ +FROM debian/eol:sarge-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN groupadd user && useradd -m user -g user +ENV SH=/bin/sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.1r8-zsh-4.2.5 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.1r8-zsh-4.2.5 new file mode 100644 index 0000000..fbe7f61 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-3.1r8-zsh-4.2.5 @@ -0,0 +1,5 @@ +FROM debian/eol:sarge-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN groupadd user && useradd -m user -g user \ + && apt-get update && apt-get -y install zsh +ENV SH=/usr/bin/zsh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-4.0r9-bash-3.1.17 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-4.0r9-bash-3.1.17 new file mode 100644 index 0000000..4d92135 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-4.0r9-bash-3.1.17 @@ -0,0 +1,4 @@ +FROM debian/eol:etch-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user +ENV SH=/bin/bash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-4.0r9-mksh-28 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-4.0r9-mksh-28 new file mode 100644 index 0000000..bd5e886 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-4.0r9-mksh-28 @@ -0,0 +1,6 @@ +FROM debian/eol:etch-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && sed '/updates/s/^/# /' -i /etc/apt/sources.list \ + && apt-get update && apt-get -y install mksh +ENV SH=/bin/mksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-4.0r9-pdksh-5.2.14 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-4.0r9-pdksh-5.2.14 new file mode 100644 index 0000000..1e9734b --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-4.0r9-pdksh-5.2.14 @@ -0,0 +1,6 @@ +FROM debian/eol:etch-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && sed '/updates/s/^/# /' -i /etc/apt/sources.list \ + && apt-get update && apt-get -y install pdksh +ENV SH=/bin/pdksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-4.0r9-posh-0.5.4 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-4.0r9-posh-0.5.4 new file mode 100644 index 0000000..92dde09 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-4.0r9-posh-0.5.4 @@ -0,0 +1,6 @@ +FROM debian/eol:etch-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && sed '/updates/s/^/# /' -i /etc/apt/sources.list \ + && apt-get update && apt-get -y install posh +ENV SH=/bin/posh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-4.0r9-sh-3.1.17 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-4.0r9-sh-3.1.17 new file mode 100644 index 0000000..dc5e84d --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-4.0r9-sh-3.1.17 @@ -0,0 +1,4 @@ +FROM debian/eol:etch-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user +ENV SH=/bin/sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-4.0r9-zsh-4.3.2 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-4.0r9-zsh-4.3.2 new file mode 100644 index 0000000..4189423 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-4.0r9-zsh-4.3.2 @@ -0,0 +1,6 @@ +FROM debian/eol:etch-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && sed '/updates/s/^/# /' -i /etc/apt/sources.list \ + && apt-get update && apt-get -y install zsh && touch /home/user/.zshrc +ENV SH=/usr/bin/zsh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-bash-3.2.39 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-bash-3.2.39 new file mode 100644 index 0000000..e058857 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-bash-3.2.39 @@ -0,0 +1,4 @@ +FROM debian/eol:lenny-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user +ENV SH=/bin/bash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-dash-0.5.4 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-dash-0.5.4 new file mode 100644 index 0000000..ff3937b --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-dash-0.5.4 @@ -0,0 +1,5 @@ +FROM debian/eol:lenny-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y --force-yes install dash +ENV SH=/bin/dash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-ksh-93s b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-ksh-93s new file mode 100644 index 0000000..b145fbb --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-ksh-93s @@ -0,0 +1,5 @@ +FROM debian/eol:lenny-slim +RUN useradd -m user \ + && export DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes \ + && apt-get update && apt-get -y --force-yes install ksh +ENV SH=/bin/ksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-mksh-35 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-mksh-35 new file mode 100644 index 0000000..fbf9db1 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-mksh-35 @@ -0,0 +1,5 @@ +FROM debian/eol:lenny-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y --force-yes install mksh +ENV SH=/bin/mksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-pdksh-5.2.14 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-pdksh-5.2.14 new file mode 100644 index 0000000..b851fac --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-pdksh-5.2.14 @@ -0,0 +1,5 @@ +FROM debian/eol:lenny-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y --force-yes install pdksh +ENV SH=/bin/pdksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-posh-0.6.13 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-posh-0.6.13 new file mode 100644 index 0000000..0d1b505 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-posh-0.6.13 @@ -0,0 +1,5 @@ +FROM debian/eol:lenny-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y --force-yes install posh +ENV SH=/bin/posh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-sh-3.2.39 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-sh-3.2.39 new file mode 100644 index 0000000..f228fb2 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-sh-3.2.39 @@ -0,0 +1,4 @@ +FROM debian/eol:lenny-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user +ENV SH=/bin/sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-zsh-4.3.6 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-zsh-4.3.6 new file mode 100644 index 0000000..5fabfbf --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-5.0.10-zsh-4.3.6 @@ -0,0 +1,5 @@ +FROM debian/eol:lenny-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y --force-yes install zsh +ENV SH=/usr/bin/zsh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-bash-4.1.5 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-bash-4.1.5 new file mode 100644 index 0000000..75d18cb --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-bash-4.1.5 @@ -0,0 +1,4 @@ +FROM debian/eol:squeeze-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user +ENV SH=/bin/bash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-busybox-1.17.1 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-busybox-1.17.1 new file mode 100644 index 0000000..aba3909 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-busybox-1.17.1 @@ -0,0 +1,6 @@ +FROM debian/eol:squeeze-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y --force-yes install busybox \ + && /bin/busybox --install -s +ENV SH=/bin/ash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-dash-0.5.5.1 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-dash-0.5.5.1 new file mode 100644 index 0000000..aef1e9f --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-dash-0.5.5.1 @@ -0,0 +1,4 @@ +FROM debian/eol:squeeze-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user +ENV SH=/bin/dash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-ksh-93s b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-ksh-93s new file mode 100644 index 0000000..7741cbd --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-ksh-93s @@ -0,0 +1,5 @@ +FROM debian/eol:squeeze-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y --force-yes install ksh +ENV SH=/bin/ksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-mksh-39 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-mksh-39 new file mode 100644 index 0000000..ee0a3f8 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-mksh-39 @@ -0,0 +1,5 @@ +FROM debian/eol:squeeze-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y --force-yes install mksh +ENV SH=/bin/mksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-pdksh-5.2.14 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-pdksh-5.2.14 new file mode 100644 index 0000000..636dbfa --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-pdksh-5.2.14 @@ -0,0 +1,5 @@ +FROM debian/eol:squeeze-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y --force-yes install pdksh +ENV SH=/bin/pdksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-posh-0.8.5 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-posh-0.8.5 new file mode 100644 index 0000000..068bba5 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-posh-0.8.5 @@ -0,0 +1,5 @@ +FROM debian/eol:squeeze-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y --force-yes install posh procps +ENV SH=/bin/posh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-zsh-4.3.10 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-zsh-4.3.10 new file mode 100644 index 0000000..e1c2101 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-6.0.10-zsh-4.3.10 @@ -0,0 +1,5 @@ +FROM debian/eol:squeeze-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y --force-yes install zsh +ENV SH=/usr/bin/zsh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-bash-4.2.37 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-bash-4.2.37 new file mode 100644 index 0000000..0eb1805 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-bash-4.2.37 @@ -0,0 +1,4 @@ +FROM debian/eol:wheezy-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user +ENV SH=/bin/bash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-busybox-1.20.0 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-busybox-1.20.0 new file mode 100644 index 0000000..aa0dbb2 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-busybox-1.20.0 @@ -0,0 +1,6 @@ +FROM debian/eol:wheezy-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install busybox \ + && /bin/busybox --install -s +ENV SH=/bin/ash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-dash-0.5.7 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-dash-0.5.7 new file mode 100644 index 0000000..d8717a9 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-dash-0.5.7 @@ -0,0 +1,4 @@ +FROM debian/eol:wheezy-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user +ENV SH=/bin/dash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-ksh-93u b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-ksh-93u new file mode 100644 index 0000000..900071b --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-ksh-93u @@ -0,0 +1,5 @@ +FROM debian/eol:wheezy-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install ksh +ENV SH=/bin/ksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-lksh-40 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-lksh-40 new file mode 100644 index 0000000..0dda521 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-lksh-40 @@ -0,0 +1,5 @@ +FROM debian/eol:wheezy-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install mksh +ENV SH=/bin/lksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-mksh-40 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-mksh-40 new file mode 100644 index 0000000..0fa0009 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-mksh-40 @@ -0,0 +1,5 @@ +FROM debian/eol:wheezy-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install mksh +ENV SH=/bin/mksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-posh-0.10.2-! b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-posh-0.10.2-! new file mode 100644 index 0000000..8d7c9c5 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-posh-0.10.2-! @@ -0,0 +1,5 @@ +FROM debian/eol:wheezy-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install posh procps +ENV SH=/bin/posh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-yash-2.30 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-yash-2.30 new file mode 100644 index 0000000..a153a01 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-yash-2.30 @@ -0,0 +1,5 @@ +FROM debian/eol:wheezy-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install yash +ENV SH=/usr/bin/yash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-zsh-4.3.17 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-zsh-4.3.17 new file mode 100644 index 0000000..bc87dfe --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-7.11-zsh-4.3.17 @@ -0,0 +1,5 @@ +FROM debian/eol:wheezy-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install zsh +ENV SH=/usr/bin/zsh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-bash-4.3.30 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-bash-4.3.30 new file mode 100644 index 0000000..5cd9919 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-bash-4.3.30 @@ -0,0 +1,4 @@ +FROM debian:8.11-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user +ENV SH=/bin/bash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-busybox-1.22.0 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-busybox-1.22.0 new file mode 100644 index 0000000..0a3f1db --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-busybox-1.22.0 @@ -0,0 +1,6 @@ +FROM debian:8.11-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install busybox \ + && /bin/busybox --install -s +ENV SH=/bin/ash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-dash-0.5.7 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-dash-0.5.7 new file mode 100644 index 0000000..a1ec0f9 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-dash-0.5.7 @@ -0,0 +1,4 @@ +FROM debian:8.11-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user +ENV SH=/bin/dash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-ksh-93u b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-ksh-93u new file mode 100644 index 0000000..bf21060 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-ksh-93u @@ -0,0 +1,5 @@ +FROM debian:8.11-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install ksh +ENV SH=/bin/ksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-lksh-50d b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-lksh-50d new file mode 100644 index 0000000..ef6a085 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-lksh-50d @@ -0,0 +1,5 @@ +FROM debian:8.11-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install mksh +ENV SH=/bin/lksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-mksh-50d b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-mksh-50d new file mode 100644 index 0000000..c7776d1 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-mksh-50d @@ -0,0 +1,5 @@ +FROM debian:8.11-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install mksh +ENV SH=/bin/mksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-posh-0.12.3 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-posh-0.12.3 new file mode 100644 index 0000000..89b8cf5 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-posh-0.12.3 @@ -0,0 +1,5 @@ +FROM debian:8.11-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install posh +ENV SH=/bin/posh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-yash-2.36 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-yash-2.36 new file mode 100644 index 0000000..011be76 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-yash-2.36 @@ -0,0 +1,5 @@ +FROM debian:8.11-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install yash +ENV SH=/usr/bin/yash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-zsh-5.0.7 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-zsh-5.0.7 new file mode 100644 index 0000000..ae86931 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-8.11-zsh-5.0.7 @@ -0,0 +1,5 @@ +FROM debian:8.11-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install zsh +ENV SH=/usr/bin/zsh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-bash-4.4.12 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-bash-4.4.12 new file mode 100644 index 0000000..c3201b3 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-bash-4.4.12 @@ -0,0 +1,4 @@ +FROM debian:9.13-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user +ENV SH=/bin/bash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-busybox-1.22.0 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-busybox-1.22.0 new file mode 100644 index 0000000..2647887 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-busybox-1.22.0 @@ -0,0 +1,6 @@ +FROM debian:9.13-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install busybox \ + && /bin/busybox --install -s +ENV SH=/bin/ash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-dash-0.5.8 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-dash-0.5.8 new file mode 100644 index 0000000..c8e29b0 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-dash-0.5.8 @@ -0,0 +1,4 @@ +FROM debian:9.13-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user +ENV SH=/bin/dash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-ksh-93u b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-ksh-93u new file mode 100644 index 0000000..28efda5 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-ksh-93u @@ -0,0 +1,5 @@ +FROM debian:9.13-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install ksh +ENV SH=/bin/ksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-lksh-54 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-lksh-54 new file mode 100644 index 0000000..d6b6060 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-lksh-54 @@ -0,0 +1,5 @@ +FROM debian:9.13-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install mksh +ENV SH=/bin/lksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-mksh-54 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-mksh-54 new file mode 100644 index 0000000..3328707 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-mksh-54 @@ -0,0 +1,5 @@ +FROM debian:9.13-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install mksh +ENV SH=/bin/mksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-posh-0.12.6 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-posh-0.12.6 new file mode 100644 index 0000000..93d6bf9 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-posh-0.12.6 @@ -0,0 +1,5 @@ +FROM debian:9.13-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install posh procps +ENV SH=/bin/posh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-yash-2.43 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-yash-2.43 new file mode 100644 index 0000000..c655c16 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-yash-2.43 @@ -0,0 +1,5 @@ +FROM debian:9.13-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install yash +ENV SH=/usr/bin/yash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-zsh-5.3.1 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-zsh-5.3.1 new file mode 100644 index 0000000..091ae8c --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-9.13-zsh-5.3.1 @@ -0,0 +1,5 @@ +FROM debian:9.13-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install zsh +ENV SH=/usr/bin/zsh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-bash-5.1.0 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-bash-5.1.0 new file mode 100644 index 0000000..7e42a3f --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-bash-5.1.0 @@ -0,0 +1,4 @@ +FROM debian:bullseye-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user +ENV SH=/bin/bash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-dash-0.5.11 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-dash-0.5.11 new file mode 100644 index 0000000..e7f4f16 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-dash-0.5.11 @@ -0,0 +1,4 @@ +FROM debian:bullseye-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user +ENV SH=/bin/dash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-ksh-2020.0.0 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-ksh-2020.0.0 new file mode 100644 index 0000000..3315807 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-ksh-2020.0.0 @@ -0,0 +1,5 @@ +FROM debian:bullseye-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install ksh +ENV SH=/bin/ksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-lksh-59c b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-lksh-59c new file mode 100644 index 0000000..7de08b5 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-lksh-59c @@ -0,0 +1,5 @@ +FROM debian:bullseye-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install mksh +ENV SH=/bin/lksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-mksh-59c b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-mksh-59c new file mode 100644 index 0000000..7ea1d56 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-mksh-59c @@ -0,0 +1,5 @@ +FROM debian:bullseye-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install mksh +ENV SH=/bin/mksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-posh-0.14.1 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-posh-0.14.1 new file mode 100644 index 0000000..eea55ca --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-posh-0.14.1 @@ -0,0 +1,5 @@ +FROM debian:bullseye-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install posh procps +ENV SH=/usr/bin/posh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-yash-2.50 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-yash-2.50 new file mode 100644 index 0000000..ca3bc8e --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-yash-2.50 @@ -0,0 +1,5 @@ +FROM debian:bullseye-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install yash +ENV SH=/usr/bin/yash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-zsh-5.8 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-zsh-5.8 new file mode 100644 index 0000000..25f04c0 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-bullseye-zsh-5.8 @@ -0,0 +1,5 @@ +FROM debian:bullseye-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install zsh +ENV SH=/usr/bin/zsh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-sid-kcov-38 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-sid-kcov-38 new file mode 100644 index 0000000..f459492 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/debian-sid-kcov-38 @@ -0,0 +1,5 @@ +FROM debian:sid-slim +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install kcov +ENV SH=/bin/bash KCOV=1 diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/fedora-32-sh-5.0.11 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/fedora-32-sh-5.0.11 new file mode 100644 index 0000000..96c5e1a --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/fedora-32-sh-5.0.11 @@ -0,0 +1,3 @@ +FROM fedora:32 +RUN useradd -m user +ENV SH=/bin/sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/fedora-33-sh-5.0.17 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/fedora-33-sh-5.0.17 new file mode 100644 index 0000000..518f95e --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/fedora-33-sh-5.0.17 @@ -0,0 +1,3 @@ +FROM fedora:33 +RUN useradd -m user +ENV SH=/bin/sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/gwsh-snapshot-20190627 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/gwsh-snapshot-20190627 new file mode 100644 index 0000000..56b9a32 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/gwsh-snapshot-20190627 @@ -0,0 +1,3 @@ +FROM shellspec/gwsh:20190627 +RUN useradd -m user +ENV SH=/usr/local/bin/gwsh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/lede-17.01.7-sh-1.25.1 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/lede-17.01.7-sh-1.25.1 new file mode 100644 index 0000000..5f82ba2 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/lede-17.01.7-sh-1.25.1 @@ -0,0 +1,5 @@ +FROM shellspec/lede:17.01.7 +RUN mkdir /var/lock /home \ + && opkg update && opkg install shadow-useradd \ + && useradd -m user +ENV SH=/bin/ash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/openwrt-10.03.1-sh-1.15.3-! b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/openwrt-10.03.1-sh-1.15.3-! new file mode 100644 index 0000000..6bf9094 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/openwrt-10.03.1-sh-1.15.3-! @@ -0,0 +1,5 @@ +FROM shellspec/openwrt:10.03.1 +RUN mkdir /var/lock /home \ + && opkg update && opkg install shadow-groupadd shadow-useradd \ + && groupadd user && useradd -m user -g user +ENV SH=/bin/sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/openwrt-12.09-sh-1.19.4-! b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/openwrt-12.09-sh-1.19.4-! new file mode 100644 index 0000000..d4cda19 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/openwrt-12.09-sh-1.19.4-! @@ -0,0 +1,5 @@ +FROM shellspec/openwrt:12.09 +RUN mkdir /var/lock /home \ + && opkg update && opkg install shadow-useradd \ + && useradd -m user +ENV SH=/bin/sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/openwrt-14.07-sh-1.22.1 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/openwrt-14.07-sh-1.22.1 new file mode 100644 index 0000000..57a5eea --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/openwrt-14.07-sh-1.22.1 @@ -0,0 +1,5 @@ +FROM shellspec/openwrt:14.07 +RUN mkdir /var/lock /home \ + && opkg update && opkg install shadow-useradd \ + && useradd -m user +ENV SH=/bin/sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/openwrt-15.05.1-sh-1.23.2 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/openwrt-15.05.1-sh-1.23.2 new file mode 100644 index 0000000..60eab1e --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/openwrt-15.05.1-sh-1.23.2 @@ -0,0 +1,5 @@ +FROM shellspec/openwrt:15.05.1 +RUN mkdir /var/lock /home \ + && opkg update && opkg install shadow-useradd \ + && useradd -m user +ENV SH=/bin/sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/openwrt-18.06.9-sh-1.28.4 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/openwrt-18.06.9-sh-1.28.4 new file mode 100644 index 0000000..f6a75fb --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/openwrt-18.06.9-sh-1.28.4 @@ -0,0 +1,5 @@ +FROM shellspec/openwrt:18.06.9 +RUN mkdir /var/lock /home \ + && opkg update && opkg install shadow-useradd \ + && useradd -m user +ENV SH=/bin/sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/openwrt-19.07.5-sh-1.30.1 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/openwrt-19.07.5-sh-1.30.1 new file mode 100644 index 0000000..f5bc577 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/openwrt-19.07.5-sh-1.30.1 @@ -0,0 +1,5 @@ +FROM shellspec/openwrt:19.07.5 +RUN mkdir /var/lock /home \ + && opkg update && opkg install shadow-useradd \ + && useradd -m user +ENV SH=/bin/sh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20181030-bosh-20181007 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20181030-bosh-20181007 new file mode 100644 index 0000000..08a7079 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20181030-bosh-20181007 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2018-10-30 +RUN useradd -m user +ENV SH=/usr/local/bin/bosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20181030-pbosh-20181007 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20181030-pbosh-20181007 new file mode 100644 index 0000000..0c93036 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20181030-pbosh-20181007 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2018-10-30 +RUN useradd -m user +ENV SH=/usr/local/bin/pbosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20190311-bosh-20190205 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20190311-bosh-20190205 new file mode 100644 index 0000000..570fcc8 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20190311-bosh-20190205 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2019-03-11 +RUN useradd -m user +ENV SH=/usr/local/bin/bosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20190311-pbosh-20190205 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20190311-pbosh-20190205 new file mode 100644 index 0000000..b1ab950 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20190311-pbosh-20190205 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2019-03-11 +RUN useradd -m user +ENV SH=/usr/local/bin/pbosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20190922-bosh-20190825 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20190922-bosh-20190825 new file mode 100644 index 0000000..9edfb31 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20190922-bosh-20190825 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2019-09-22 +RUN useradd -m user +ENV SH=/usr/local/bin/bosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20190922-pbosh-20190825 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20190922-pbosh-20190825 new file mode 100644 index 0000000..fe59122 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20190922-pbosh-20190825 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2019-09-22 +RUN useradd -m user +ENV SH=/usr/local/bin/pbosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20191007-bosh-20190927 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20191007-bosh-20190927 new file mode 100644 index 0000000..ed199d5 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20191007-bosh-20190927 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2019-10-07 +RUN useradd -m user +ENV SH=/usr/local/bin/bosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20191007-pbosh-20190927 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20191007-pbosh-20190927 new file mode 100644 index 0000000..5c798bd --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20191007-pbosh-20190927 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2019-10-07 +RUN useradd -m user +ENV SH=/usr/local/bin/pbosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20191025-bosh-20191025 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20191025-bosh-20191025 new file mode 100644 index 0000000..e926b81 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20191025-bosh-20191025 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2019-10-25 +RUN useradd -m user +ENV SH=/usr/local/bin/bosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20191025-pbosh-20191025 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20191025-pbosh-20191025 new file mode 100644 index 0000000..b9c7c6e --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20191025-pbosh-20191025 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2019-10-25 +RUN useradd -m user +ENV SH=/usr/local/bin/pbosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200211-bosh-20200124 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200211-bosh-20200124 new file mode 100644 index 0000000..8c01e94 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200211-bosh-20200124 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2020-02-11 +RUN useradd -m user +ENV SH=/usr/local/bin/bosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200211-pbosh-20200124 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200211-pbosh-20200124 new file mode 100644 index 0000000..64dbaba --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200211-pbosh-20200124 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2020-02-11 +RUN useradd -m user +ENV SH=/usr/local/bin/pbosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200327-bosh-20200325 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200327-bosh-20200325 new file mode 100644 index 0000000..8c67d1f --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200327-bosh-20200325 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2020-03-27 +RUN useradd -m user +ENV SH=/usr/local/bin/bosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200327-pbosh-20200325 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200327-pbosh-20200325 new file mode 100644 index 0000000..5eccfdd --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200327-pbosh-20200325 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2020-03-27 +RUN useradd -m user +ENV SH=/usr/local/bin/pbosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200418-bosh-20200410-! b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200418-bosh-20200410-! new file mode 100644 index 0000000..167799f --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200418-bosh-20200410-! @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2020-04-18 +RUN useradd -m user +ENV SH=/usr/local/bin/bosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200418-pbosh-20200410-! b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200418-pbosh-20200410-! new file mode 100644 index 0000000..ef4859c --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200418-pbosh-20200410-! @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2020-04-18 +RUN useradd -m user +ENV SH=/usr/local/bin/pbosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200511-bosh-20200427 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200511-bosh-20200427 new file mode 100644 index 0000000..34e722f --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200511-bosh-20200427 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2020-05-11 +RUN useradd -m user +ENV SH=/usr/local/bin/bosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200511-pbosh-20200427 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200511-pbosh-20200427 new file mode 100644 index 0000000..1ccebcc --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200511-pbosh-20200427 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2020-05-11 +RUN useradd -m user +ENV SH=/usr/local/bin/pbosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200904-bosh-20200903 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200904-bosh-20200903 new file mode 100644 index 0000000..32fdc81 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200904-bosh-20200903 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2020-09-04 +RUN useradd -m user +ENV SH=/usr/local/bin/bosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200904-pbosh-20200903 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200904-pbosh-20200903 new file mode 100644 index 0000000..54c53d6 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20200904-pbosh-20200903 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2020-09-04 +RUN useradd -m user +ENV SH=/usr/local/bin/pbosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20201009-bosh-20201007 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20201009-bosh-20201007 new file mode 100644 index 0000000..6686952 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20201009-bosh-20201007 @@ -0,0 +1,4 @@ +FROM shellspec/schilytools:2020-10-09 +RUN apt-get update && apt-get install -y procps +RUN useradd -m user +ENV SH=/usr/local/bin/bosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20201009-pbosh-20201007 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20201009-pbosh-20201007 new file mode 100644 index 0000000..8fc195a --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20201009-pbosh-20201007 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2020-10-09 +RUN useradd -m user +ENV SH=/usr/local/bin/pbosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20201104-bosh-20201104 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20201104-bosh-20201104 new file mode 100644 index 0000000..ea1b75d --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20201104-bosh-20201104 @@ -0,0 +1,4 @@ +FROM shellspec/schilytools:2020-11-04 +RUN apt-get update && apt-get install -y procps +RUN useradd -m user +ENV SH=/usr/local/bin/bosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20201104-pbosh-20201104 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20201104-pbosh-20201104 new file mode 100644 index 0000000..18c2a08 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/schily-20201104-pbosh-20201104 @@ -0,0 +1,3 @@ +FROM shellspec/schilytools:2020-11-04 +RUN useradd -m user +ENV SH=/usr/local/bin/pbosh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-12.04-ksh-93u b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-12.04-ksh-93u new file mode 100644 index 0000000..e95df8e --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-12.04-ksh-93u @@ -0,0 +1,5 @@ +FROM ubuntu:12.04 +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install ksh +ENV SH=/bin/ksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-16.04-mksh-52c b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-16.04-mksh-52c new file mode 100644 index 0000000..b5ad451 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-16.04-mksh-52c @@ -0,0 +1,5 @@ +FROM ubuntu:16.04 +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install mksh +ENV SH=/bin/mksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-16.04-zsh-5.1.1 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-16.04-zsh-5.1.1 new file mode 100644 index 0000000..59042c8 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-16.04-zsh-5.1.1 @@ -0,0 +1,5 @@ +FROM ubuntu:16.04 +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install zsh +ENV SH=/usr/bin/zsh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-18.04-busybox-1.27.2 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-18.04-busybox-1.27.2 new file mode 100644 index 0000000..f96e71c --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-18.04-busybox-1.27.2 @@ -0,0 +1,6 @@ +FROM ubuntu:18.04 +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install busybox \ + && /bin/busybox --install -s +ENV SH=/bin/ash diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-18.04-mksh-56c b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-18.04-mksh-56c new file mode 100644 index 0000000..2f1cd97 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-18.04-mksh-56c @@ -0,0 +1,5 @@ +FROM ubuntu:18.04 +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install mksh +ENV SH=/bin/mksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-18.04-posh-0.13.1 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-18.04-posh-0.13.1 new file mode 100644 index 0000000..9989c5f --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-18.04-posh-0.13.1 @@ -0,0 +1,5 @@ +FROM ubuntu:18.04 +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install posh +ENV SH=/usr/bin/posh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-18.04-zsh-5.4.2 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-18.04-zsh-5.4.2 new file mode 100644 index 0000000..37b98fc --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-18.04-zsh-5.4.2 @@ -0,0 +1,5 @@ +FROM ubuntu:18.04 +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install zsh +ENV SH=/usr/bin/zsh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-19.10-kcov-36 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-19.10-kcov-36 new file mode 100644 index 0000000..d764ac9 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-19.10-kcov-36 @@ -0,0 +1,6 @@ +FROM ubuntu:19.10 +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && sed -i -E 's/(archive|security).ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list \ + && apt-get update && apt-get -y install kcov +ENV SH=/bin/bash KCOV=1 diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-20.04-kcov-38 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-20.04-kcov-38 new file mode 100644 index 0000000..74a246f --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-20.04-kcov-38 @@ -0,0 +1,5 @@ +FROM ubuntu:20.04 +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install kcov +ENV SH=/bin/bash KCOV=1 diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-20.04-ksh-2020 b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-20.04-ksh-2020 new file mode 100644 index 0000000..7e7b85b --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-20.04-ksh-2020 @@ -0,0 +1,5 @@ +FROM ubuntu:20.04 +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install ksh +ENV SH=/bin/ksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-20.04-ksh-93u b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-20.04-ksh-93u new file mode 100644 index 0000000..908579c --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/dockerfiles/ubuntu-20.04-ksh-93u @@ -0,0 +1,5 @@ +FROM ubuntu:20.04 +ENV DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes +RUN useradd -m user \ + && apt-get update && apt-get -y install ksh93 +ENV SH=/bin/ksh diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/docs/architecture.md b/tests/shellspec/.vendor/shellspec-0.28.1/docs/architecture.md new file mode 100644 index 0000000..82f76a0 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/docs/architecture.md @@ -0,0 +1,29 @@ +# Architecture + +``` +shellspec command specfile execution ++-------------------------------+ +-------------------------------+ +| 1. shellspec | | The translated specfile is | +| Parsing options. | | just a plain shell script | +| | | that include the core scripts | +| 2. shellspec-runner.sh | | of shellspec. | +| Execute executor and | | | +| reporter. | | It is executed in a separate | +| | | translated | process from shellspec | +| v | specfile | command. | +| 3. shellspec-executor.sh ---|------------>| | +| Execute translator and | | Do not use external command, | +| translated specfile. | | subshell, pipe, and command | +| | | | substituion from core scripts | +| v | | as much as possibe for | +| 4. shellspec-translate.sh | | performance and portability. | +| Translate specfile. | reporting | | +| | protocol | Currently, only command-based | +| 5. shellspec-reporter.sh <----|-------------| mocks use external commands. | +| Reporting. | | | +| | | This rule applies only to | +| Can be used POSIX compliant | | core scripts. You can use | +| commands, but make as less | | external commands freely in | +| as possible. | | your test code. | ++-------------------------------+ +-------------------------------+ +``` diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/docs/cli.md b/tests/shellspec/.vendor/shellspec-0.28.1/docs/cli.md new file mode 100644 index 0000000..694626c --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/docs/cli.md @@ -0,0 +1,154 @@ +# ShellSpec CLI + +- [Initialize your project (`--init`)](#initialize-your-project---init) +- [Specify the shell to run (`--shell`)](#specify-the-shell-to-run---shell) +- [Quick execution (`--quick`, `--repair`, `--next`)](#quick-execution---quick---repair---next) +- [Parallel execution (`--jobs`)](#parallel-execution---jobs) +- [Random execution (`--random`)](#random-execution---random) +- [Fail fast (`--fail-fast`)](#fail-fast---fail-fast) +- [Trace (`--xtrace`, `--xtrace-only`)](#trace---xtrace---xtrace-only) +- [Sandbox mode (`--sandbox`)](#sandbox-mode---sandbox) +- [Ranges (`:LINENO`, `:@ID`) / Filters (`--example`) / Focus (`--focus`)](#ranges-lineno-id--filters---example--focus---focus) +- [Reporter (`--format`) / Generator (`--output`)](#reporter---format--generator---output) +- [Coverage (`--kcov`)](#coverage---kcov) +- [Profiler (`--profile`)](#profiler---profile) +- [Run tests in Docker container (`--docker`)](#run-tests-in-docker-container---docker) +- [Task runner (`--task`)](#task-runner---task) + +## Initialize your project (`--init`) + +Run `shellspec --init` initializes the current directory for ShellSpec. +It creates `.shellspec` and `spec/spec_helper.sh` + +## Specify the shell to run (`--shell`) + +Specify the shell to run with `--shell` option. +ShellSpec ignores shebang and runs the shell script in the specified shell. +The default is the shell running the `shellspec` command (usually `/bin/sh`). + +## Quick execution (`--quick`, `--repair`, `--next`) + +Quick execution is a feature for rapid development and failure fixing. + +When you run `shellspec` with `--quick` option first, Quick mode is automatically enabled. +When Quick mode enabled, The file `.shellspec-quick.log` generated on the project root directory. +If you want to disable Quick mode, delete `.shellspec-quick.log`. + +When Quick mode enabled, the results of running examples are logged to `.shellspec-quick.log` +on the project root directory (even if `--quick` option is not specified). + +Use `--quick` option is for rapid development. When `--quick` option specified, It runs examples +that not-passed (failure and temporary pending) the last time they ran. +If there are no examples that did not pass, It runs all examples. +It is designed to be added to `$HOME/.shellspec` instead of being specified each runs. + +Use `--repair` and `--next` option is for rapid failure fixing. +It runs failed examples only (not includes temporary pending). + +## Parallel execution (`--jobs`) + +You can use parallel execution for fast test with `--jobs` option. Parallel +jobs are executed per specfile. So it is necessary to separate the specfile +for effective parallel execution. + +## Random execution (`--random`) + +You can randomize the execution order to detect troubles due to the test +execution order. If `SEED` is specified, the execution order is deterministic. + +## Fail fast (`--fail-fast`) + +You can stop on the first (N times) failures with `--fail-fast` option. + +NOTE: The reporter that count the number of failures and specfile execution are processed in parallel. +Therefore, the specfile execution may precede the location where it stopped due to a failure. + +## Trace (`--xtrace`, `--xtrace-only`) + +You can trace evaluation with `--xtrace` or `--xtrace-only` option. + +If `BASH_XTRACEFD` is implemented in the shell, you can run tests and traces at the same time. +Otherwise, run tracing only. The output format can be set with the variable `PS4`. + +NOTE: `BASH_XTRACEFD` only available *bash version >= 4.1* or *busybox (ash) version >= 1.28.0*. + +## Sandbox mode (`--sandbox`) + +Force the use of the mock instead of the actual command. +This option makes the `PATH` environment variable empty (except `spec/support/bin`) and `readonly`. + +[Support commands](#support-commands) help to call the actual command in sandbox mode. + +NOTE: This is not a security feature and does not provide complete isolation. +For example, if specified with an absolute path, the actual command will be executed. +If you need strict isolation, use Docker or similar technology. + +## Ranges (`:LINENO`, `:@ID`) / Filters (`--example`) / Focus (`--focus`) + +You can run specific example(s) or example group(s) only. + +It can be specified by line number (`a_spec.sh:10:20`), example id (`a_spec.sh:@1-5:@1-6`), +example name (`--example` option), tag (`--tag` option) and focus (`--focus` option). + +To focus, prepend `f` to groups / examples in specfiles (e.g. `Describe` -> `fDescribe`, `It` -> `fIt`) +and run with `--focus` option. + +## Reporter (`--format`) / Generator (`--output`) + +You can specify one reporter (output to stdout) and multiple generators +(output to a file). Currently builtin formatters are `progress`, +`documentation`, `tap`, `junit`, `failures`, `null`, `debug`. + +NOTE: Custom formatter is supported (but not documented yet, sorry). + +## Coverage (`--kcov`) + +ShellSpec has integrated coverage feature. To use this feature [Kcov][] (v35 or later) is required. + +[Kcov]: https://github.com/SimonKagstrom/kcov + +- How to [install kcov](https://github.com/SimonKagstrom/kcov/blob/master/INSTALL.md). +- Shells that support coverage are **bash**, **zsh**, and **ksh**. +- Coverage measures only `The` evaluation and `Include`. + +By default only files whose names contain `.sh` are coverage targeted. +If you want to include other files, you need to adjust options with `--kcov-options`. + +```sh +# Default kcov (coverage) options +--kcov-options "--include-path=. --path-strip-level=1" +--kcov-options "--include-pattern=.sh" +--kcov-options "--exclude-pattern=/.shellspec,/spec/,/coverage/,/report/" + +# Example: Include script "myprog" with no extension +--kcov-options "--include-pattern=.sh,myprog" + +# Example: Only specified files/directories +--kcov-options "--include-pattern=myprog,/lib/" +``` + +[Coverage report][coverage] and `cobertura.xml` and `sonarqube.xml` files are generated under the `coverage` directory by Kcov. +You can easily integrate with [Coveralls](https://coveralls.io/), [Code Climate](https://codeclimate.com/), +[Codecov](https://codecov.io/) and more. + +[coverage]: https://circleci.com/api/v1.1/project/github/shellspec/shellspec/latest/artifacts/0/coverage/index.html + +## Profiler (`--profile`) + +When the `--profile` option is specified, the profiler is enabled and lists the slow examples. + +## Run tests in Docker container (`--docker`) + +**NOTE: This is an experimental feature and may be changed/removed in the future.** + +When the `--docker DOCKER-IMAGE` option is specified, run tests using the specified Docker image. + +If you specify only the tag that starts with `:` as DOCKER-IMAGE (e.g. `--docker :debian10`), +Use ShellSpec official runtime image (`shellspec/runtime`). +The ShellSpec official runtime image contains supported shells. + +See available tags: https://hub.docker.com/r/shellspec/runtime/tags + +## Task runner (`--task`) + +You can run the task with `--task` option. diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/docs/demo.gif b/tests/shellspec/.vendor/shellspec-0.28.1/docs/demo.gif new file mode 100644 index 0000000..943529a Binary files /dev/null and b/tests/shellspec/.vendor/shellspec-0.28.1/docs/demo.gif differ diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/docs/directory_structure.md b/tests/shellspec/.vendor/shellspec-0.28.1/docs/directory_structure.md new file mode 100644 index 0000000..bbe0709 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/docs/directory_structure.md @@ -0,0 +1,66 @@ +# Project directory structure + +## Example directory structure and options + +Separate a separate directory for each utility and test it with `test_spec.sh`. +The execution directory for testing is where the specfile is located. + +```text + +ā”œā”€ .shellspec +│ +ā”œā”€ script1/ +│ ā”œā”€ script1.sh +│ └─ test_spec.sh +│ +ā”œā”€ script2/ +│ ā”œā”€ script2.sh +│ └─ test_spec.sh +│ +ā”œā”€ spec/ +│ ā”œā”€ spec_helper.sh +│ │ : +``` + +```test +# .shellspec +--default-path "**/test_spec.sh" +--execdir @specfile +```` + +Separate a separate directory for each utility and test it with `spec/*_spec.sh`. +The test execution directory is where the script is located. + +```text + +ā”œā”€ .shellspec +│ +ā”œā”€ script1/ +│ ā”œā”€ .shellspec-basedir +│ ā”œā”€ bin/ +│ │ ā”œā”€ script1.sh +│ │ │ : +│ └─ spec/ +│ ā”œā”€ script1_spec.sh +│ │ : +│ +ā”œā”€ script2/ +│ ā”œā”€ .shellspec-basedir +│ ā”œā”€ bin/ +│ │ ā”œā”€ script2.sh +│ │ │ : +│ └─ spec/ +│ ā”œā”€ script2_spec.sh +│ │ : +│ +ā”œā”€ spec/ +│ ā”œā”€ spec_helper.sh +│ ā”œā”€ support/ +│ │ : +``` + +```test +# .shellspec +--default-path "**/spec" +--execdir @basedir/bin` +```` diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/docs/docker.md b/tests/shellspec/.vendor/shellspec-0.28.1/docs/docker.md new file mode 100644 index 0000000..ac98361 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/docs/docker.md @@ -0,0 +1,150 @@ +# How to use ShellSpec with Docker + +- [Official docker images](#official-docker-images) +- [Using ShellSpec docker image](#using-shellspec-docker-image) + - [1. Run ShellSpec and your specfiles within container](#1-run-shellspec-and-your-specfiles-within-container) + - [2. Run simple with helper script and extra hooks](#2-run-simple-with-helper-script-and-extra-hooks) + - [Hooks](#hooks) + - [.shellspec-docker/initrc](#shellspec-dockerinitrc) + - [.shellspec-docker/pre-test](#shellspec-dockerpre-test) + - [.shellspec-docker/post-test](#shellspec-dockerpost-test) + - [3. Using ShellSpec image as parent image](#3-using-shellspec-image-as-parent-image) + - [4. Include ShellSpec into another image](#4-include-shellspec-into-another-image) +- [Appendix](#appendix) + - [How to build official ShellSpec docker image yourself](#how-to-build-official-shellspec-docker-image-yourself) + +## Official docker images + +There are official images on the [Docker Hub](https://hub.docker.com/r/shellspec/shellspec). + +| Name | Linux | Included | Size | +| ------------------------------- | ------ | ------------------------- | -------------------------------------------------------------------------------------------------------------: | +| shellspec/shellspec | Alpine | busybox (ash) | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shellspec/shellspec/latest?label=) | +| shellspec/shellspec:kcov | Alpine | busybox (ash), bash, kcov | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shellspec/shellspec/kcov?label=) | +| shellspec/shellspec-debian | Debian | dash, bash | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shellspec/shellspec-debian/latest?label=) | +| shellspec/shellspec-debian:kcov | Debian | dash, bash, kcov | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shellspec/shellspec-debian/kcov?label=) | +| shellspec/shellspec-scratch | None | none (shellspec only) | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shellspec/shellspec-scratch/latest?label=) | + +- Version specified images are also available (VERSION: 0.21.0 and above) + - `shellspec/shellspec[-VARIANT]:[-kcov]` + +## Using ShellSpec docker image + +### 1. Run ShellSpec and your specfiles within container + +```sh +# Run docker command on the project root +$ docker run -it --rm -v "$PWD:/src" shellspec/shellspec + +# Display help +$ docker run -it --rm -v "$PWD:/src" shellspec/shellspec --help + +# Run with kcov (requires kcov supported image) +$ docker run -it --rm -u $(id -u):$(id -g) \ + -v "$PWD:/src" shellspec/shellspec:kcov --kcov + +# For users using Docker Desktop for Windows within WSL 1 +$ docker run -it --rm -v "$(wslpath -wa .):/src" shellspec/shellspec +``` + +### 2. Run simple with helper script and extra hooks + +Use [contrib/shellspec-docker](../contrib/shellspec-docker) helper script. + +```sh +# Specify the Docker image to use (default: shellspec/shellspec) +$ export SHELLSPEC_DOCKER=shellspec/shellspec + +# Run helper script on the project root +$ shellspec-docker + +# Display help +$ shellspec-docker --help + +# Run with kcov (requires kcov supported image) +$ shellspec-docker --kcov + +# Enter the Docker container +$ shellspec-docker - + +# Execute command with in the Docker container +$ shellspec-docker - hostname +``` + +If you want to run manually. + +```sh +$ docker run -it --rm --entrypoint=/shellspec-docker \ + -u $(id -u):$(id -g) -v "$PWD:/src" shellspec/shellspec + +# For users using Docker Desktop for Windows within WSL 1 +$ docker run -it --rm --entrypoint=/shellspec-docker \ + -u $(id -u):$(id -g) -v "$(wslpath -wa .):/src" shellspec/shellspec +``` + +#### Hooks + +##### .shellspec-docker/initrc + +This file should be a shell script. You can override [docker_run()](../contrib/shellspec-docker) to +changes options, pass environment variables, etc. + +##### .shellspec-docker/pre-test + +Invoked before execute shellspec inside of the docker container. + +##### .shellspec-docker/post-test + +Invoked after executed shellspec inside of the docker container. + +### 3. Using ShellSpec image as parent image + +Example + +```Dockerfile +# Dockerfile +FROM shellspec/shellspec +RUN apk add --no-cache add-your-required-packages +COPY ./ /src +``` + +```sh +# Build and run at your project root +$ docker build -t your-project-name . +$ docker run -it your-project-name +``` + +### 4. Include ShellSpec into another image + +Example + +```Dockerfile +# Dockerfile +FROM buildpack-deps +RUN apt-get update && apt-get install -y add-your-required-packages +COPY --from=shellspec/shellspec-scratch /opt/shellspec /opt/shellspec +ENV PATH /opt/shellspec/:$PATH +WORKDIR /src +ENTRYPOINT [ "shellspec" ] +COPY ./ /src +``` + +```sh +# Build and run at your project root +$ docker build -t your-project-name . +$ docker run -it your-project-name +``` + +## Appendix + +### How to build official ShellSpec docker image yourself + +Example + +```sh +contrib/build.sh .dockerhub/Dockerfile shellspec +contrib/build.sh .dockerhub/Dockerfile shellspec kcov +contrib/build.sh .dockerhub/Dockerfile.debian shellspec-debian +contrib/build.sh .dockerhub/Dockerfile.debian shellspec-debian kcov +contrib/build.sh .dockerhub/Dockerfile.scratch shellspec-scratch +``` diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/docs/image.png b/tests/shellspec/.vendor/shellspec-0.28.1/docs/image.png new file mode 100644 index 0000000..f076e26 Binary files /dev/null and b/tests/shellspec/.vendor/shellspec-0.28.1/docs/image.png differ diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/docs/image2.png b/tests/shellspec/.vendor/shellspec-0.28.1/docs/image2.png new file mode 100644 index 0000000..9c52663 Binary files /dev/null and b/tests/shellspec/.vendor/shellspec-0.28.1/docs/image2.png differ diff --git a/tests/shellspec/.vendor/shellspec-0.28.1/docs/references.md b/tests/shellspec/.vendor/shellspec-0.28.1/docs/references.md new file mode 100644 index 0000000..56f6412 --- /dev/null +++ b/tests/shellspec/.vendor/shellspec-0.28.1/docs/references.md @@ -0,0 +1,884 @@ +# References + +- [Basic structure](#basic-structure) + - [Example group](#example-group) + - [`ExampleGroup` / `Describe` / `Context`](#examplegroup--describe--context) + - [Example](#example) + - [`Example` / `It` / `Specify`](#example--it--specify) + - [Evaluation](#evaluation) + - [`When call`](#when-call) + - [`When run`](#when-run) + - [about calling shell function with run](#about-calling-shell-function-with-run) + - [`When run command`](#when-run-command) + - [`When run script`](#when-run-script) + - [`When run source`](#when-run-source) + - [Comparison](#comparison) + - [Expectation](#expectation) + - [`The` ... `should (not)`](#the--should-not) + - [`Assert`](#assert) + - [Subjects](#subjects) + - [`stdout` (`output`) subject](#stdout-output-subject) + - [`stderr` (`error`) subject](#stderr-error-subject) + - [`status` subject](#status-subject) + - [`line` subject](#line-subject) + - [`word` subject](#word-subject) + - [`path` / `file` / `directory` subject](#path--file--directory-subject) + - [`function` subject](#function-subject) + - [`value` subject](#value-subject) + - [`variable` subject](#variable-subject) + - [Modifiers](#modifiers) + - [`line` modifier](#line-modifier) + - [`lines` modifier](#lines-modifier) + - [`word` modifier](#word-modifier) + - [`length` modifier](#length-modifier) + - [`contents` modifier](#contents-modifier) + - [`result` modifier](#result-modifier) + - [Matchers](#matchers) + - [`satisfy` matcher](#satisfy-matcher) + - [stat matchers](#stat-matchers) + - [`be exist` matcher](#be-exist-matcher) + - [`be file` matcher](#be-file-matcher) + - [`be directory` matcher](#be-directory-matcher) + - [`be empty file` matcher](#be-empty-file-matcher) + - [`be empty directory` matcher](#be-empty-directory-matcher) + - [`be symlink` matcher](#be-symlink-matcher) + - [`be pipe` matcher](#be-pipe-matcher) + - [`be socket` matcher](#be-socket-matcher) + - [`be readable` matcher](#be-readable-matcher) + - [`be writable` matcher](#be-writable-matcher) + - [`be executable` matcher](#be-executable-matcher) + - [`be block_device` matcher](#be-block_device-matcher) + - [`be character_device` matcher](#be-character_device-matcher) + - [`has setgid` matcher](#has-setgid-matcher) + - [`has setuid` matcher](#has-setuid-matcher) + - [status matchers](#status-matchers) + - [`be success` matcher](#be-success-matcher) + - [`be failure` matcher](#be-failure-matcher) + - [string matchers](#string-matchers) + - [`equal` matcher](#equal-matcher) + - [`start with` matcher](#start-with-matcher) + - [`end with` matcher](#end-with-matcher) + - [`include` matcher](#include-matcher) + - [`match pattern` matcher](#match-pattern-matcher) + - [`successful` matcher](#successful-matcher) + - [valid matchers](#valid-matchers) + - [variable matchers](#variable-matchers) + - [`be defined` matcher](#be-defined-matcher) + - [`be undefined` matcher](#be-undefined-matcher) + - [`be present` matcher](#be-present-matcher) + - [`be blank` matcher](#be-blank-matcher) + - [`be exported` matcher](#be-exported-matcher) + - [`be readonly` matcher](#be-readonly-matcher) +- [Helper](#helper) + - [Skip / Pending](#skip--pending) + - [`Skip`](#skip) + - [`Skip if`](#skip-if) + - [`Pending`](#pending) + - [`Todo`](#todo) + - [Data](#data) + - [`Data[:raw]`](#dataraw) + - [`Data:expand`](#dataexpand) + - [`Data `](#data-function) + - [`Data ""`](#data-string) + - [`Data < ""`](#data--file) + - [Parameters](#parameters) + - [`Parameters[:block]`](#parametersblock) + - [`Parameters:value`](#parametersvalue) + - [`Parameters:matrix`](#parametersmatrix) + - [`Parameters:dynamic`](#parametersdynamic) + - [Others](#others) + - [`Include`](#include) + - [`Path` / `File` / `Dir`](#path--file--dir) + - [`Intercept`](#intercept) + - [`Set`](#set) + - [`Dump`](#dump) +- [Hooks](#hooks) + - [`Before` / `After`](#before--after) + - [`BeforeAll` / `AfterAll`](#beforeall--afterall) + - [`BeforeCall` / `AfterCall`](#beforecall--aftercall) + - [`BeforeRun` / `AfterRun`](#beforerun--afterrun) +- [Directive](#directive) + - [`%const` (`%`)](#const-) + - [`%text`](#text) + - [`%puts` (`%-`) / `%putsn` (`%=`)](#puts----putsn-) + - [%preserve](#preserve) + - [`%logger`](#logger) +- [Special environment Variables](#special-environment-variables) + +## Basic structure + +You can write a structured *Example* by using the DSL shown below: + +### Example group + +| DSL | Description | +| :------------------- | :-------------------------- | +| ExampleGroup ... End | Define an example group. | +| Describe ... End | Synonym for `ExampleGroup`. | +| Context ... End | Synonym for `ExampleGroup`. | + +#### `ExampleGroup` / `Describe` / `Context` + +Example groups are nestable. + +### Example + +| DSL | Description | +| :-------------- | :--------------------- | +| Example ... End | Define an example. | +| It ... End | Synonym for `Example`. | +| Specify ... End | Synonym for `Example`. | + +#### `Example` / `It` / `Specify` + +### Evaluation + +The line beginning with `When` is the evaluation. + +| Evaluation | Description | +| :--------------- | :------------------------------------------------------------------- | +| When call | Call shell function without subshell. | +| When run | Run shell function or external command within a subshell. | +| When run command | Run external command (including non-shell scripts). | +| When run script | Run shell script by new process of the current shell. | +| When run source | Run shell script in the current shell by `.` command (aka `source`). | + +#### `When call` + +```sh +When call [ARGUMENTS...] +``` + +This is primarily designed for shell function calls. It is the recommended evaluation as a unit test. +It does not use a subshell, therefore it is the fastest evaluation variant and you can assert variables. + +#### `When run` + +```sh +When run [ARGUMENTS...] +``` + +This is primarily designed for external command calls. +The external command does not have to be a shell script. +Even shell scripts are executed as external commands according to the shebang, so they are not covered by the coverage. + +##### about calling shell function with run + +If a shell function is specified, it will be executed in a subshell. The slight advantage of +executing shell functions with `run` is that you can trap errors with `set -e`. +Unlike `call`, it does not cause an error, so you can assert the exit status. + +Also, because of the execution in the subshell, the variables which change values in the function are restored once `run` finishes. +This is often a disadvantage, but tests of ShellSpec itself intentionally use `run` +because changing internal variables confuses ShellSpec's behavior. + +If you want to assert variables with `run`, use the `%preserve` directive in function called by `AfterRun` hook. +It can preserve variables even if `run` exits the subshell. + +#### `When run command` + +```sh +When run command [ARGUMENTS...] +``` + +Run an external command explicitly. +The external command does not have to be a shell script. +Even shell scripts are executed as external commands according to the shebang, so they are not covered by the coverage. + +#### `When run script` + +```sh +When run script