#!/bin/bash

# Fail on any error.
set -e
# Display commands being run.
set -x

cd git/SwiftShader

# Validate commit message
git log -1 --pretty=%B | grep -E '^Bug:|^Issue:|^Regres:'

if [ $? -ne 0 ]
then
  echo "Commit message must have a Bug: line."
  exit 0
fi

# Download all submodules
git submodule update --init

mkdir -p build && cd build

if [[ -z "${REACTOR_BACKEND}" ]]; then
  REACTOR_BACKEND="LLVM"
fi

cmake .. "-DREACTOR_BACKEND=${REACTOR_BACKEND}" "-DREACTOR_VERIFY_LLVM_IR=1"
make --jobs=$(nproc)

# Run unit tests

cd .. # Some tests must be run from project root

build/ReactorUnitTests
build/gles-unittests

if [ "${REACTOR_BACKEND}" != "Subzero" ]; then
  build/vk-unittests # Currently vulkan does not work with Subzero.
fi
#!/bin/bash

cd git/SwiftShader

# Validate commit message
git log -1 --pretty=%B | grep -E '^Bug:|^Issue:|^Regres:'

if [ $? -ne 0 ]
then
  echo "error: Git commit message must have a Bug: line."
  exit 1
fi

# Fail on any error.
set -e
# Display commands being run.
set -x

# Download all submodules
git submodule update --init

mkdir -p build && cd build

if [[ -z "${REACTOR_BACKEND}" ]]; then
  REACTOR_BACKEND="LLVM"
fi

cmake .. "-DREACTOR_BACKEND=${REACTOR_BACKEND}" "-DREACTOR_VERIFY_LLVM_IR=1"
make --jobs=$(nproc)

# Run unit tests

cd .. # Some tests must be run from project root

build/ReactorUnitTests
build/gles-unittests

if [ "${REACTOR_BACKEND}" != "Subzero" ]; then
  build/vk-unittests # Currently vulkan does not work with Subzero.
fi
Fix commit message validation reporting
Fix commit message validation reporting

"set -e" was aborting the script after grep doesn't find the Bug line,
and "set -x" makes things overly verbose. So perform the validation
before these options are set.

Also return 1 instead of 0 on failure.

Bug: b/141892461
Change-Id: Ica0364ff49383b47cf37b3a02d6b03e55d8d88ad
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/37008
Kokoro-Presubmit: kokoro <2ac7b1f3fa578934c95181d4272be0d3bca00121@google.com>
Tested-by: Nicolas Capens <51edc787c30f24c4904e8ffbb5523c3a9f7a451d@google.com>
Reviewed-by: Antonio Maiorano <86d87a6550afb6b07035c9743fa181900589f7e0@google.com>
