Skip to content

Commit 13a325d

Browse files
committed
Fix lint issues in coverage tests
1 parent 984fafe commit 13a325d

18 files changed

Lines changed: 215 additions & 166 deletions

File tree

‎rust/bioscript-cli/src/package.rs‎

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -496,13 +496,13 @@ mod package_tests {
496496

497497
fn variant_manifest(name: &str) -> String {
498498
format!(
499-
r#"
499+
r"
500500
schema: bioscript:variant:1.0
501501
name: {name}
502502
gene: ABC
503503
identifiers:
504504
rsids: [rs1]
505-
"#
505+
"
506506
)
507507
}
508508

@@ -548,11 +548,11 @@ identifiers:
548548

549549
fs::write(
550550
dir.join("manifest.yaml"),
551-
r#"
551+
r"
552552
schema: bioscript:package:1.0
553553
name: Wrapped
554554
entrypoint: nested/panel.yaml
555-
"#,
555+
",
556556
)
557557
.unwrap();
558558
let descriptor = load_package_descriptor(&dir).unwrap();
@@ -561,20 +561,20 @@ entrypoint: nested/panel.yaml
561561

562562
fs::write(
563563
dir.join("manifest.yaml"),
564-
r#"
564+
r"
565565
schema: bioscript:package:1.0
566566
name: Missing Entrypoint
567-
"#,
567+
",
568568
)
569569
.unwrap();
570570
assert!(descriptor_err(&dir).contains("missing entrypoint"));
571571

572572
fs::write(
573573
dir.join("manifest.yaml"),
574-
r#"
574+
r"
575575
schema: bioscript:package:1.0
576576
entrypoint: ../escape.yaml
577-
"#,
577+
",
578578
)
579579
.unwrap();
580580
assert!(descriptor_err(&dir).contains("escapes"));
@@ -588,11 +588,11 @@ entrypoint: ../escape.yaml
588588
fs::remove_file(dir.join("manifest.yaml")).unwrap();
589589
fs::write(
590590
dir.join(LEGACY_PACKAGE_DESCRIPTOR),
591-
r#"
591+
r"
592592
schema: bioscript:package:1.0
593593
name: Legacy
594594
entrypoint: assay.yaml
595-
"#,
595+
",
596596
)
597597
.unwrap();
598598
let descriptor = load_package_descriptor(&dir).unwrap();
@@ -614,11 +614,11 @@ entrypoint: assay.yaml
614614
&[
615615
(
616616
"manifest.yaml",
617-
r#"
617+
r"
618618
schema: bioscript:package:1.0
619619
name: Test Package
620620
entrypoint: nested/variant.yaml
621-
"#,
621+
",
622622
),
623623
("nested/", ""),
624624
("nested/variant.yaml", &variant_manifest("Nested")),
@@ -683,10 +683,10 @@ entrypoint: nested/variant.yaml
683683
&missing_entrypoint,
684684
&[(
685685
"manifest.yaml",
686-
r#"
686+
r"
687687
schema: bioscript:package:1.0
688688
entrypoint: missing.yaml
689-
"#,
689+
",
690690
)],
691691
);
692692
assert!(import_err(&dir, &missing_entrypoint, Some(Path::new("missing-out")))
@@ -698,10 +698,10 @@ entrypoint: missing.yaml
698698
&[
699699
(
700700
"manifest.yaml",
701-
r#"
701+
r"
702702
schema: bioscript:package:1.0
703703
entrypoint: nested/custom.yaml
704-
"#,
704+
",
705705
),
706706
("nested/custom.yaml", "schema: custom:schema\nname: bad\n"),
707707
],
@@ -722,12 +722,12 @@ entrypoint: nested/custom.yaml
722722
fs::write(
723723
&release_path,
724724
format!(
725-
r#"
725+
r"
726726
schema: bioscript:package-release:1.0
727727
artifact:
728728
path: pkg.zip
729729
sha256: {digest}
730-
"#
730+
"
731731
),
732732
)
733733
.unwrap();
@@ -739,12 +739,12 @@ artifact:
739739

740740
fs::write(
741741
&release_path,
742-
r#"
742+
r"
743743
schema: bioscript:package-release:1.0
744744
artifact:
745745
path: pkg.zip
746746
sha256: bad
747-
"#,
747+
",
748748
)
749749
.unwrap();
750750
assert!(package_zip_from_release_manifest(&dir, &release_path, None)
@@ -777,12 +777,12 @@ artifact:
777777
fs::write(
778778
&release_path,
779779
format!(
780-
r#"
780+
r"
781781
schema: bioscript:package-release:1.0
782782
artifact:
783783
path: pkg.zip
784784
sha256: {digest}
785-
"#
785+
"
786786
),
787787
)
788788
.unwrap();
@@ -846,11 +846,11 @@ artifact:
846846
&[
847847
(
848848
"manifest.yaml",
849-
r#"
849+
r"
850850
schema: bioscript:package:1.0
851851
name: Import Command Package
852852
entrypoint: variant.yaml
853-
"#,
853+
",
854854
),
855855
("variant.yaml", &variant_manifest("Imported")),
856856
],

‎rust/bioscript-cli/src/report_observations.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ mod app_report_observation_tests {
137137
let path = write_variant_yaml(
138138
&dir,
139139
"variant.yaml",
140-
r#"
140+
r"
141141
schema: bioscript:variant:1.0
142142
name: Test variant
143143
gene: CYP2D6
@@ -149,7 +149,7 @@ evidence:
149149
references:
150150
- label: Primary
151151
url: https://www.ncbi.nlm.nih.gov/snp/rs123
152-
"#,
152+
",
153153
);
154154

155155
assert_eq!(variant_manifest_gene(&path).unwrap(), "CYP2D6");
@@ -170,13 +170,13 @@ evidence:
170170
let path = write_variant_yaml(
171171
&dir,
172172
"variant.yaml",
173-
r#"
173+
r"
174174
schema: bioscript:variant:1.0
175175
name: Test variant
176176
identifiers:
177177
rsids:
178178
- rs4242
179-
"#,
179+
",
180180
);
181181

182182
let source = variant_primary_source(&path).unwrap();

‎rust/bioscript-cli/src/report_review.rs‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ mod review_report_tests {
357357
let cases_path = dir.join("cases.yaml");
358358
fs::write(
359359
&cases_path,
360-
r#"
360+
r"
361361
cases:
362362
- id: c1
363363
label: First case
@@ -367,7 +367,7 @@ cases:
367367
- id: c2
368368
variants:
369369
rs3: C/T
370-
"#,
370+
",
371371
)
372372
.unwrap();
373373

@@ -395,22 +395,22 @@ cases:
395395
let dir = path.parent().unwrap().to_path_buf();
396396

397397
let missing_id = serde_yaml::from_str::<serde_yaml::Value>(
398-
r#"{label: no id, genotypes: {rs1: A/G}}"#,
398+
r"{label: no id, genotypes: {rs1: A/G}}",
399399
)
400400
.unwrap();
401401
assert!(review_case_err(&missing_id).contains("missing id"));
402402

403403
let missing_genotypes =
404-
serde_yaml::from_str::<serde_yaml::Value>(r#"{id: c1}"#).unwrap();
404+
serde_yaml::from_str::<serde_yaml::Value>(r"{id: c1}").unwrap();
405405
assert!(review_case_err(&missing_genotypes).contains("missing genotypes"));
406406

407407
let bad_key =
408-
serde_yaml::from_str::<serde_yaml::Value>(r#"{id: c1, genotypes: {1: A/G}}"#)
408+
serde_yaml::from_str::<serde_yaml::Value>(r"{id: c1, genotypes: {1: A/G}}")
409409
.unwrap();
410410
assert!(review_case_err(&bad_key).contains("non-string genotype key"));
411411

412412
let bad_value =
413-
serde_yaml::from_str::<serde_yaml::Value>(r#"{id: c1, genotypes: {rs1: [A, G]}}"#)
413+
serde_yaml::from_str::<serde_yaml::Value>(r"{id: c1, genotypes: {rs1: [A, G]}}")
414414
.unwrap();
415415
assert!(review_case_err(&bad_value).contains("must be string or null"));
416416

@@ -471,7 +471,7 @@ provenance:
471471
let cases = dir.join("cases.yaml");
472472
fs::write(
473473
&cases,
474-
r#"
474+
r"
475475
cases:
476476
- id: case1
477477
label: Case One
@@ -480,7 +480,7 @@ cases:
480480
- id: case2
481481
genotypes:
482482
rs1: null
483-
"#,
483+
",
484484
)
485485
.unwrap();
486486
let output = dir.join("out");

‎rust/bioscript-formats/src/genotype.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,8 @@ mod tests {
567567

568568
#[test]
569569
fn genotype_public_cache_wrappers_and_empty_store_cover_lookup_contracts() {
570-
let fallback = GenotypeStore::from_bytes("fallback.txt", b"rsid\tgenotype\nrs2\tCC\n")
571-
.unwrap();
570+
let fallback =
571+
GenotypeStore::from_bytes("fallback.txt", b"rsid\tgenotype\nrs2\tCC\n").unwrap();
572572
let cached_observation = VariantObservation {
573573
matched_rsid: Some("rs1".to_owned()),
574574
genotype: Some("AG".to_owned()),

‎rust/bioscript-formats/src/genotype/cram_backend/observation.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,8 @@ mod tests {
408408
let dir = fixtures_dir();
409409
let reference = dir.join("mini.fa");
410410
let repository = alignment::build_reference_repository(&reference).unwrap();
411-
let index = alignment::parse_crai_bytes(&fs::read(dir.join("mini.cram.crai")).unwrap())
412-
.unwrap();
411+
let index =
412+
alignment::parse_crai_bytes(&fs::read(dir.join("mini.cram.crai")).unwrap()).unwrap();
413413
alignment::build_cram_indexed_reader_from_reader(
414414
fs::File::open(dir.join("mini.cram")).unwrap(),
415415
index,

‎rust/bioscript-formats/src/genotype/cram_backend/store.rs‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,14 @@ mod tests {
273273

274274
#[test]
275275
fn cram_store_rejects_variants_without_coordinates_before_opening_cram() {
276-
let mut options = GenotypeLoadOptions::default();
277-
options.reference_file = Some(PathBuf::from("ref.fa"));
278-
options.reference_index = Some(PathBuf::from("ref.fa.fai"));
279-
options.input_index = Some(PathBuf::from("sample.cram.crai"));
280276
let store = CramBackend {
281277
path: PathBuf::from("sample.cram"),
282-
options,
278+
options: GenotypeLoadOptions {
279+
reference_file: Some(PathBuf::from("ref.fa")),
280+
reference_index: Some(PathBuf::from("ref.fa.fai")),
281+
input_index: Some(PathBuf::from("sample.cram.crai")),
282+
..GenotypeLoadOptions::default()
283+
},
283284
};
284285

285286
let err = store

‎rust/bioscript-formats/src/inspect/sex.rs‎

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ fn select_sex_detection_zip_entry<R: std::io::Read + std::io::Seek>(
455455
#[cfg(test)]
456456
mod tests {
457457
use super::*;
458+
use std::fmt::Write as _;
458459
use std::io::Write as _;
459460

460461
fn zip_bytes(entries: &[(&str, &str)]) -> Vec<u8> {
@@ -653,8 +654,9 @@ mod tests {
653654
assert_eq!(unsupported.sex, InferredSex::Unknown);
654655
assert_eq!(unsupported.method, "unsupported_source_type");
655656

656-
let result = infer_sex_from_bytes("sample.txt", text.as_bytes(), DetectedKind::GenotypeText)
657-
.unwrap();
657+
let result =
658+
infer_sex_from_bytes("sample.txt", text.as_bytes(), DetectedKind::GenotypeText)
659+
.unwrap();
658660
assert_eq!(result.method, "snp_array_x_y_fingerprint");
659661

660662
let archive = zip_bytes(&[
@@ -669,10 +671,14 @@ mod tests {
669671

670672
let err = infer_sex_from_zip_bytes(&archive, "missing.txt", DetectedKind::GenotypeText)
671673
.unwrap_err();
672-
assert!(err.to_string().contains("failed to open zip entry missing.txt"));
674+
assert!(
675+
err.to_string()
676+
.contains("failed to open zip entry missing.txt")
677+
);
673678

674-
let bad_zip = infer_sex_from_zip_bytes(b"not a zip", "sample.txt", DetectedKind::GenotypeText)
675-
.unwrap_err();
679+
let bad_zip =
680+
infer_sex_from_zip_bytes(b"not a zip", "sample.txt", DetectedKind::GenotypeText)
681+
.unwrap_err();
676682
assert!(bad_zip.to_string().contains("failed to read zip bytes"));
677683

678684
let mut zip = ZipArchive::new(Cursor::new(archive)).unwrap();
@@ -684,7 +690,10 @@ mod tests {
684690
let unsupported_zip = zip_bytes(&[("docs/readme.md", "ignored")]);
685691
let mut zip = ZipArchive::new(Cursor::new(unsupported_zip)).unwrap();
686692
let err = select_sex_detection_zip_entry(&mut zip).unwrap_err();
687-
assert!(err.to_string().contains("does not contain a supported sex detection input"));
693+
assert!(
694+
err.to_string()
695+
.contains("does not contain a supported sex detection input")
696+
);
688697
}
689698

690699
#[test]
@@ -694,18 +703,30 @@ mod tests {
694703
text.push_str("chrM\t1\t.\tC\tT\t.\tPASS\t.\tGT\t1\n");
695704
for idx in 0..70 {
696705
let gt = if idx % 2 == 0 { "0|1" } else { "0|0" };
697-
text.push_str(&format!(
698-
"23\t{}\t.\tC\tT\t.\tPASS\t.\tGT\t{gt}:99\n",
706+
let _ = writeln!(
707+
text,
708+
"23\t{}\t.\tC\tT\t.\tPASS\t.\tGT\t{gt}:99",
699709
3_000_000 + idx
700-
));
710+
);
701711
}
702712
text.push_str("24\t1\t.\tC\tT\t.\tPASS\t.\tGT\t.\n");
703713
text.push_str("chrX\t60000\t.\tC\tT\t.\tPASS\t.\tGT\t0/1\n");
704714
text.push_str("chrX\t155000000\t.\tC\tT\t.\tPASS\t.\tGT\t0/1\n");
705715

706-
let result = infer_sex_from_bytes("sample.vcf", text.as_bytes(), DetectedKind::Vcf).unwrap();
716+
let result =
717+
infer_sex_from_bytes("sample.vcf", text.as_bytes(), DetectedKind::Vcf).unwrap();
707718
assert_eq!(result.sex, InferredSex::Female);
708-
assert!(result.evidence.iter().any(|item| item == "x_non_par_sites=70"));
709-
assert!(result.evidence.iter().any(|item| item == "x_het_gt_sites=35"));
719+
assert!(
720+
result
721+
.evidence
722+
.iter()
723+
.any(|item| item == "x_non_par_sites=70")
724+
);
725+
assert!(
726+
result
727+
.evidence
728+
.iter()
729+
.any(|item| item == "x_het_gt_sites=35")
730+
);
710731
}
711732
}

0 commit comments

Comments
 (0)