New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add some initial shell parsing tests. #51649
Conversation
I have absolutely no idea if this is a good approach or not, so please feel free to suggest alternate/better ways to achieve this. /assign @ixdy |
you probably want something like this to ensure fail on non-zero exit:
|
4e4c2d7
to
ef03933
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
basically LG, with a few minor nits/comments.
cluster/common_test.sh
Outdated
set -o pipefail | ||
|
||
# Setup test environment | ||
source hack/test-shlib.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might want to base these off ${KUBE_ROOT}
so that you can call this script from somewhere besides ${KUBE_ROOT}
?
cluster/BUILD
Outdated
@@ -46,3 +46,33 @@ pkg_tar( | |||
"//cluster/saltbase:salt-manifests", | |||
], | |||
) | |||
|
|||
sh_test( | |||
name = "common", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may want to suffix all of these with _test
. otherwise you have a weird target named //cluster:common
which is actually a test, for example.
hack/test-shlib.sh
Outdated
set -o pipefail | ||
|
||
# HOME is, by default, not set. Give it a bogus value. | ||
HOME=${PWD} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use a tmp dir instead?
hack/BUILD
Outdated
@@ -14,6 +14,11 @@ filegroup( | |||
visibility = ["//visibility:private"], | |||
) | |||
|
|||
sh_library( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add testonly = True
?
cluster/BUILD
Outdated
name = "common", | ||
srcs = ["common_test.sh"], | ||
data = [ | ||
"all-srcs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
":all-srcs"
(add the leading :
) is preferred for referencing rules in the same package.
an alternative to having --- a/build/root/.bazelrc
+++ b/build/root/.bazelrc
@@ -11,3 +11,6 @@ build --sandbox_tmpfs_path=/tmp
# Ensure that Bazel never runs as root, which can cause unit tests to fail.
# This flag requires Bazel 0.5.0+
build --sandbox_fake_username
+
+# Set HOME in the test environment to something bogus
+test --test_env HOME=/tmp/bazel-fake-home Another alternative is having I'm not sure whether either of these is better than what you're already doing. |
I don't like the bazel flag option, because it requires that flag or the test signals a failure. It also seems a little too broad for me to make it (because it changes the environment on all tests), so I'd rather not. The other idea, fixing cluster/common.sh, is easy enough. I'll just use |
@ixdy I think I got all the style fixes and sidestepped most of the other issues by just executing the files directly as tests. PTAL |
cluster/BUILD
Outdated
srcs = ["common.sh"], | ||
data = [ | ||
":all-srcs", | ||
"//hack/lib:all-srcs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we actually have a sh_library
in hack/lib
, so //hack/lib
is probably a more correct dep here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
lgtm other than small suggestion (x3) |
Oh, wait. Did you mean |
maybe squash your commits? |
actually, that's false. buildifier (i.e. update-bazel.sh) will simplify |
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ixdy, mml, roberthbailey Associated issue: 51642 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test all |
/retest Review the full test history for this PR. |
1 similar comment
/retest Review the full test history for this PR. |
/retest #51692 |
/retest |
These just test to see if there is a bash syntax error in these shell libraries. For kubernetes#51642
Automatic merge from submit-queue (batch tested with PRs 49971, 51357, 51616, 51649, 51372) |
Cleanup after kubernetes#51649 Bug: kubernetes#51642
Automatic merge from submit-queue (batch tested with PRs 50579, 50875, 51797, 51807, 51803) Depend on //cluster/lib instead of :all-srcs. Cleanup after kubernetes#51649 Bug: kubernetes#51642 ```release-note NONE ``` /assign @ixdy /assign @roberthbailey
These just test to see if there is a bash syntax error in these shell
libraries.
For #51642