Skip to content

Instantly share code, notes, and snippets.

@jayconrod
Last active August 17, 2018 17:15
Show Gist options
  • Save jayconrod/d6c7006199fcc79b39b3534bfcc84f21 to your computer and use it in GitHub Desktop.
Save jayconrod/d6c7006199fcc79b39b3534bfcc84f21 to your computer and use it in GitHub Desktop.
load("//:def.bzl", "mkdata")
mkdata(name = "mkdata")
sh_test(
name = "mkdata_test",
srcs = ["mkdata_test.sh"],
args = ["$(location :mkdata)"],
data = [":mkdata"],
)
def _mkdata_impl(ctx):
out = ctx.actions.declare_directory(ctx.label.name + ".d")
script = "mkdir -p {out}; touch {out}/file; ln -s file {out}/link".format(out = out.path)
ctx.actions.run_shell(
outputs = [out],
command = script,
)
runfiles = ctx.runfiles(files = [out])
return [DefaultInfo(
files = depset([out]),
runfiles = runfiles,
)]
mkdata = rule(
_mkdata_impl,
)
#!/bin/bash
set -euo pipefail
test_dir="$1"
cd "$test_dir"
ls -l | cut -f1,9 -d' ' >&2
if [ ! -f file -o -L file ]; then
echo "'file' is not a regular file" >&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment