Created
July 11, 2018 13:47
-
-
Save nikhedonia/3e804fe2916d3a8033a0909428b469ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_tree(name, path): | |
genrule( | |
name = name, | |
out = ".", | |
srcs = [path], | |
cmd = "cp -r $SRCS/* $OUT" | |
) | |
return ":"+name | |
def sh_cxx_test( | |
name, | |
tree = False, | |
**kwargs): | |
target = name | |
binTarget = "bin-" + name | |
shTarget = "sh-" + name | |
runTarget = "run-" + name | |
cxx_binary( | |
binTarget, | |
**kwargs | |
) | |
genrule( | |
name = runTarget, | |
out = "run.sh", | |
srcs = [], | |
cmd = "&&".join([ | |
"echo '%s' > $OUT" % "\n".join([ | |
"#!/bin/bash", | |
"cd $(location %s)" % tree if tree else "cd $BUCK_PROJECT_ROOT/__default__/gen", | |
"exec $(location :%s)" % binTarget | |
]), | |
"chmod +x $OUT" | |
]) | |
) | |
sh_binary( | |
name = shTarget, | |
main = ":run-"+target, | |
resources = [] | |
) | |
sh_test( | |
name = target, | |
test = ":sh-"+target, | |
visibility = ["PUBLIC"], | |
) | |
return ":"+target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment