forked from bazelbuild/bazel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test that builds a Windows binary remotely and runs it locally,…
… to validate this key use case for remote Windows builds. This is a working test case, but I plan to add more in this style to demonstrate fixes to address bazelbuild#4962.
- Loading branch information
Jeremy Sharpe
committed
Apr 9, 2018
1 parent
eb0671b
commit dcbf1e4
Showing
3 changed files
with
170 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# pylint: disable=g-bad-file-header | ||
# Copyright 2017 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 WindowsRemoteTest(test_base.TestBase): | ||
|
||
_worker_stdout = None | ||
_worker_stderr = None | ||
|
||
def _RunRemoteBazel(self, args, port, env_remove=None, env_add=None): | ||
return self.RunBazel( | ||
args + [ | ||
'--spawn_strategy=remote', | ||
'--strategy=Javac=remote', | ||
'--strategy=Closure=remote', | ||
'--genrule_strategy=remote', | ||
'--define=EXECUTOR=remote', | ||
'--remote_executor=localhost:' + str(port), | ||
'--remote_cache=localhost:' + str(port), | ||
'--experimental_strict_action_env=true', | ||
'--remote_timeout=3600', | ||
'--auth_enabled=false', | ||
'--remote_accept_cached=false', | ||
], | ||
env_remove=env_remove, | ||
env_add=env_add) | ||
|
||
# Check that a binary built remotely is runnable locally. Among other things, | ||
# this means the runfiles manifest, which is not present remotely, must exist | ||
# locally. | ||
def testBinaryRunnableLocally(self): | ||
self.ScratchFile('WORKSPACE') | ||
self.ScratchFile( | ||
'foo/BUILD', | ||
[ | ||
'sh_binary(', | ||
' name = "foo",', | ||
' srcs = ["foo.sh"],', | ||
')', | ||
]) | ||
foo_sh = self.ScratchFile('foo/foo.sh', [ | ||
'#!/bin/bash', | ||
'echo hello shell', | ||
]) | ||
|
||
exit_code, stdout, stderr = self.RunBazel(['info', 'bazel-bin']) | ||
self.AssertExitCode(exit_code, 0, stderr) | ||
bazel_bin = stdout[0] | ||
|
||
port = self.StartRemoteWorker() | ||
|
||
# Build. | ||
exit_code, stdout, stderr = self._RunRemoteBazel(['build', '//foo:foo'], port) | ||
print stdout | ||
self.AssertExitCode(exit_code, 0, stderr) | ||
|
||
# Run. | ||
foo_bin = os.path.join(bazel_bin, 'foo', 'foo.exe') | ||
self.assertTrue(os.path.exists(foo_bin)) | ||
exit_code, stdout, stderr = self.RunProgram([foo_bin]) | ||
self.AssertExitCode(exit_code, 0, stderr) | ||
self.assertEqual(stdout, ['hello shell']) | ||
|
||
self.StopRemoteWorker() | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |