diff --git a/docs/notes/2.24.x.md b/docs/notes/2.24.x.md index db947ae0cc0..6bbafdcf79f 100644 --- a/docs/notes/2.24.x.md +++ b/docs/notes/2.24.x.md @@ -79,6 +79,10 @@ Pants will now warn if any errors are encountered while fingerprinting candidate Added a new `cache_scope` field to `adhoc_tool` and `shell_command` targets to allow configuration of the "cache scope" of the invoked process. The cache scope determines how long Pants will cache the result of the invoked process absent any other invalidation of the result via source or dependency changes. +#### Go + +Fix a bug where Pants raised an internal exception which occurred when compiling a Go package with coverage support when the package also had an external test which imported the base package. + ### Plugin API changes The `path_metadata_request` intrinsic rule can now access metadata for paths in the local system outside of the build root. Use the new `namespace` field on `PathMetadataRequest` to request metdata on local system paths using namespace `PathNamespace.SYSTEM`. diff --git a/src/python/pants/backend/go/goals/test_test.py b/src/python/pants/backend/go/goals/test_test.py index 2b764a9cb55..26cfc9d6f97 100644 --- a/src/python/pants/backend/go/goals/test_test.py +++ b/src/python/pants/backend/go/goals/test_test.py @@ -714,3 +714,45 @@ def test_profile_options_write_results(rule_runner: RuleRunner) -> None: "test_runner", "trace.out", ] + + +def test_external_test_with_use_coverage(rule_runner: RuleRunner) -> None: + rule_runner.write_files( + { + "foo/BUILD": "go_mod(name='mod')\ngo_package()", + "foo/go.mod": "module foo", + "foo/add.go": textwrap.dedent( + """ + package foo + func Add(x, y int) int { + return x + y + } + """ + ), + "foo/add_test.go": textwrap.dedent( + """ + package foo_test + import ( + "foo" + "testing" + ) + func TestAdd(t *testing.T) { + if foo.Add(2, 3) != 5 { + t.Fail() + } + } + """ + ), + } + ) + tgt = rule_runner.get_target(Address("foo", generated_name="./")) + rule_runner.set_options( + [ + "--test-use-coverage", + ], + env_inherit={"PATH"}, + ) + result = rule_runner.request( + TestResult, [GoTestRequest.Batch("", (GoTestFieldSet.create(tgt),), None)] + ) + assert result.exit_code == 0 diff --git a/src/python/pants/backend/go/util_rules/build_pkg_target.py b/src/python/pants/backend/go/util_rules/build_pkg_target.py index fccc4290b7c..62964ac5d63 100644 --- a/src/python/pants/backend/go/util_rules/build_pkg_target.py +++ b/src/python/pants/backend/go/util_rules/build_pkg_target.py @@ -458,7 +458,10 @@ async def setup_build_go_package_target_request( maybe_base_pkg_dep = await Get( FallibleBuildGoPackageRequest, BuildGoPackageTargetRequest( - request.address, for_tests=True, build_opts=request.build_opts + request.address, + for_tests=True, + with_coverage=request.with_coverage, + build_opts=request.build_opts, ), ) if maybe_base_pkg_dep.request is None: diff --git a/src/rust/engine/Cargo.lock b/src/rust/engine/Cargo.lock index d9fb64d86a4..c2aed4f18ba 100644 --- a/src/rust/engine/Cargo.lock +++ b/src/rust/engine/Cargo.lock @@ -450,7 +450,7 @@ dependencies = [ "serde_urlencoded", "thiserror", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.12", "tower-service", "url", "winapi", @@ -518,9 +518,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" [[package]] name = "cache" @@ -1096,7 +1096,7 @@ dependencies = [ "testutil", "tokio", "tokio-rustls 0.26.0", - "tokio-util 0.7.10", + "tokio-util 0.7.12", "workunit_store", ] @@ -1201,7 +1201,7 @@ dependencies = [ "time", "tokio", "tokio-retry", - "tokio-util 0.7.10", + "tokio-util 0.7.12", "tryfuture", "ui", "url", @@ -1616,13 +1616,13 @@ dependencies = [ "prost-types", "rand", "rustls 0.23.10", - "rustls-native-certs", + "rustls-native-certs 0.8.0", "rustls-pemfile", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", "tokio-stream", - "tokio-util 0.7.10", + "tokio-util 0.7.12", "tonic", "tonic-build", "tower", @@ -1647,7 +1647,7 @@ dependencies = [ "indexmap 2.2.3", "slab", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.12", "tracing", ] @@ -1666,7 +1666,7 @@ dependencies = [ "indexmap 2.2.3", "slab", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.12", "tracing", ] @@ -1926,7 +1926,7 @@ dependencies = [ "hyper-util", "log", "rustls 0.23.10", - "rustls-native-certs", + "rustls-native-certs 0.7.0", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -2791,7 +2791,7 @@ dependencies = [ "testutil", "tokio", "tokio-rustls 0.26.0", - "tokio-util 0.7.10", + "tokio-util 0.7.12", "workunit_store", ] @@ -2840,22 +2840,22 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.0.12" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.0.12" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.51", ] [[package]] @@ -3021,7 +3021,7 @@ dependencies = [ "testutil", "tokio", "tokio-rustls 0.26.0", - "tokio-util 0.7.10", + "tokio-util 0.7.12", "tonic", "tryfuture", "uname", @@ -3068,9 +3068,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2ecbe40f08db5c006b5764a2645f7f3f141ce756412ac9e1dd6087e6d32995" +checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" dependencies = [ "bytes", "prost-derive", @@ -3078,9 +3078,9 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8650aabb6c35b860610e9cff5dc1af886c9e25073b7b1712a68972af4281302" +checksum = "0c1318b19085f08681016926435853bbf7858f9c082d0999b80550ff5d9abe15" dependencies = [ "bytes", "heck", @@ -3099,9 +3099,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acf0c195eebb4af52c752bec4f52f645da98b6e92077a04110c7f349477ae5ac" +checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", "itertools", @@ -3112,9 +3112,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60caa6738c7369b940c3d49246a8d1749323674c65cb13010134f5c9bad5b519" +checksum = "4759aa0d3a6232fb8dbdb97b61de2c20047c68aca932c7ed76da9d788508d670" dependencies = [ "prost", ] @@ -3325,9 +3325,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.2" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick 1.1.2", "memchr", @@ -3337,9 +3337,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick 1.1.2", "memchr", @@ -3348,9 +3348,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "remote" @@ -3391,7 +3391,7 @@ dependencies = [ "testutil", "tokio", "tokio-rustls 0.26.0", - "tokio-util 0.7.10", + "tokio-util 0.7.12", "tonic", "workunit_store", ] @@ -3446,7 +3446,7 @@ dependencies = [ "tempfile", "testutil", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.12", "tonic", "uuid", "workunit_store", @@ -3494,7 +3494,7 @@ dependencies = [ "serde_urlencoded", "system-configuration", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.12", "tower-service", "url", "wasm-bindgen", @@ -3536,7 +3536,7 @@ dependencies = [ "sync_wrapper 0.1.2", "tokio", "tokio-rustls 0.25.0", - "tokio-util 0.7.10", + "tokio-util 0.7.12", "tower-service", "url", "wasm-bindgen", @@ -3696,6 +3696,19 @@ dependencies = [ "security-framework", ] +[[package]] +name = "rustls-native-certs" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "rustls-pki-types", + "schannel", + "security-framework", +] + [[package]] name = "rustls-pemfile" version = "2.1.2" @@ -3801,18 +3814,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.197" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -3821,11 +3834,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -3853,9 +3867,9 @@ dependencies = [ [[package]] name = "serde_test" -version = "1.0.176" +version = "1.0.177" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a2f49ace1498612d14f7e0b8245519584db8299541dfe31a06374a828d620ab" +checksum = "7f901ee573cab6b3060453d2d5f0bae4e6d628c23c0a962ff9b5f1d7c8d4f1ed" dependencies = [ "serde", ] @@ -3891,9 +3905,9 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.9.32" +version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd075d994154d4a774f95b51fb96bdc2832b0ea48425c92546073816cda1f2f" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ "indexmap 2.2.3", "itoa", @@ -4052,7 +4066,7 @@ dependencies = [ "testutil", "tokio", "tokio-rustls 0.26.0", - "tokio-util 0.7.10", + "tokio-util 0.7.12", "tonic", "tower-service", "tryfuture", @@ -4332,9 +4346,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.39.2" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", @@ -4394,9 +4408,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.14" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -4419,16 +4433,15 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -4442,9 +4455,9 @@ dependencies = [ [[package]] name = "tonic" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6f6ba989e4b2c58ae83d862d3a3e27690b6e3ae630d0deb59f3697f32aa88ad" +checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" dependencies = [ "async-stream", "async-trait", @@ -4461,7 +4474,7 @@ dependencies = [ "percent-encoding", "pin-project", "prost", - "rustls-native-certs", + "rustls-native-certs 0.8.0", "rustls-pemfile", "socket2 0.5.7", "tokio", @@ -4475,13 +4488,14 @@ dependencies = [ [[package]] name = "tonic-build" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe4ee8877250136bd7e3d2331632810a4df4ea5e004656990d8d66d2f5ee8a67" +checksum = "9557ce109ea773b399c9b9e5dca39294110b74f1f342cb347a80d1fce8c26a11" dependencies = [ "prettyplease", "proc-macro2", "prost-build", + "prost-types", "quote", "syn 2.0.51", ] @@ -4500,7 +4514,7 @@ dependencies = [ "rand", "slab", "tokio", - "tokio-util 0.7.10", + "tokio-util 0.7.12", "tower-layer", "tower-service", "tracing", @@ -4670,9 +4684,9 @@ checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" [[package]] name = "unsafe-libyaml" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" [[package]] name = "untrusted" @@ -5265,9 +5279,9 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96f8f25c15a0edc9b07eb66e7e6e97d124c0505435c382fde1ab7ceb188aa956" +checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" dependencies = [ "byteorder", "zerocopy-derive", @@ -5275,9 +5289,9 @@ dependencies = [ [[package]] name = "zerocopy-derive" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "855e0f6af9cd72b87d8a6c586f3cb583f5cdcc62c2c80869d8cd7e96fdf7ee20" +checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" dependencies = [ "proc-macro2", "quote", diff --git a/src/rust/engine/Cargo.toml b/src/rust/engine/Cargo.toml index 3af7ce2d52f..809366aaece 100644 --- a/src/rust/engine/Cargo.toml +++ b/src/rust/engine/Cargo.toml @@ -284,7 +284,7 @@ os_pipe = "1.1" parking_lot = "0.12" peg = "0.8" petgraph = "0.6" -pin-project = "1.0.12" +pin-project = "1.1.5" pin-project-lite = "0.2" prodash = { git = "https://github.com/stuhood/prodash", rev = "stuhood/raw-messages-draft", version = "16", default-features = false, features = [ "progress-tree", @@ -300,7 +300,7 @@ rand = "0.8" regex = "1" rlimit = "0.8" rustls = "0.23" -rustls-native-certs = "0.7" +rustls-native-certs = "0.8" rustls-pemfile = "2.0" rustls-pki-types = "1.7" serde = "1.0.160" diff --git a/src/rust/engine/grpc_util/build.rs b/src/rust/engine/grpc_util/build.rs index 57cbb8e4ded..2ed96503911 100644 --- a/src/rust/engine/grpc_util/build.rs +++ b/src/rust/engine/grpc_util/build.rs @@ -9,7 +9,7 @@ fn main() -> Result<(), Box> { tonic_build::configure() .build_client(true) .build_server(true) - .compile_with_config(config, &["protos/test.proto"], &["protos"])?; + .compile_protos_with_config(config, &["protos/test.proto"], &["protos"])?; Ok(()) } diff --git a/src/rust/engine/grpc_util/src/tls.rs b/src/rust/engine/grpc_util/src/tls.rs index 4a6e6b10180..c7ba4b292c4 100644 --- a/src/rust/engine/grpc_util/src/tls.rs +++ b/src/rust/engine/grpc_util/src/tls.rs @@ -1,5 +1,6 @@ // Copyright 2022 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). +use std::fmt::Write; use std::io; use std::sync::Arc; @@ -88,16 +89,20 @@ impl TryFrom for ClientConfig { } } None => { - let native_root_certs = rustls_native_certs::load_native_certs() - .map_err(|err| { - format!( - "Could not discover root CA cert files to use TLS with remote caching and remote \ + let native_root_certs_result = rustls_native_certs::load_native_certs(); + if !native_root_certs_result.errors.is_empty() { + let mut msg = String::from("Could not discover root CA cert files to use TLS with remote caching and remote \ execution. Consider setting `--remote-ca-certs-path` instead to explicitly point to \ - the correct PEM file.\n\n{err}", - ) - })?; + the correct PEM file. Error(s):\n\n"); + for error in &native_root_certs_result.errors { + write!(&mut msg, "{}\n\n", &error) + .expect("write into mutable string"); + } + return Err(msg); + } - root_cert_store.add_parsable_certificates(native_root_certs); + root_cert_store + .add_parsable_certificates(native_root_certs_result.certs); } } diff --git a/src/rust/engine/protos/build.rs b/src/rust/engine/protos/build.rs index 682813604ce..0bec1d864a3 100644 --- a/src/rust/engine/protos/build.rs +++ b/src/rust/engine/protos/build.rs @@ -16,7 +16,7 @@ fn main() -> Result<(), Box> { tonic_build::configure() .build_client(true) .build_server(true) - .compile_with_config( + .compile_protos_with_config( config, &[ "protos/bazelbuild_remote-apis/build/bazel/remote/execution/v2/remote_execution.proto",