Skip to content

Cannot run tests using cargo_pup_lint_config #41

@tomas-janecka-tfs

Description

@tomas-janecka-tfs

Description

I am trying to run architecture tests using cargo_pup_lint_config library and cargo test . No matter what I am presented with the error:

error: no bin target named `cargo-pup` in default-run packages
thread '<thread_name>' (37792) panicked at C:\Users\<user>\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\cargo_pup_lint_config-0.1.7\src\lint_builder_ext.rs:136:13:
cargo pup checks failed!

Preconditions

  • Folder cargo_pup_lint_config-0.1.7 is removed from C:\Users\<user>\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f so it rebuilds before running test

Steps to reproduce issue

  1. cargo new project
  2. cargo add cargo_pup_lint_config --dev
  3. ui.rs
use std::fs;

pub fn ui_stuff() {
    let file_path = "config.toml";
    let _ = fs::read_to_string(file_path).map_err(|e| format!("Failed to read config file: {}", e));
}
  1. main.rs
mod ui;

fn main() {
    ui::ui_stuff();
}
  1. architecture_tests.rs
use cargo_pup_lint_config::{LintBuilder, LintBuilderExt, ModuleLintExt, Severity};

#[test]
fn ui_does_not_depend_on_fs() {
    let mut builder = LintBuilder::new();

    builder
        .module_lint()
        .lint_named("ui_does_not_depend_on_fs")
        .matching(|m| m.module(".*ui.*"))
        .with_severity(Severity::Error)
        .restrict_imports(
            None,
            Some(vec![".*fs.*".to_string()])
        )
        .build();

    builder
        .assert_lints(None)
        .expect("UI modules should not depend on filesystem modules");
}
  1. cargo test

Expected behavior

error: Use of module 'std::fs' is denied
 --> src\ui.rs:1:1
  |
1 | use std::fs;
  | ^^^^^^^^^^^^
  |
  = help: Remove this import
  = note: Applied by cargo-pup rule 'ui_does_not_depend_on_fs'.
  = note: `#[deny(module_restrict_imports)]` on by default

Actual behavior

error: no bin target named `cargo-pup` in default-run packages
thread '<thread_name>' (37792) panicked at C:\Users\<user>\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\cargo_pup_lint_config-0.1.7\src\lint_builder_ext.rs:136:13:
cargo pup checks failed!

Environment

  • Windows 11
  • rustc -Vv
rustc 1.94.1 (e408947bf 2026-03-25)
binary: rustc
commit-hash: e408947bfd200af42db322daf0fadfe7e26d3bd1
commit-date: 2026-03-25
host: x86_64-pc-windows-msvc
release: 1.94.1
LLVM version: 21.1.8
  • cargo_pup_lint_config = "0.1.7"

Proposed fix

I used AI to diagnose and find the error. It proposed this to fix the error and it works.
lint_builder_ext.rs - https://github.com/DataDog/cargo-pup/blob/main/cargo_pup_lint_config/src/lint_builder_ext.rs

// ...
// Line 225
// Before
Ok(current_dir)
// After
anyhow::bail!("Failed to find cargo-pup workspace root");
// ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions