Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Set size to a default value as well as timeout. #839

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/diff_test.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions lib/private/diff_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ The rule uses a Bash command (diff) on Linux/macOS/non-Windows, and a cmd.exe
command (fc.exe) on Windows (no Bash is required).
"""

load("//lib:utils.bzl", "default_timeout")
load(":directory_path.bzl", "DirectoryPathInfo")

def _runfiles_path(f):
Expand Down Expand Up @@ -116,16 +115,15 @@ def diff_test(name, file1, file2, size = None, timeout = None, **kwargs):
name: The name of the test rule.
file1: Label of the file to compare to <code>file2</code>.
file2: Label of the file to compare to <code>file1</code>.
size: standard attribute for tests
size: standard attribute for tests. Defaults to "small" if unspecified.
timeout: standard attribute for tests. Defaults to "short" if both timeout and size are unspecified.
**kwargs: The <a href="https://docs.bazel.build/versions/main/be/common-definitions.html#common-attributes-tests">common attributes for tests</a>.
"""

_diff_test(
name = name,
file1 = file1,
file2 = file2,
size = size,
timeout = default_timeout(size, timeout),
size = size or "small",
alexeagle marked this conversation as resolved.
Show resolved Hide resolved
timeout = timeout,
**kwargs
)
1 change: 1 addition & 0 deletions lib/private/write_source_file.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ To create an update *only* this file, run:
message = message,
visibility = kwargs.get("visibility"),
tags = kwargs.get("tags"),
size = "small",
)
else:
if suggested_update_target == None:
Expand Down
5 changes: 2 additions & 3 deletions lib/testing.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("//lib:diff_test.bzl", "diff_test")
load("//lib:jq.bzl", "jq")
load("//lib:params_file.bzl", "params_file")
load("//lib:utils.bzl", "default_timeout")

def assert_contains(name, actual, expected, size = None, timeout = None, **kwargs):
"""Generates a test target which fails if the file doesn't contain the string.
Expand Down Expand Up @@ -44,8 +43,8 @@ def assert_contains(name, actual, expected, size = None, timeout = None, **kwarg
name = name,
srcs = [test_sh],
args = ["$(rootpath %s)" % expected_file, "$(rootpath %s)" % actual],
size = size,
timeout = default_timeout(size, timeout),
size = size or "small",
timeout = timeout,
data = [actual, expected_file],
**kwargs
)
Expand Down