diff --git a/src/sourmash/sig/__main__.py b/src/sourmash/sig/__main__.py index 9ef2a4e4e2..fa46a7d209 100644 --- a/src/sourmash/sig/__main__.py +++ b/src/sourmash/sig/__main__.py @@ -1377,7 +1377,7 @@ def check(args): elif args.save_manifest_matching: notify(f"(not saving matching manifest to '{args.save_manifest_matching}' because no matches)") - if args.fail_if_missing: + if args.fail_if_missing and n_missing: error("** ERROR: missing values, and --fail-if-missing requested. Exiting.") sys.exit(-1) diff --git a/tests/test_cmd_signature.py b/tests/test_cmd_signature.py index 35601eea9a..b09d05076b 100644 --- a/tests/test_cmd_signature.py +++ b/tests/test_cmd_signature.py @@ -4219,6 +4219,33 @@ def test_sig_check_1(runtmp): assert 31 in ksizes +def test_sig_check_1_nofail(runtmp): + # basic check functionality with --fail-if-missing + sigfiles = glob.glob(utils.get_test_data('gather/GCF*.sig')) + picklist = utils.get_test_data('gather/salmonella-picklist.csv') + + runtmp.sourmash('sig', 'check', *sigfiles, + "--picklist", f"{picklist}::manifest", + "-m", "mf.csv", '--fail-if-missing') + + out_mf = runtmp.output('mf.csv') + assert os.path.exists(out_mf) + + # all should match. + with open(out_mf, newline='') as fp: + mf = CollectionManifest.load_from_csv(fp) + assert len(mf) == 24 + + idx = sourmash.load_file_as_index(out_mf) + siglist = list(idx.signatures()) + assert len(siglist) == 24 + ksizes = set([ ss.minhash.ksize for ss in siglist ]) + assert len(ksizes) == 3 + assert 11 in ksizes + assert 21 in ksizes + assert 31 in ksizes + + def test_sig_check_1_no_picklist(runtmp): # basic check functionality sigfiles = glob.glob(utils.get_test_data('gather/GCF*.sig'))