forked from tweag/rules_nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request tweag#35 from tweag/expose-all-files
Improve documentation of `build_file` and add tests
- Loading branch information
Showing
5 changed files
with
130 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,49 @@ | ||
package(default_testonly = 1) | ||
|
||
[sh_test( | ||
name= "run-{0}".format(test), | ||
srcs = ["test_bin.sh"], | ||
args=["$(location @{0}//:bin)".format(test)], | ||
data = ["@{0}//:bin".format(test)], | ||
timeout = "short", | ||
) for test in [ | ||
"hello", | ||
"expr-test", | ||
"attribute-test", | ||
"expr-attribute-test", | ||
"nix-file-test", | ||
"nix-file-deps-test", | ||
"nixpkgs-git-repository-test", | ||
]] | ||
[ | ||
# All of these tests use the "hello" binary to see | ||
# whether different invocations of `nixpkgs_package` | ||
# produce a valid bazel repository. | ||
sh_test( | ||
name= "run-{0}".format(test), | ||
srcs = ["test_bin.sh"], | ||
args=["$(location @{0}//:bin)".format(test)], | ||
data = ["@{0}//:bin".format(test)], | ||
timeout = "short", | ||
) for test in [ | ||
"hello", | ||
"expr-test", | ||
"attribute-test", | ||
"expr-attribute-test", | ||
"nix-file-test", | ||
"nix-file-deps-test", | ||
"nixpkgs-git-repository-test", | ||
] | ||
] \ | ||
+ \ | ||
[ | ||
# These tests use the nix package generated by ./output.nix | ||
|
||
# Checks whether the `:include` filegroup of `nixpkgs_package` | ||
# repositories works as intended | ||
# (that the expected number of files are inside the target) | ||
sh_test( | ||
name = "run-test-include", | ||
srcs = ["test_output.sh"], | ||
data = ["@output-filegroup-test//:include"], | ||
args = ["2", "$(locations @output-filegroup-test//:include)"], | ||
timeout = "short", | ||
), | ||
|
||
# Checks whether specifying a manual filegroup in the | ||
# `nixpkgs_package` BUILD file works as well. | ||
sh_test( | ||
name = "run-test-manual-filegroup", | ||
srcs = ["test_output.sh"], | ||
data = ["@output-filegroup-manual-test//:manual-filegroup"], | ||
args = [ | ||
"3", | ||
"$(locations @output-filegroup-manual-test//:manual-filegroup)"], | ||
timeout = "short", | ||
) | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
with import <nixpkgs> {}; | ||
|
||
runCommand "some-output" { | ||
preferLocalBuild = true; | ||
allowSubstitutes = false; | ||
} '' | ||
mkdir -p $out/{bin,include/mylib} | ||
touch $out/hi-i-exist | ||
touch $out/hi-i-exist-too | ||
touch $out/bin/im-a-binary | ||
touch $out/include/mylib/im-a-header.h | ||
touch $out/include/mylib/im-also-a-header.h | ||
'' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
# first param is the expected number of files given by `locations` | ||
expected_length="$1" | ||
|
||
# rest of the arguments are files | ||
shift | ||
no_of_files=$# | ||
|
||
if [ "$no_of_files" -ne "$expected_length" ]; then | ||
echo "Should have received $expected_length files, but got $no_of_files:" | ||
for f in "$@"; do | ||
echo "$f" | ||
done | ||
exit 1 | ||
fi |