daml/bazel_tools/sh/test.sh.tpl
Andreas Herrmann 4b1438276c
Update Bazel 2.1.0 --> 3.3.1 (#6761)
* Upgrade nixpkgs revision

* Remove unused minio

It used to be used as a gateway to push the Nix cache to GCS, but has
since been replaced by nix-store-gcs-proxy.

* Update Bazel on Windows

changelog_begin
changelog_end

* Fix hlint warnings

The nixpkgs update implied an hlint update which enabled new warnings.

* Fix "Error applying patch"

Since Bazel 2.2.0 the order of generating `WORKSPACE` and `BUILD` files
and applying patches has been reversed. The allows users to define
patches to these files that will not be immediately overwritten.
However, it also means that patches on another repository's original
`WORKSPACE` file will likely become invalid.

* a948eb7255
* https://github.com/bazelbuild/bazel/issues/10681

Hint: If you're generating a patch with `git` then you can use the
following command to exclude the `WORKSPACE` file.

```
git diff ':(exclude)WORKSPACE'
```

* Update rules_nixpkgs

* nixpkgs location expansion escaping

* Drop --noincompatible_windows_native_test_wrapper

* client_server_test using sh_inline_test

client_server_test used to produce an executable shell script in form of
a text file output. However, since the removal of
`--noincompatible_windows_native_test_wrapper` this no longer works on
Windows since `.sh` files are not directly executable on Windows.

This change fixes the issue by producing the script file in a dedicated
rule and then wrapping it in a `sh_test` rule which also works on
Windows.

* daml_test using sh_inline_test

* daml_doc_test using sh_inline_test

* _daml_validate_test using sh_inline_test

* damlc_compile_test using sh_inline_test

* client_server_test find .exe on Windows

* Bump Windows cache for Bazel update

Remove `clean --expunge` after merge.

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-07-23 09:46:04 +02:00

58 lines
2.4 KiB
Smarty
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# Copy-pasted from the Bazel Bash runfiles library v2.
set +e
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v2 ---
canonicalize_rlocation() {
# Note (MK): This is a fun one: Lets say $TEST_WORKSPACE is "compatibility"
# and the argument points to a target from an external workspace, e.g.,
# @daml-sdk-0.0.0//:daml. Then the short path will point to
# ../daml-sdk-0.0.0/daml. Putting things together we end up with
# compatibility/../daml-sdk-0.0.0/daml. On Linux and MacOS this works
# just fine. However, on windows we need to normalize the path
# or rlocation will fail to find the path in the manifest file.
rlocation $(realpath -L -s -m --relative-to=$PWD $TEST_WORKSPACE/$1)
}
get_exe() {
# Usage: get_exe FILE...
#
# On Windows: Return the FILE ending on .exe or the first argument.
# On Unix: Return the first argument.
# Note (AH): Bazel `sh_binary` targets produce multiple outputs.
# On Unix `script`, and `script.sh`.
# On Windows `script`, `script.exe`, and `script.sh`.
# Assuming `srcs = ["script.sh"]`.
# This is an issue for macros like `client_server_test` which would like
# to determine the path to executables such as.
# `$$(canonicalize_rlocation $(rootpath {client}))`.
# For a `sh_binary` generated `{client}` this fails since `$(rootpath )` is
# not applicable to a target with multiple outputs and we have to use
# `$(rootpaths )` instead. This happens to work on Unix because the first
# item returned by `$(rootpaths )` is correctly executable. However, on
# Windows the required `.exe` wrapper is only the second item returned by
# `$(rootpaths )` and consequently the obtained `$client` path cannot be
# executed on Windows.
# See https://github.com/bazelbuild/bazel/issues/11820.
if [[ %os% = windows ]]; then
for arg in "$@"; do
if [[ $arg = *.exe ]]; then
echo "$arg"
return
fi
done
echo "$1"
else
echo "$1"
fi
}
set -e
%cmd%
# vim: ft=sh