Skip to content

Commit

Permalink
test wrapper: add empty implementation
Browse files Browse the repository at this point in the history
Add empty implementation of the Windows-native
test wrapper, add it to the embedded tools, and
depend on it from test rules.

See bazelbuild#5508
See https://github.com/laszlocsomor/proposals/blob/win-test-runner/designs/2018-07-18-windows-native-test-runner.md

Change-Id: I15ce28beb6eb98cb9dd60e2158b906c5b0ae9bb9
  • Loading branch information
laszlocsomor committed Aug 8, 2018
1 parent 7f3ad73 commit 329cc79
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ public Object getDefault(AttributeMap rule) {
.nonconfigurable("policy decision: should be consistent across configurations"))
.add(attr("args", STRING_LIST))
// Input files for every test action
.add(
attr("$test_wrapper", LABEL)
.cfg(HostTransition.INSTANCE)
.singleArtifact()
.value(env.getToolsLabel("//tools/test:test_wrapper")))
.add(
attr("$test_runtime", LABEL_LIST)
.cfg(HostTransition.INSTANCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ public static final RuleClass getTestBaseRule(String toolsRepository) {
"policy decision: this should be consistent across configurations"))
.add(attr("args", STRING_LIST))
// Input files for every test action
.add(
attr("$test_wrapper", LABEL)
.cfg(HostTransition.INSTANCE)
.singleArtifact()
.value(
labelCache.getUnchecked(toolsRepository + "//tools/test:test_wrapper")))
.add(
attr("$test_runtime", LABEL_LIST)
.cfg(HostTransition.INSTANCE)
Expand Down
16 changes: 15 additions & 1 deletion tools/test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ filegroup(
srcs = ["@bazel_tools//tools/test/LcovMerger/java/com/google/devtools/lcovmerger:Main"],
)

cc_binary(
name = "test_wrapper",
srcs = select({
"@bazel_tools//src/conditions:windows": ["windows/test_wrapper.cc"],
# Dummy source file, so this rule can be built on non-Windows platforms
# (when building all targets in this package).
"//conditions:default": ["windows/dummy.cc"],
}),
visibility = ["//visibility:private"],
)

filegroup(
name = "srcs",
srcs = glob(["**"]),
Expand All @@ -45,6 +56,9 @@ filegroup(
"test-setup.sh",
"generate-xml.sh",
"collect_coverage.sh",
] + glob(["LcovMerger/**"]),
] + glob(["LcovMerger/**"]) + select({
"@bazel_tools//src/conditions:windows": ["test_wrapper"],
"//conditions:default": [],
}),
visibility = ["//tools:__pkg__"],
)
8 changes: 8 additions & 0 deletions tools/test/BUILD.tools
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ filegroup(
name = "coverage_report_generator",
srcs = ["@bazel_tools//tools/test/LcovMerger/java/com/google/devtools/lcovmerger:Main"],
)

filegroup(
name = "test_wrapper",
srcs = select({
"@bazel_tools//src/conditions:windows": ["test_wrapper.exe"],
"//conditions:default": ["test_wrapper"],
}),
)
27 changes: 27 additions & 0 deletions tools/test/windows/dummy.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2018 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.

// Empty implementation of the test wrapper.
//
// As of 2018-08-08, every platform uses //tools/test:test-setup.sh as the test
// wrapper, and we are working on introducing a C++ test wrapper for Windows.
// See https://github.com/laszlocsomor/proposals/blob/win-test-runner/designs/2018-07-18-windows-native-test-runner.md

#include <stdio.h>

int main(int, char**) {
fprintf(stderr,
__FILE__ ": The C++ test wrapper is not used on this platform.\n");
return 1;
}
22 changes: 22 additions & 0 deletions tools/test/windows/test_wrapper.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2018 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.

// Test wrapper implementation for Windows.
// Design: https://github.com/laszlocsomor/proposals/blob/win-test-runner/designs/2018-07-18-windows-native-test-runner.md

int main(int argc, char** argv) {
// TODO(laszlocsomor): Implement the functionality described in
// https://github.com/laszlocsomor/proposals/blob/win-test-runner/designs/2018-07-18-windows-native-test-runner.md
return 0;
}

0 comments on commit 329cc79

Please sign in to comment.