Fix a number of misc issues to allow google usage of bazel-skylib (#146)

* Fix a number of misc issues to allow google usage of bazel-skylib

1. Missing copyright header
2. Shell test fixes to use TEST_TMPDIR to have write access to directories
3. diff_test fix to use TEST_SRCDIR

* added a comment as to why diff_test_tests is local

* ran buildifier
This commit is contained in:
c-parsons 2019-05-07 16:25:43 -04:00 committed by GitHub
parent 67215655bf
commit 84a12d1084
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 0 deletions

View File

@ -86,6 +86,9 @@ if [[ -d "${{RUNFILES_DIR:-/dev/null}}" && "${{RUNFILES_MANIFEST_ONLY:-}}" != 1
elif [[ -f "${{RUNFILES_MANIFEST_FILE:-/dev/null}}" ]]; then elif [[ -f "${{RUNFILES_MANIFEST_FILE:-/dev/null}}" ]]; then
RF1="$(grep -F -m1 "$F1 " "$RUNFILES_MANIFEST_FILE" | sed 's/^[^ ]* //')" RF1="$(grep -F -m1 "$F1 " "$RUNFILES_MANIFEST_FILE" | sed 's/^[^ ]* //')"
RF2="$(grep -F -m1 "$F2 " "$RUNFILES_MANIFEST_FILE" | sed 's/^[^ ]* //')" RF2="$(grep -F -m1 "$F2 " "$RUNFILES_MANIFEST_FILE" | sed 's/^[^ ]* //')"
elif [[ -f "$TEST_SRCDIR/$F1" && -f "$TEST_SRCDIR/$F2" ]]; then
RF1="$TEST_SRCDIR/$F1"
RF2="$TEST_SRCDIR/$F2"
else else
echo >&2 "ERROR: could not find \"{file1}\" and \"{file2}\"" echo >&2 "ERROR: could not find \"{file1}\" and \"{file2}\""
exit 1 exit 1

View File

@ -13,6 +13,8 @@ sh_test(
"//rules:diff_test", "//rules:diff_test",
"//tests:unittest.bash", "//tests:unittest.bash",
], ],
# Test marked local because it uses bazel.
tags = ["local"],
deps = ["@bazel_tools//tools/bash/runfiles"], deps = ["@bazel_tools//tools/bash/runfiles"],
) )

View File

@ -202,4 +202,5 @@ function test_from_ext_repo_without_legacy_external_runfiles() {
assert_from_ext_repo "--nolegacy_external_runfiles" "${FUNCNAME[0]}" assert_from_ext_repo "--nolegacy_external_runfiles" "${FUNCNAME[0]}"
} }
cd "$TEST_TMPDIR"
run_suite "diff_test_tests test suite" run_suite "diff_test_tests test suite"

View File

@ -1,3 +1,17 @@
# Copyright 2019 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Unit tests for unittest.bzl.""" """Unit tests for unittest.bzl."""
load("//lib:unittest.bzl", "analysistest", "asserts", "unittest") load("//lib:unittest.bzl", "analysistest", "asserts", "unittest")