Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/starlark.json
Original file line number Diff line number Diff line change
Expand Up @@ -20332,6 +20332,7 @@
"attrs": [
"actual",
"tags",
"testonly",
"visibility"
],
"kind": "alias"
Expand Down Expand Up @@ -20413,6 +20414,7 @@
{
"attrs": [
"tags",
"testonly",
"tool",
"visibility"
],
Expand Down Expand Up @@ -20632,6 +20634,7 @@
"attrs": [
"actual",
"tags",
"testonly",
"visibility"
],
"kind": "alias"
Expand Down Expand Up @@ -20683,6 +20686,7 @@
{
"attrs": [
"tags",
"testonly",
"tool",
"visibility"
],
Expand Down
3 changes: 0 additions & 3 deletions cli/cli/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ rust_library(
# keep
deps = [
"//cli/adopt:dx_adopt",
"//cli/archive:dx_archive",
"//cli/atomic_fs:dx_atomic_fs",
"//cli/bep:dx_bep",
"//cli/codegen:dx_codegen",
Expand Down Expand Up @@ -100,7 +99,6 @@ rust_library(
"@crates//:serde",
"@crates//:serde-sarif",
"@crates//:serde_json",
"@crates//:tempfile",
"@crates//:tracing",
],
)
Expand Down Expand Up @@ -389,7 +387,6 @@ rust_test(
deps = [
"//cli/adopt:dx_adopt",
"//cli/apply:dx_apply",
"//cli/archive:dx_archive",
"//cli/atomic_fs:dx_atomic_fs",
"//cli/audit:dx_audit",
"//cli/bep:dx_bep",
Expand Down
3 changes: 2 additions & 1 deletion cli/cli/src/adopt/init_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,8 @@ mod tests {
std::fs::write(root.join(".editorconfig"), "root = true\n").expect("editorconfig");
std::fs::write(root.join(".gitignore"), "target/\n").expect("gitignore");
std::fs::create_dir_all(root.join(".github/workflows")).expect("workflows");
let hand = ci.lines().skip(1).collect::<Vec<_>>().join("\n") + "\n";
let mut hand = ci.lines().skip(1).collect::<Vec<_>>().join("\n");
hand.push('\n');
std::fs::write(root.join(".github/workflows/ci.yml"), &hand).expect("ci");
let (code, _out, err) = run(&invocation(&["init", "--apply"]), root);
assert_eq!(code, 0, "{err}");
Expand Down
2 changes: 1 addition & 1 deletion cli/cli/src/adopt/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ fn finish_upgrade(
if conflicts > 0 {
return conflicted(invocation, to, conflicts, out, err);
}
return json_pin(invocation, out, "default", to, ide_warning.as_deref())
return json_pin(invocation, out, "default", to, ide_warning)
.map_or_else(|exit| exit, |()| 0);
}
if let Some(message) = &ide_warning {
Expand Down
3 changes: 1 addition & 2 deletions cli/cli/src/exec/update_consumer_tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::test_support::Harness;
use super::test_support::{event, event_kinds, json_events};
use super::test_support::{event_kinds, json_events};
use super::update_live::{Launch, ScriptRunner, fake_pinned};

fn uv_call(check: bool, dir: &str) -> Vec<String> {
Expand Down Expand Up @@ -502,7 +502,6 @@ fn consumer_json_check_reports_per_set_correlations() {
out.contains("\"correlation\":\"update:deps-worker\""),
"{out}"
);
let _: &serde_json::Value = event(&events, "command_started");
}

const MIXED_MODULE: &str = "uv = use_extension(\"@rules_py//uv:extensions.bzl\", \"uv\")\nuv.project(hub_name = \"deps\", pyproject = \"//apps/frontend:pyproject.toml\", lock = \"//apps/frontend:uv.lock\")\nnpm = use_extension(\"@aspect_rules_js//npm:extensions.bzl\", \"npm\")\nnpm.npm_translate_lock(name = \"jobs\", pnpm_lock = \"//consumer-npm/jobs:pnpm-lock.yaml\")\nnpm.npm_translate_lock(name = \"web\", pnpm_lock = \"//consumer-npm/web:pnpm-lock.yaml\")\n";
Expand Down
12 changes: 8 additions & 4 deletions cli/cli/tests/adopt/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ rust_test(
"DX_POLYGLOT_UV_LOCK": "$(rootpath //examples/adopt-polyglot:uv.lock)",
"RUST_TEST_THREADS": "1",
},
deps = [
"//cli/test_scratch:dx_test_scratch",
"//tools/testing:dx_testing",
],
# keep
deps = select({
"@platforms//os:windows": [],
"//conditions:default": [
"//cli/test_scratch:dx_test_scratch",
"//tools/testing:dx_testing",
],
}),
)

real_source_target(
Expand Down
12 changes: 8 additions & 4 deletions cli/cli/tests/agents/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ rust_test(
"DX_FAKE_GENERATE": "$(rootpath //cli/cli/tests/fake_generate)",
"RUST_TEST_THREADS": "1",
},
deps = [
"//cli/test_scratch:dx_test_scratch",
"//tools/testing:dx_testing",
],
# keep
deps = select({
"@platforms//os:windows": [],
"//conditions:default": [
"//cli/test_scratch:dx_test_scratch",
"//tools/testing:dx_testing",
],
}),
)

rust_test(
Expand Down
7 changes: 5 additions & 2 deletions cli/exec_quality/src/quality_apply_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use dx_apply::RealFileSystem;
use dx_digest::blake3 as digest;
use dx_exec_core::common::{
FileChange, REASON_INCOMPLETE_COLLECTION, REASON_INVALID_EDITS, REASON_OUTSIDE_SCOPE,
REASON_OUTSIDE_WORKSPACE, REASON_STALE_SOURCE, REASON_WRITE_FAILED,
REASON_STALE_SOURCE, REASON_WRITE_FAILED,
};
use dx_exec_quality_testing::{FailingWrites, temp_dir};

Expand Down Expand Up @@ -208,7 +208,10 @@ fn symlink_leaving_workspace_is_not_applied() {
assert_eq!(outcome.applied.get("src/shared.py"), Some(&false));
assert_eq!(
outcome.not_applied,
vec![("src/shared.py".to_owned(), REASON_OUTSIDE_WORKSPACE)]
vec![(
"src/shared.py".to_owned(),
dx_exec_core::common::REASON_OUTSIDE_WORKSPACE
)]
);
}

Expand Down
30 changes: 14 additions & 16 deletions cli/exec_update/src/dep_edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,28 +260,26 @@ pub(crate) fn preflight(
),
));
}
if target.is_configured_bazel()
if (target.is_configured_bazel()
|| matches!(&target.configured, Some(set) if matches!(
set.kind,
dx_update::edit::ConfiguredKind::Cargo
| dx_update::edit::ConfiguredKind::Maven
| dx_update::edit::ConfiguredKind::Go
))
{
if let Some((_, Err(dx_update::backend::BackendError::Unsupported { reason, .. }))) =
)))
&& let Some((_, Err(dx_update::backend::BackendError::Unsupported { reason, .. }))) =
refresh_plan(workspace, invocation, target, None)
{
return Err(operational(
invocation,
out,
err,
verb.failure_code,
&format!(
"cannot refresh {selector}: {reason} (no {} performed)",
verb.noun,
),
));
}
{
return Err(operational(
invocation,
out,
err,
verb.failure_code,
&format!(
"cannot refresh {selector}: {reason} (no {} performed)",
verb.noun,
),
));
}
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion cli/exec_update/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod dep_edit;
mod staged;
#[cfg(test)]
#[cfg(all(test, unix))]
mod test_env;
mod update;
mod update_add_missing;
Expand Down
8 changes: 4 additions & 4 deletions cli/exec_update/src/update_pr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,10 +655,10 @@ fn refresh_tracking(git: &dyn Fn(&[&str]) -> Result<String, DxError>, branch: &s
"origin",
&format!("+refs/heads/{branch}:{tracking}"),
]);
if fetched.is_err() {
if let Err(error) = git(&["update-ref", "-d", &tracking]) {
tracing::info!(%error, %tracking, "cannot delete the stale tracking ref");
}
if fetched.is_err()
&& let Err(error) = git(&["update-ref", "-d", &tracking])
{
tracing::info!(%error, %tracking, "cannot delete the stale tracking ref");
}
}

Expand Down
6 changes: 4 additions & 2 deletions cli/plan/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ rust_test(
"//cli/generation_result",
"//cli/lcov:dx_lcov",
"//cli/module_bazel:dx_module_bazel",
"//cli/os_sys:dx_os_sys",
"//cli/output:dx_output",
"//cli/path:dx_path",
"//cli/process:dx_process",
Expand All @@ -261,7 +260,10 @@ rust_test(
"@crates//:serde_json",
"@crates//:tempfile",
"@crates//:thiserror",
],
] + select({
"@platforms//os:windows": [],
"//conditions:default": ["//cli/os_sys:dx_os_sys"],
}),
)

rust_bench(
Expand Down
2 changes: 1 addition & 1 deletion cli/plan/src/slots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@ impl Gate {
&mut |holder: &str, reason: WaitReason| {
let reaped = self.reap(&layout);
let (err, events) = &mut *out.borrow_mut();
let message = wait_message(holder) + &reaped_suffix(reaped.unwrap_or(0));
let message = format!("{}{}", wait_message(holder), reaped_suffix(reaped.unwrap_or(0)));
dx_output::write_stderr(&mut **err, format_args!("dx: {message}\n"));
if json {
let mut event = notice_event(
Expand Down
11 changes: 7 additions & 4 deletions core/modules/npm_hub_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ fn hub_violations(source: &str) -> Vec<String> {
Ok(module) => module,
Err(error) => return vec![error.to_string()],
};
let is_dev = |call: &dx_module_bazel::Call| {
matches!(call.arg("dev_dependency"), Some(Value::Ident(value)) if value == "True")
};
let is_dev = |call: &dx_module_bazel::Call| matches!(call.arg("dev_dependency"), Some(Value::Ident(value)) if value == "True");
let dev_proxies: Vec<&str> = module
.calls_named("use_extension")
.filter(|call| is_dev(call))
Expand Down Expand Up @@ -40,7 +38,12 @@ fn collect(dir: &Path, root: &Path, found: &mut Vec<String>) {
let text = std::fs::read_to_string(&path).unwrap_or_default();
if text.contains("\"name\": \"dx-node-tools\"") {
let rel = path.strip_prefix(root).expect("under root");
found.push(rel.parent().expect("parent").display().to_string());
found.push(
rel.parent()
.expect("parent")
.to_string_lossy()
.replace('\\', "/"),
);
}
}
}
Expand Down
15 changes: 5 additions & 10 deletions deploy/private/release/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,11 @@ rust_test(
"DX_SBOM_PROVENANCE": "$(rootpath :sbom_demo_provenance)",
"DX_SBOM_SPDX": "$(rootpath :sbom_demo_spdx)",
},
deps = all_crate_deps(
package_name = "deploy/private/dx_release_tools",
normal = True,
normal_dev = True,
) + [
deps = [
":dx_release_tools",
"//cli/digest:dx_digest",
"//tools/testing:dx_testing",
"@crates//:tempfile",
],
)

Expand All @@ -211,15 +208,13 @@ rust_test(
rust_test(
name = "candidate_identity_test",
srcs = ["candidate_test.rs"],
deps = all_crate_deps(
package_name = "deploy/private/dx_release_tools",
normal = True,
normal_dev = True,
) + [
deps = [
":dx_release_tools",
"//cli/digest:dx_digest",
"//cli/test_scratch:dx_test_scratch",
"//deploy/private:dx_deploy_tools",
"@crates//:serde_json",
"@crates//:tempfile",
],
)

Expand Down
6 changes: 5 additions & 1 deletion deploy/private/release/src/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,10 @@ mod tests {

#[test]
fn missing_input_or_unwritable_output_exits_one() {
let dir = tempfile::tempdir().expect("tempdir");
let blocker = dir.path().join("blocker");
std::fs::write(&blocker, b"").expect("blocker");
let unwritable = blocker.join("out.source.json");
for argv in [
argv_of(&[
PROG,
Expand All @@ -734,7 +738,7 @@ mod tests {
argv_of(&[
PROG,
"bcr-source",
"/definitely/missing/dir/out.source.json",
unwritable.to_str().expect("utf-8 path"),
"rules_dx",
"1.2.3",
]),
Expand Down
4 changes: 4 additions & 0 deletions deploy/private/release/tests/candidate_consumer_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ fn assert_swift_consumer(case: &Case) {

/// Builds with the hermetic GCC toolchain while host compilers on PATH fail.
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
#[expect(
clippy::disallowed_methods,
reason = "tests run local programs under the Bazel test timeout"
)]
fn assert_gcc_consumer(case: &Case) {
use std::os::unix::fs::PermissionsExt;

Expand Down
5 changes: 0 additions & 5 deletions deploy/private/release/tests/release_consumer_test.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
#![expect(
clippy::disallowed_methods,
reason = "tests run local programs under the Bazel test timeout"
)]

mod candidate_consumer_test;
mod quickstart_consumer_test;

Expand Down
6 changes: 6 additions & 0 deletions rust/private/quality/rust_clippy.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ load("@rules_rust//rust:defs.bzl", "rust_clippy_action", "rust_common")
load("@rules_rust//rust/private:clippy.bzl", "ClippyFlagsInfo")
load("@rules_rust//rust/private:rustc.bzl", "get_error_format")
load("@rules_rust//rust/settings:incompatible.bzl", "IncompatibleFlagInfo")
load("//core/quality:sources.bzl", "forwarded_upstream")
load("//rust/private/toolchain:bindings.bzl", "RUST_TOOLCHAIN_TYPE")

DxClippyInfo = provider(
Expand Down Expand Up @@ -47,6 +48,10 @@ def _package_clippy_config(crate_info, label, default):
return default

def _dx_clippy_aspect_impl(target, ctx):
# A forwarder's crate lives in the upstream's configuration, and rustc writes beside it.
upstream = forwarded_upstream(ctx.rule.attr, DxClippyInfo)
if upstream != None:
return [upstream[DxClippyInfo]]
if OutputGroupInfo in target and hasattr(target[OutputGroupInfo], "clippy_checks"):
return [DxClippyInfo(diagnostics = [])]
crate_info = rust_clippy_action.get_clippy_ready_crate_info(target, ctx)
Expand Down Expand Up @@ -74,6 +79,7 @@ def _dx_clippy_aspect_impl(target, ctx):

dx_clippy_aspect = aspect(
implementation = _dx_clippy_aspect_impl,
attr_aspects = ["upstream"],
doc = "Runs clippy with unused_crate_dependencies forced to a warning and keeps its JSON diagnostics.",
fragments = ["cpp"],
attrs = {
Expand Down
6 changes: 4 additions & 2 deletions tools/ci/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -741,10 +741,12 @@ rust_test(
"//ci/gitlab:dx.gitlab-ci.yml",
],
deps = [
"//cli/test_scratch:dx_test_scratch",
"//tools/testing:dx_testing",
"@crates//:yaml_serde",
],
] + select({
"@platforms//os:windows": [],
"//conditions:default": ["//cli/test_scratch:dx_test_scratch"],
}),
)

rust_test(
Expand Down
Loading
Loading