forked from bazelbuild/bazel
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Windows: add skeleton for Bash-less test wrapper
In this commit: - Add the not-yet-documented `--windows_native_test_wrapper` flag. This flag will guard the new feature and allow the Bazel team to roll out the feature gradually, as well as to deprecate the old test execution mechanism gradually. - Add a target for the native implementation of the test wrapper. - Hook up the test action creator logic to use the new binary, and add a test to assert this. See bazelbuild#5508 Change-Id: I980a1a88cfabd04ddcf8a5b26620f8f3255f77ef
- Loading branch information
1 parent
32e3b9d
commit b14c932
Showing
13 changed files
with
234 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
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
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# 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. | ||
|
||
import os | ||
import unittest | ||
from src.test.py.bazel import test_base | ||
|
||
|
||
class BazelCleanTest(test_base.TestBase): | ||
|
||
def testTestExecutionWithTestSetupShAndWithTestWrapperExe(self): | ||
self.ScratchFile('WORKSPACE') | ||
self.ScratchFile('foo/BUILD', [ | ||
'py_test(', | ||
' name = "x_test",', | ||
' srcs = ["x_test.py"],', | ||
')', | ||
]) | ||
self.ScratchFile('foo/x_test.py', [ | ||
'from __future__ import print_function', | ||
'import unittest', | ||
'', | ||
'class XTest(unittest.TestCase):', | ||
' def testFoo(self):', | ||
' print("lorem ipsum")', | ||
'', | ||
'if __name__ == "__main__":', | ||
' unittest.main()', | ||
], executable = True) | ||
|
||
# Run test with test-setup.sh | ||
exit_code, stdout, stderr = self.RunBazel([ | ||
'test', '//foo:x_test', '--test_output=streamed', '-t-', | ||
'--nowindows_native_test_wrapper']) | ||
self.AssertExitCode(exit_code, 0, stderr) | ||
found = False | ||
for line in stdout + stderr: | ||
if 'lorem ipsum' in line: | ||
found = True | ||
if not found: | ||
self.fail('FAIL: output:\n%s\n---' % '\n'.join(stderr + stdout)) | ||
|
||
# Run test with test_wrapper.exe | ||
exit_code, _, stderr = self.RunBazel([ | ||
'test', '//foo:x_test', '--test_output=streamed', '-t-', | ||
'--windows_native_test_wrapper']) | ||
|
||
# As of 2018-08-07, test_wrapper.exe cannot yet run tests. | ||
self.AssertExitCode(exit_code, 3, stderr) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
|
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 |
---|---|---|
@@ -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-06, 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; | ||
} |
Oops, something went wrong.