Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Brings two rules:

- `diff_file_test`
- `diff_directory_test`

Uses `diff` from `ape` so is hermetic and consistent across operating
systems, even Windows.

Negates the non-hermetic-ness of `bazel_skylib#diff_test` that uses
`diff` from the system.

A new module for `diff` related rules makes sense, in the future we may
want to enable a three file comparison rule with `diff3`, byte-by-byte
comparison with `cmp` or other possible differencing rules.

This module also exposes the hermetic toolchains for use in other
modules:

- `@rules_diff//diff/toolchain/diff:type`
- `@rules_diff//diff/toolchain/diff3:type`
- `@rules_diff//diff/toolchain/sdiff:type`
- `@rules_diff//diff/toolchain/cmp:type`

At this time, we're in alpha as the rules need to be fleshed out and
tested in more situations. For example, we are not fully testing with
all possible combinations of runfiles.
  • Loading branch information
mattyclarkson authored Feb 21, 2024
1 parent 20a5df7 commit fa84fff
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
33 changes: 33 additions & 0 deletions modules/rules_diff/1.0.0-alpha.3/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module(
name = "rules_diff",
version = "1.0.0-alpha.3",
bazel_compatibility = [
">=7.0.0",
],
compatibility_level = 1,
)

bazel_dep(name = "toolchain_utils", version = "1.0.0-beta.1")
bazel_dep(name = "ape", version = "1.0.0-alpha.3")

export = use_extension("@toolchain_utils//toolchain/export:defs.bzl", "toolchain_export")

resolved = use_repo_rule("@toolchain_utils//toolchain/resolved:defs.bzl", "toolchain_resolved")

[
(
use_repo(export, "ape-{}".format(tool)),
export.symlink(
name = tool,
target = "@ape-{}".format(tool),
),
use_repo(export, tool),
resolved(
name = "resolved-{}".format(tool),
toolchain_type = "//diff/toolchain/{}:type".format(tool),
),
)
for tool in ("diff", "diff3", "sdiff", "cmp")
]

register_toolchains("//diff/toolchain/...")
20 changes: 20 additions & 0 deletions modules/rules_diff/1.0.0-alpha.3/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
bcr_test_module:
module_path: e2e
matrix:
bazel:
- 7.x
platform:
- debian10
- ubuntu2004
- macos
# TODO: we need `ape` to support `macos_arm64`
# - macos_arm64
# TODO: enable this once the `gitlab.arm.com` certificate is validated on BuildKite runner
# - windows
tasks:
run_tests:
name: Run end-to-end Tests
bazel: ${{ bazel }}
platform: ${{ platform }}
test_targets:
- "//..."
5 changes: 5 additions & 0 deletions modules/rules_diff/1.0.0-alpha.3/source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"url": "https://gitlab.arm.com/bazel/rules_diff/-/releases/v1.0.0-alpha.3/downloads/src.tar.gz",
"integrity": "sha512-g8eVWXWcRpkiWjxs54Zua9tjdX/mTZV2yWslBrFqftvHDaCLxJQ1uXb4fRqC3pM1XKFouelMkviYZSMJaVAT8w==",
"strip_prefix": "rules_diff-v1.0.0-alpha.3"
}
16 changes: 16 additions & 0 deletions modules/rules_diff/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"homepage": "https://gitlab.arm.com/bazel/rules_diff",
"repository": [
"https://gitlab.arm.com/bazel/rules_diff"
],
"versions":[
"1.0.0-alpha.3"
],
"maintainers": [
{
"email": "[email protected]",
"github": "mattyclarkson",
"name": "Matt Clarkson"
}
]
}

0 comments on commit fa84fff

Please sign in to comment.