Skip to content

Commit

Permalink
fix sig check --fail-if-missing (#1917)
Browse files Browse the repository at this point in the history
  • Loading branch information
ctb authored Apr 1, 2022
1 parent 51ba09e commit d8102df
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/sourmash/sig/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
27 changes: 27 additions & 0 deletions tests/test_cmd_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down

0 comments on commit d8102df

Please sign in to comment.