Skip to content

Commit

Permalink
Test for #428
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcefrog committed Jan 5, 2025
1 parent 9189c0c commit 5d117ba
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions testdata/alternate_registry/.cargo_test/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[registries]
my-registry = { index = "https://crates.io/" }
7 changes: 7 additions & 0 deletions testdata/alternate_registry/Cargo_test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "cargo-mutants-testdata-alternate-registry"
publish = false
edition = "2021"

[dependencies]
mutants = { version = "1", registry = "my-registry" }
5 changes: 5 additions & 0 deletions testdata/alternate_registry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# `alternate_registry`

<https://github.com/sourcefrog/cargo-mutants/issues/428>

This tree has Cargo configured to read from an alternative registry to crates.io.
1 change: 1 addition & 0 deletions testdata/alternate_registry/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}
22 changes: 22 additions & 0 deletions tests/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,25 @@ fn no_mutants_in_tree_everything_skipped() {
.stdout(predicate::str::is_empty())
.success();
}

#[test]
fn list_mutants_with_alternate_registry() {
// For https://github.com/sourcefrog/cargo-mutants/issues/428

// This tree has a non-default registry that ends up just pointing back to crates.io, but under another name.
//
// Without running cargo metadata properly this will fail.
//
// The tree doesn't actually generate any mutants.
//
// To reproduce the failure it's important that we *don't* run from the tree's directory.
let tmp = copy_of_testdata("alternate_registry");
run()
.arg("mutants")
.arg("--list")
.arg("--dir")
.arg(tmp.path())
.assert()
.stdout("")
.success();
}
7 changes: 7 additions & 0 deletions tests/snapshots/list__list_mutants_in_all_trees_as_json.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: tests/list.rs
expression: buf
snapshot_kind: text
---
## testdata/already_failing_doctests

Expand Down Expand Up @@ -293,6 +294,12 @@ expression: buf
]
```

## testdata/alternate_registry

```json
[]
```

## testdata/cdylib

```json
Expand Down
6 changes: 6 additions & 0 deletions tests/snapshots/list__list_mutants_in_all_trees_as_text.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: tests/list.rs
expression: buf
snapshot_kind: text
---
## testdata/already_failing_doctests

Expand All @@ -26,6 +27,11 @@ src/lib.rs:4:11: replace *= with /= in factorial
src/lib.rs:12:5: replace infinite_loop with ()
```

## testdata/alternate_registry

```
```

## testdata/cdylib

```
Expand Down

0 comments on commit 5d117ba

Please sign in to comment.