 +
 +def buildifier_test(**kwargs):
 +    """
-+    Wrapper for the _buildifier_test rule. Adds tags to disable sandboxing.
++    Wrapper for the _buildifier_test rule. Optionally disables sandboxing and caching.
 +
 +    Args:
 +      **kwargs: all parameters for _buildifier_test
 +    """
-+    if kwargs.get("no-sandbox", False):
++    if kwargs.get("no_sandbox", False):
 +        tags = kwargs.get("tags", [])
++
 +        # Note: the "external" tag is a workaround for bazelbuild#15516.
 +        for t in ["no-sandbox", "no-cache", "external"]:
 +            if t not in tags:

             ),
         })
 
@@ -147,15 +152,24 @@ def buildifier_impl_factory(ctx, test_rule = False):
         args.append("-add_tables=%s" % ctx.file.add_tables.path)
 
     exclude_patterns_str = ""

+        kwargs["tags"] = tags
+    _buildifier_test(**kwargs)
diff --git a/buildifier/internal/factory.bzl b/buildifier/internal/factory.bzl
index 779c789..34a4997 100644
--- a/buildifier/internal/factory.bzl
+++ b/buildifier/internal/factory.bzl
@@ -46,6 +46,10 @@ def buildifier_attr_factory(test_rule = False):
