-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathaudit.bxl
More file actions
59 lines (48 loc) · 1.86 KB
/
Copy pathaudit.bxl
File metadata and controls
59 lines (48 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is dual-licensed under either the MIT license found in the
# LICENSE-MIT file in the root directory of this source tree or the Apache
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree. You may select, at your option, one of the
# above-listed licenses.
def _audit_output_action_exists_impl(ctx):
label = "root//:with_output"
target = ctx.configured_targets(label)
build_result = ctx.build(target)
artifact = build_result.values()[0].artifacts()[0]
buck_out = get_path_without_materialization(artifact, ctx)
action = ctx.audit().output(buck_out)
asserts.equals(action.owner(), target.label)
asserts.equals(action.outputs()[0].basename, "with_output.txt")
audit_output_action_exists = bxl_main(
impl = _audit_output_action_exists_impl,
cli_args = {
},
)
def _audit_content_based_output_action_exists_impl(ctx):
output = ctx.audit().output(ctx.cli_args.path)
asserts.true(isinstance(output, TargetLabel))
asserts.equals(str(output), ctx.cli_args.label)
audit_content_based_output_action_exists = bxl_main(
impl = _audit_content_based_output_action_exists_impl,
cli_args = {
"label": cli_args.string(),
"path": cli_args.string(),
},
)
def _audit_output_config_not_match_impl(ctx):
buck_out = "buck-out/v2/gen/root/aaaabbbbccccdddd/__with_output__/foo.txt"
output = ctx.audit().output(buck_out, "root//:someplat")
asserts.equals(str(output), "root//:with_output")
audit_output_config_not_match = bxl_main(
impl = _audit_output_config_not_match_impl,
cli_args = {
},
)
def _audit_output_invalid_path_impl(ctx):
ctx.audit().output("buck-out/blah/blah")
audit_output_invalid_path = bxl_main(
impl = _audit_output_invalid_path_impl,
cli_args = {
},
)