# zopen build configuration for zash.
#
# The source tree is the port: ZOPEN_TYPE=LOCAL builds this checkout instead
# of downloading a release, so `zopen build` and `make` see the same commit.
ZASH_VERSION="0.5.0"

export ZOPEN_PROJECT_NAME="zash"
export ZOPEN_BUILD_LINE="DEV"
export ZOPEN_TYPE="LOCAL"
# For a public standalone zopen port (instead of ZOPEN_TYPE=LOCAL):
# export ZOPEN_STABLE_URL="https://github.com/skurtz97/zash.git"
# export ZOPEN_STABLE_TAG="v0.5.0-beta"
# export ZOPEN_DEV_URL="https://github.com/skurtz97/zash.git"
export ZOPEN_RUNTIME_DEPS=""
# Build and test dependencies only (not runtime): tests/zos/tagging.sh uses
# gzip.  Do not add coreutils here -- its altbin puts ASCII `cat` ahead of
# /bin/cat, which changes the EBCDIC external-writer test in zos/tagging.
export ZOPEN_DEV_DEPS="make gzip"
export ZOPEN_STABLE_DEPS="make gzip"
export ZOPEN_CATEGORIES="shell"
export ZOPEN_COMP="CLANG"
# zash uses only POSIX/POSIX-adjacent libc calls; zoslib would add a runtime
# dependency the package does not declare.
export ZOPEN_DONT_ADD_ZOSLIB_DEP="1"

# GNU make, no autotools.
export ZOPEN_CONFIGURE="skip"
export ZOPEN_CHECK="make"
export ZOPEN_CHECK_OPTS="check"
# Without these the check runs as a background job: POSIX shells ignore SIGINT
# in async children, so tests that send themselves INT fail.
export ZOPEN_CHECK_TIMEOUT="0"
# Keep zopen's injected CC/CFLAGS out of the test environment; the Makefile
# picks its own compiler, and the long lines trip IBM grep in posix/vars.
export ZOPEN_CHECK_MINIMAL="1"

# The Makefile uses PREFIX, not the autotools prefix variable.
export ZOPEN_INSTALL_OPTS="install PREFIX=\$ZOPEN_INSTALL_DIR"

zopen_check_results()
{
  chk="$1/$2_check.log"

  # tests/run.sh prints one summary per pass; z/OS make check runs two
  # (ASCII and EBCDIC).  No summary means the suite did not run.
  awk '
    /^zash tests: / {
      passed += $3
      skipped += $5
      failed += $7
      seen = 1
    }
    END {
      total = passed + skipped + failed
      if (!seen || total == 0)
        failed = 1
      print "actualFailures:" failed + 0
      print "totalTests:" (total ? total : 1)
      print "expectedFailures:0"
    }
  ' "$chk"
}

zopen_get_version()
{
  echo "$ZASH_VERSION"
}
