daml/compiler/damlc/tests/util.bzl

39 lines
1.0 KiB
Python
Raw Normal View History

# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2019-04-04 11:33:38 +03:00
# SPDX-License-Identifier: Apache-2.0
load("//bazel_tools:haskell.bzl", "da_haskell_test")
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. * https://github.com/bazelbuild/bazel/commit/a948eb7255b8418f0bba1c819a58972066577d6f * 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 10:46:04 +03:00
load("//bazel_tools/sh:sh.bzl", "sh_inline_test")
2019-04-04 11:33:38 +03:00
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. * https://github.com/bazelbuild/bazel/commit/a948eb7255b8418f0bba1c819a58972066577d6f * 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 10:46:04 +03:00
def damlc_compile_test(
name,
srcs,
main,
damlc = "//compiler/damlc",
stack_limit = "",
heap_limit = "",
**kwargs):
stack_opt = "-K" + stack_limit if stack_limit else ""
heap_opt = "-M" + heap_limit if heap_limit else ""
sh_inline_test(
name = name,
data = [damlc, main] + srcs,
cmd = """\
DAMLC=$$(canonicalize_rlocation $(rootpath {damlc}))
MAIN=$$(canonicalize_rlocation $(rootpath {main}))
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. * https://github.com/bazelbuild/bazel/commit/a948eb7255b8418f0bba1c819a58972066577d6f * 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 10:46:04 +03:00
TMP=$$(mktemp -d)
function cleanup() {{
rm -rf "$$TMP"
}}
trap cleanup EXIT
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. * https://github.com/bazelbuild/bazel/commit/a948eb7255b8418f0bba1c819a58972066577d6f * 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 10:46:04 +03:00
$$DAMLC compile $$MAIN -o $$TMP/out +RTS -s {stack_opt} {heap_opt}
""".format(
damlc = damlc,
main = main,
stack_opt = stack_opt,
heap_opt = heap_opt,
),
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. * https://github.com/bazelbuild/bazel/commit/a948eb7255b8418f0bba1c819a58972066577d6f * 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 10:46:04 +03:00
**kwargs
)