Skip to content

Commit

Permalink
Merge branch 'release-7.3.0' into cp22953-7.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorcloudy authored Jul 10, 2024
2 parents 2ab73dd + bf5f7e6 commit 1992d49
Show file tree
Hide file tree
Showing 21 changed files with 116 additions and 40 deletions.
11 changes: 9 additions & 2 deletions .bazelci/postsubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ tasks:
- build
- test
macos:
shards: 20
shell_commands:
- sed -i.bak -e 's/^# android_sdk_repository/android_sdk_repository/' -e 's/^#
android_ndk_repository/android_ndk_repository/' WORKSPACE.bzlmod
Expand All @@ -174,7 +175,7 @@ tasks:
test_flags:
- "--config=ci-macos"
# Fine tune the number of test jobs running in parallel to avoid timeout
- "--local_test_jobs=8"
- "--local_test_jobs=2"
test_targets:
- "//scripts/..."
- "//src/main/starlark/tests/builtins_bzl/..."
Expand Down Expand Up @@ -206,11 +207,17 @@ tasks:
- "-//src/test/shell/bazel/android:android_instrumentation_test_integration_test_with_head_android_tools"
- "-//src/test/shell/bazel/android:aapt_integration_test"
- "-//src/test/shell/bazel/android:aapt_integration_test_with_head_android_tools"
# ServerTests frequently runs into deadlocks on Intel Macs
- "-//src/test/java/com/google/devtools/build/lib/server:ServerTests"
# bazel_proto_library_test is timeout flaky on Intel Macs, which usually means a runtime of 2 hours or more
- "-//src/test/shell/bazel:bazel_proto_library_test"
# Takes too long on Intel VMs
- "-//src/test/shell/bazel:bazel_bootstrap_distfile_test"
include_json_profile:
- build
- test
macos_arm64:
xcode_version: "15.1"
shards: 5
shell_commands:
- sed -i.bak -e 's/^# android_sdk_repository/android_sdk_repository/' -e 's/^#
android_ndk_repository/android_ndk_repository/' WORKSPACE.bzlmod
Expand Down
14 changes: 10 additions & 4 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ tasks:
- build
- test
macos:
shards: 5
shards: 20
shell_commands:
- sed -i.bak -e 's/^# android_sdk_repository/android_sdk_repository/' -e 's/^#
android_ndk_repository/android_ndk_repository/' WORKSPACE.bzlmod
Expand All @@ -178,7 +178,7 @@ tasks:
test_flags:
- "--config=ci-macos"
# Fine tune the number of test jobs running in parallel to avoid timeout
- "--local_test_jobs=8"
- "--local_test_jobs=2"
test_targets:
- "//scripts/..."
- "//src/main/starlark/tests/builtins_bzl/..."
Expand Down Expand Up @@ -258,12 +258,18 @@ tasks:
# - "-//src/test/shell/bazel/android:resource_processing_integration_test_with_head_android_tools"
- "-//src/test/shell/integration:aquery_test"
- "-//src/test/py/bazel:mod_command_test"
# ServerTests frequently runs into deadlocks on Intel Macs
- "-//src/test/java/com/google/devtools/build/lib/server:ServerTests"
# bazel_proto_library_test is timeout flaky on Intel Macs, which usually means a runtime of 2 hours or more
- "-//src/test/shell/bazel:bazel_proto_library_test"
# Takes too long on Intel VMs
- "-//src/test/shell/bazel:bazel_bootstrap_distfile_test"
- "-//src/test/shell/bazel:bazel_bootstrap_distfile_tar_test"
include_json_profile:
- build
- test
macos_arm64:
shards: 2
xcode_version: "15.1"
shards: 5
shell_commands:
- sed -i.bak -e 's/^# android_sdk_repository/android_sdk_repository/' -e 's/^#
android_ndk_repository/android_ndk_repository/' WORKSPACE.bzlmod
Expand Down
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.2.0
7.2.1
8 changes: 4 additions & 4 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/py_native/fail.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class TestGetNumber(unittest.TestCase):

