From 51059a81579362470e9323587a44dc1e50ab3426 Mon Sep 17 00:00:00 2001 From: Chris Parsons Date: Tue, 7 May 2019 16:03:28 -0400 Subject: [PATCH] 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 --- rules/diff_test.bzl | 3 +++ tests/diff_test/BUILD | 1 + tests/diff_test/diff_test_tests.sh | 1 + tests/unittest_tests.bzl | 14 ++++++++++++++ 4 files changed, 19 insertions(+) diff --git a/rules/diff_test.bzl b/rules/diff_test.bzl index 6fb3581..4482e6c 100644 --- a/rules/diff_test.bzl +++ b/rules/diff_test.bzl @@ -86,6 +86,9 @@ if [[ -d "${{RUNFILES_DIR:-/dev/null}}" && "${{RUNFILES_MANIFEST_ONLY:-}}" != 1 elif [[ -f "${{RUNFILES_MANIFEST_FILE:-/dev/null}}" ]]; then RF1="$(grep -F -m1 "$F1 " "$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 echo >&2 "ERROR: could not find \"{file1}\" and \"{file2}\"" exit 1 diff --git a/tests/diff_test/BUILD b/tests/diff_test/BUILD index bd0aacd..afed401 100644 --- a/tests/diff_test/BUILD +++ b/tests/diff_test/BUILD @@ -14,6 +14,7 @@ sh_test( "//tests:unittest.bash", ], deps = ["@bazel_tools//tools/bash/runfiles"], + tags = ["local"], ) diff_test( diff --git a/tests/diff_test/diff_test_tests.sh b/tests/diff_test/diff_test_tests.sh index aa43307..1cab39b 100755 --- a/tests/diff_test/diff_test_tests.sh +++ b/tests/diff_test/diff_test_tests.sh @@ -202,4 +202,5 @@ function test_from_ext_repo_without_legacy_external_runfiles() { assert_from_ext_repo "--nolegacy_external_runfiles" "${FUNCNAME[0]}" } +cd "$TEST_TMPDIR" run_suite "diff_test_tests test suite" diff --git a/tests/unittest_tests.bzl b/tests/unittest_tests.bzl index 01ea4de..e25e4da 100644 --- a/tests/unittest_tests.bzl +++ b/tests/unittest_tests.bzl @@ -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.""" load("//lib:unittest.bzl", "analysistest", "asserts", "unittest")