def test_fail(self):
self.assertEquals(GetNumber(), 0)
self.assertEqual(GetNumber(), 0)


if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions examples/py_native/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
class TestGetNumber(unittest.TestCase):

def test_ok(self):
self.assertEquals(GetNumber(), 42)
self.assertEqual(GetNumber(), 42)

def test_fib(self):
self.assertEquals(Fib(5), 8)
self.assertEqual(Fib(5), 8)

if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ java_binary(
name = "BazelPackageLoaderTester",
testonly = True,
srcs = ["BazelPackageLoaderTester.java"],
jvm_flags = select({
# For MacService machines which only have IPv6 addresses.
"//src/conditions:darwin": ["-Djava.net.preferIPv6Addresses=true"],
"//conditions:default": [],
}),
deps = [
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//src/main/java/com/google/devtools/build/lib/events",
Expand Down
29 changes: 20 additions & 9 deletions src/test/cpp/option_processor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,13 @@ class OptionProcessorTest : public ::testing::Test {
};

TEST_F(OptionProcessorTest, CanParseOptions) {
const std::vector<std::string> args = {"bazel", "--host_jvm_args=MyParam",
"--nobatch", "command",
"--flag", "//my:target",
const std::vector<std::string> args = {"bazel",
"--ignore_all_rc_files",
"--host_jvm_args=MyParam",
"--nobatch",
"command",
"--flag",
"//my:target",
"--flag2=42"};
std::string error;
ASSERT_EQ(blaze_exit_code::SUCCESS,
Expand Down Expand Up @@ -135,9 +139,13 @@ TEST_F(OptionProcessorTest, CanParseOptions) {
}

TEST_F(OptionProcessorTest, CanParseHelpCommandSurroundedByOtherArgs) {
const std::vector<std::string> args = {"bazel", "--host_jvm_args=MyParam",
"--nobatch", "help",
"--flag", "//my:target",
const std::vector<std::string> args = {"bazel",
"--ignore_all_rc_files",
"--host_jvm_args=MyParam",
"--nobatch",
"help",
"--flag",
"//my:target",
"--flag2=42"};
std::string error;
ASSERT_EQ(blaze_exit_code::SUCCESS,
Expand Down Expand Up @@ -196,9 +204,12 @@ TEST_F(OptionProcessorTest, CanParseEmptyArgs) {
}

TEST_F(OptionProcessorTest, CanParseDifferentStartupArgs) {
const std::vector<std::string> args =
{"bazel",
"--nobatch", "--host_jvm_args=MyParam", "--host_jvm_args", "42"};
const std::vector<std::string> args = {"bazel",
"--nobatch",
"--ignore_all_rc_files",
"--host_jvm_args=MyParam",
"--host_jvm_args",
"42"};
std::string error;
ASSERT_EQ(blaze_exit_code::SUCCESS,
option_processor_->ParseOptions(args, workspace_, cwd_, &error))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ public void setup(BlackBoxTestContext context) throws IOException {
}
}

lines.add("common --enable_bzlmod");
if (OS.getCurrent() == OS.DARWIN) {
// Prefer ipv6 network on macOS
lines.add("startup --host_jvm_args=-Djava.net.preferIPv6Addresses=true");
lines.add("build --jvmopt=-Djava.net.preferIPv6Addresses");
}

context.write(".bazelrc", lines);
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/net/starlark/java/syntax/ParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ public void testParseExpressionStackOverflow() throws Exception {

private static ParserInput veryDeepExpression() {
StringBuilder s = new StringBuilder();
for (int i = 0; i < 1000; i++) {
for (int i = 0; i < 5000; i++) {
s.append("{");
}
return ParserInput.fromString(s.toString(), "foo.star");
Expand Down
4 changes: 2 additions & 2 deletions src/test/py/bazel/action_temp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,15 @@ def _AssertOutputFileContents(self, lines, input_file_line,
self.assertEqual(lines[0:3], [input_file_line, 'TMP:y', 'TEMP:y'])
tmp = lines[3].split('=', 1)[1]
temp = lines[4].split('=', 1)[1]
self.assertRegexpMatches(tmp, expected_tmpdir_regex)
self.assertRegex(tmp, expected_tmpdir_regex)
self.assertEqual(tmp, temp)
else:
# 3 lines = input_file_line, foo, TMPDIR
if len(lines) != 3:
self.fail('lines=%s' % lines)
self.assertEqual(lines[0:2], [input_file_line, 'foo'])
tmpdir = lines[2].split('=', 1)[1]
self.assertRegexpMatches(tmpdir, expected_tmpdir_regex)
self.assertRegex(tmpdir, expected_tmpdir_regex)


if __name__ == '__main__':
Expand Down
12 changes: 6 additions & 6 deletions src/test/py/bazel/launcher_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ def _buildJavaTargets(self, bazel_bin, binary_suffix):
self.assertEqual(len(stdout), 4)
self.assertEqual(stdout[0], 'hello java')
if self.IsWindows():
self.assertRegexpMatches(
self.assertRegex(
stdout[1], r'java_runfiles=.*foo\\foo%s.runfiles' % binary_suffix)
self.assertEqual(stdout[2], 'runfiles_manifest_only=1')
self.assertRegexpMatches(
self.assertRegex(
stdout[3], r'^runfiles_manifest_file=[a-zA-Z]:[/\\].*MANIFEST$')
else:
self.assertRegexpMatches(stdout[1], r'java_runfiles=.*/foo/foo.runfiles')
self.assertRegex(stdout[1], r'java_runfiles=.*/foo/foo.runfiles')
self.assertEqual(stdout[2], 'runfiles_manifest_only=')
self.assertRegexpMatches(stdout[3], r'^runfiles_manifest_file.*MANIFEST$')
self.assertRegex(stdout[3], r'^runfiles_manifest_file.*MANIFEST$')

def _buildShBinaryTargets(self, bazel_bin, bin1_suffix):
self.RunBazel(['build', '//foo:bin1.sh'])
Expand Down Expand Up @@ -134,7 +134,7 @@ def _buildShBinaryTargets(self, bazel_bin, bin1_suffix):
self.assertEqual(stdout[0], 'hello shell')
if self.IsWindows():
self.assertEqual(stdout[1], 'runfiles_manifest_only=1')
self.assertRegexpMatches(
self.assertRegex(
stdout[2],
(r'^runfiles_manifest_file='
r'[a-zA-Z]:/.*/foo/bin1.sh%s.runfiles/MANIFEST$' % bin1_suffix))
Expand Down Expand Up @@ -547,7 +547,7 @@ def testWindowsJavaExeLauncher(self):
_, stdout, _ = self.RunProgram([binary, '--classpath_limit=0', print_cmd])
self.assertIn('-classpath', stdout)
classpath = stdout[stdout.index('-classpath') + 1]
self.assertRegexpMatches(classpath, r'foo-[A-Za-z0-9]+-classpath.jar$')
self.assertRegex(classpath, r'foo-[A-Za-z0-9]+-classpath.jar$')

def testWindowsNativeLauncherInNonEnglishPath(self):
if not self.IsWindows():
Expand Down
11 changes: 10 additions & 1 deletion src/test/py/bazel/remote/cache_decompression_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,21 @@ def do_GET(self):
self.finish()


class HTTPServerV6(HTTPServer):
address_family = socket.AF_INET6


class CacheDecompressionTest(test_base.TestBase):

def setUp(self):
test_base.TestBase.setUp(self)
server_port = self.GetFreeTCPPort()
self.httpd = HTTPServer(('localhost', server_port), MemoryStorageHandler)
if self.IsDarwin():
self.httpd = HTTPServerV6(
('localhost', server_port), MemoryStorageHandler
)
else:
self.httpd = HTTPServer(('localhost', server_port), MemoryStorageHandler)
self.httpd.storage = {}
self.url = 'http://localhost:{}'.format(server_port)
self.background = threading.Thread(target=self.httpd.serve_forever)
Expand Down
5 changes: 4 additions & 1 deletion src/test/py/bazel/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ def setUp(self):
if TestBase.IsDarwin():
# For reducing SSD usage on our physical Mac machines.
f.write('common --experimental_repository_cache_hardlinks\n')
f.write('common --enable_bzlmod\n')
if TestBase.IsDarwin():
# Prefer ipv6 network on macOS
f.write('startup --host_jvm_args=-Djava.net.preferIPv6Addresses=true\n')
f.write('build --jvmopt=-Djava.net.preferIPv6Addresses\n')
# An empty MODULE.bazel and a corresponding MODULE.bazel.lock will prevent
# tests from accessing BCR
self.ScratchFile('MODULE.bazel')
Expand Down
3 changes: 2 additions & 1 deletion src/test/shell/bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ sh_test(
tags = [
"no-sandbox",
"no_windows",
"requires-network", # For Bzlmod
],
)

Expand Down Expand Up @@ -793,7 +794,7 @@ sh_test(

sh_test(
name = "external_remote_file_test",
size = "small",
size = "medium",
srcs = ["external_remote_file_test.sh"],
data = [
":test-deps",
Expand Down
12 changes: 10 additions & 2 deletions src/test/shell/bazel/bazel_test_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,16 @@ sh_test(
)
EOF

# The next line ensures that the test passes in IPv6-only networks on macOS.
if is_darwin; then
export JAVA_TOOL_OPTIONS="-Djava.net.preferIPv6Addresses=true"
export STARTUP_OPTS="--host_jvm_args=-Djava.net.preferIPv6Addresses=true"
else
export STARTUP_OPTS=""
fi

# Test BAR is set from --action_env
BAZ=fromaction bazel --ignore_all_rc_files test --test_output=all \
BAZ=fromaction bazel --ignore_all_rc_files $STARTUP_OPTS test --test_output=all \
--action_env=BAR=fromcli --action_env=BAZ \
//foo &> $TEST_log || fail "Test failed"
expect_log "foo: frombuild"
Expand All @@ -187,7 +195,7 @@ EOF
# Test FOO from the BUILD file wins
# Test BAR is set from --test_env
# Test BAZ is set from --test_env
BAZ=fromtest bazel --ignore_all_rc_files test --test_output=all \
BAZ=fromtest bazel --ignore_all_rc_files $STARTUP_OPTS test --test_output=all \
--action_env=FOO=fromcli --test_env=FOO=fromcli --test_env=BAR=fromcli \
--test_env=BAZ //foo &> $TEST_log || fail "Test failed"
expect_log "foo: frombuild"
Expand Down
9 changes: 8 additions & 1 deletion src/test/shell/bazel/testing_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
import time


class TCPServerV6(TCPServer):
address_family = socket.AF_INET6


class Handler(BaseHTTPRequestHandler):
"""Handlers for testing HTTP server."""
auth = False
Expand Down Expand Up @@ -152,7 +156,10 @@ def main(argv):
while port is None:
try:
port = random.randrange(32760, 59760)
httpd = TCPServer(('', port), Handler)
if sys.platform == 'darwin':
httpd = TCPServerV6(('', port), Handler)
else:
httpd = TCPServer(('', port), Handler)
except socket.error:
port = None
sys.stdout.write('%d\nstarted\n' % (port,))
Expand Down
3 changes: 3 additions & 0 deletions src/test/shell/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ sh_test(
"@bazel_tools//tools/bash/runfiles",
],
shard_count = 8,
tags = [
"requires-network", # For Bzlmod
],
)

sh_test(
Expand Down
Loading

0 comments on commit 1992d49

Please sign in to comment.