provenant-cli 1.0.2

Fast Rust scanner for licenses, copyrights, package metadata, SBOMs, and provenance data.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
// SPDX-FileCopyrightText: nexB Inc. and others
// ScanCode is a trademark of nexB Inc.
// SPDX-FileCopyrightText: Provenant contributors
// SPDX-License-Identifier: Apache-2.0
// Derived from ScanCode Toolkit (Apache-2.0); modified. See NOTICE.

use super::*;
use crate::models::LineNumber;

#[test]
fn test_multiline_two_copyrights_adjacent_lines() {
    let input = "\tCopyright 1988, 1989 by Carnegie Mellon University\n\tCopyright 1989\tTGV, Incorporated\n";
    let (c, h, _a) = detect_copyrights_from_text(input);
    assert!(
        c.iter().any(|cr| cr.copyright.contains("Carnegie Mellon")),
        "Should detect CMU copyright"
    );
    assert!(
        c.iter().any(|cr| cr.copyright.contains("TGV")),
        "Should detect TGV copyright, got: {:?}",
        c
    );
    assert!(
        h.iter().any(|hr| hr.holder.contains("TGV")),
        "Should detect TGV holder, got: {:?}",
        h
    );
}

#[test]
fn test_multiline_copyright_after_created_line() {
    let input = "// Created: Sun Feb  9 10:06:01 2003 by faith@dict.org\n// Copyright 2003, 2004 Rickard E. Faith (faith@dict.org)\n";
    let (c, h, _a) = detect_copyrights_from_text(input);
    assert!(
        c.iter().any(|cr| cr.copyright.contains("Rickard")),
        "Should detect Faith copyright, got: {:?}",
        c
    );
    assert!(
        h.iter().any(|hr| hr.holder.contains("Faith")),
        "Should detect Faith holder, got: {:?}",
        h
    );
}

#[test]
fn test_multiline_obfuscated_email_continuation_recovers_clean_holder() {
    // The holder's obfuscated-email contact wraps onto the next comment line.
    // The full `(chris at kohlhoff dot com)` span must be folded back so the
    // holder is recovered cleanly instead of leaking the first email token.
    for input in [
        "//\n// Copyright (c) 2003-2008 Christopher M. Kohlhoff\n// (chris at kohlhoff dot com)\n//\n// Distributed under the Boost Software License, Version 1.0.\n//\n",
        "/*\n * Copyright (c) 2003-2008 Christopher M. Kohlhoff\n * (chris at kohlhoff dot com)\n */\n",
        "# Copyright (c) 2003-2008 Christopher M. Kohlhoff\n# (chris at kohlhoff dot com)\n",
    ] {
        let (_c, h, _a) = detect_copyrights_from_text(input);
        let holders: Vec<&str> = h.iter().map(|hr| hr.holder.as_str()).collect();
        assert!(
            holders.contains(&"Christopher M. Kohlhoff"),
            "Expected clean holder, got: {holders:?}"
        );
        assert!(
            !holders.iter().any(|hr| hr.contains("chris")),
            "Holder must not leak the email token `chris`, got: {holders:?}"
        );
    }
}

#[test]
fn test_multiline_obfuscated_email_continuation_leaves_non_email_parens_alone() {
    // A following parenthetical that is not an obfuscated email must not be
    // folded into the holder line.
    let input = "// Copyright (c) 2020 Acme Inc\n// (see LICENSE for details)\n";
    let (_c, h, _a) = detect_copyrights_from_text(input);
    let holders: Vec<&str> = h.iter().map(|hr| hr.holder.as_str()).collect();
    assert!(
        holders.contains(&"Acme Inc"),
        "Expected Acme Inc holder, got: {holders:?}"
    );
    assert!(
        !holders.iter().any(|hr| hr.contains("LICENSE")),
        "Holder must not absorb the non-email parenthetical, got: {holders:?}"
    );
}

#[test]
fn test_multiline_copyrighted_by_href_links_merges_trailing_copyright_clause() {
    let input = "copyrighted by <A\nHREF=\"http://www.dre.vanderbilt.edu/~schmidt/\">Douglas C. Schmidt</A>\nand his <a\nHREF=\"http://www.cs.wustl.edu/~schmidt/ACE-members.html\">research\ngroup</a> at <A HREF=\"http://www.wustl.edu/\">Washington\nUniversity</A>, <A HREF=\"http://www.uci.edu\">University of California,\nIrvine</A>, and <A HREF=\"http://www.vanderbilt.edu\">Vanderbilt\nUniversity</A>, Copyright (c) 1993-2009, all rights reserved.";
    let (c, _h, _a) = detect_copyrights_from_text(input);
    let expected = "copyrighted by http://www.dre.vanderbilt.edu/~schmidt/ Douglas C. Schmidt and his http://www.cs.wustl.edu/~schmidt/ACE-members.html research group at http://www.wustl.edu/ Washington University, http://www.uci.edu University of California, Irvine, and http://www.vanderbilt.edu Vanderbilt University, Copyright (c) 1993-2009";
    assert!(
        c.iter().any(|cr| cr.copyright == expected),
        "Expected merged copyrighted-by href copyright, got: {:?}",
        c
    );
    let merged = c.iter().find(|cr| cr.copyright == expected).unwrap();
    assert!(
        merged.end_line > merged.start_line,
        "Expected merged span to extend across lines, got: {:?}",
        merged
    );
}

#[test]
fn test_html_anchor_copyright_url_multiline_span_preserved() {
    let input = "<a href=\"https://example.com/path\">\ncopyright\n</a>";
    let (c, h, _a) = detect_copyrights_from_text(input);

    let cd = c
        .iter()
        .find(|cr| cr.copyright == "copyright https://example.com/path")
        .unwrap();
    assert_eq!(
        (cd.start_line, cd.end_line),
        (LineNumber::new(1).unwrap(), LineNumber::new(3).unwrap()),
        "copyrights: {c:?}"
    );

    let hd = h
        .iter()
        .find(|hr| hr.holder == "https://example.com/path")
        .unwrap();
    assert_eq!(
        (hd.start_line, hd.end_line),
        (LineNumber::new(1).unwrap(), LineNumber::new(3).unwrap()),
        "holders: {h:?}"
    );
}

#[test]
fn test_split_multiline_holder_list_with_emails() {
    let input = "(c) 1999                Terrehon Bowden <terrehon@pacbell.net>\n                        Bodo Bauer <bb@ricochet.net>\n";

    let (_copyrights, holders, _authors) = detect_copyrights_from_text(input);

    assert!(
        holders.iter().any(|h| h.holder == "Terrehon Bowden"),
        "holders: {holders:?}"
    );
    assert!(
        holders.iter().any(|h| h.holder == "Bodo Bauer"),
        "holders: {holders:?}"
    );
    assert!(
        !holders
            .iter()
            .any(|h| h.holder == "Terrehon Bowden Bodo Bauer"),
        "holders: {holders:?}"
    );
}

#[test]
fn test_boost_style_multiline_holder_continuation_after_year_first_line() {
    let input = "// Copyright (c) 2019 Peter Dimov (pdimov at gmail dot com),\n\
//                    Vinnie Falco (vinnie.falco@gmail.com)\n\
// Copyright (c) 2020 Krystian Stasiowski (sdkrystian@gmail.com)\n";

    let (copyrights, holders, _authors) = detect_copyrights_from_text(input);

    assert!(
        copyrights.iter().any(|c| {
            c.start_line == LineNumber::ONE
                && c.end_line == LineNumber::new(2).unwrap()
                && c.copyright.contains("Peter Dimov")
                && c.copyright.contains("Vinnie Falco")
        }),
        "copyrights: {copyrights:?}"
    );

    assert!(
        holders.iter().any(|h| {
            h.start_line == LineNumber::ONE
                && h.end_line == LineNumber::new(2).unwrap()
                && h.holder.contains("Peter Dimov")
                && h.holder.contains("Vinnie Falco")
        }),
        "holders: {holders:?}"
    );
}

#[test]
fn test_year_first_multiline_holder_repair_does_not_absorb_multiline_holder_lists() {
    let input = "Copyright (c) 1995, 1996, 1997 Francis.Dupont@inria.fr, INRIA Rocquencourt,\n\
Alain.Durand@imag.fr, IMAG,\n\
Jean-Luc.Richier@imag.fr, IMAG-LSR.\n";

    let (copyrights, _holders, _authors) = detect_copyrights_from_text(input);

    assert!(
        copyrights.iter().any(|c| {
            c.start_line == LineNumber::ONE
                && c.end_line == LineNumber::ONE
                && c.copyright == "Copyright (c) 1995, 1996, 1997 Francis.Dupont@inria.fr, INRIA"
        }),
        "copyrights: {copyrights:?}"
    );

    assert!(
        !copyrights
            .iter()
            .any(|c| c.copyright.contains("Rocquencourt") || c.copyright.contains("Alain.Durand")),
        "copyrights: {copyrights:?}"
    );
}

#[test]
fn test_extend_copyright_with_following_all_rights_reserved_line() {
    let input = "Copyright 2010-2015 Mike Bostock\nAll rights reserved.";
    let (copyrights, holders, _authors) = detect_copyrights_from_text(input);

    assert!(
        copyrights
            .iter()
            .any(|c| c.copyright == "Copyright 2010-2015 Mike Bostock"),
        "copyrights: {copyrights:?}"
    );
    assert!(
        copyrights
            .iter()
            .any(|c| c.start_line == LineNumber::ONE && c.end_line == LineNumber::new(2).unwrap()),
        "copyrights: {copyrights:?}"
    );
    assert!(
        holders.iter().any(|h| h.holder == "Mike Bostock"),
        "holders: {holders:?}"
    );
}

#[test]
fn test_drop_url_embedded_suffix_copyright_and_holder_variants() {
    let input =
        "/* Copyright (c) 2020 Example Corp. See url(\"https://dummy-url-for-test.com\") */";
    let (copyrights, holders, _authors) = detect_copyrights_from_text(input);

    assert!(
        copyrights
            .iter()
            .any(|c| c.copyright == "Copyright (c) 2020 Example Corp."),
        "copyrights: {copyrights:?}"
    );
    assert!(
        !copyrights
            .iter()
            .any(|c| c.copyright.contains("See url") || c.copyright.contains("https://")),
        "copyrights: {copyrights:?}"
    );
    assert!(
        holders.iter().any(|h| h.holder == "Example Corp."),
        "holders: {holders:?}"
    );
    assert!(
        !holders
            .iter()
            .any(|h| h.holder.contains("See url") || h.holder.contains("http")),
        "holders: {holders:?}"
    );
}

#[test]
fn test_add_missing_holder_from_preceding_name_line_for_year_only_copyright() {
    let input = "Author:  David Beazley (http://www.dabeaz.com)\nCopyright (C) 2007\n";
    let (copyrights, holders, _authors) = detect_copyrights_from_text(input);

    assert!(
        copyrights
            .iter()
            .any(|c| c.copyright == "David Beazley, Copyright (c) 2007"),
        "copyrights: {copyrights:?}"
    );
    assert!(
        holders.iter().any(|h| h.holder == "David Beazley"),
        "holders: {holders:?}"
    );
}

#[test]
fn test_merge_year_only_copyright_with_following_contact_line_and_url() {
    let input = "// copyright (c) 2005\n// troy d. straszheim <troy@resophonic.com>\n// http://www.resophonic.com\n";
    let (copyrights, holders, _authors) = detect_copyrights_from_text(input);

    assert!(
        copyrights.iter().any(|c| {
            c.start_line == LineNumber::ONE
                && c.end_line == LineNumber::new(3).unwrap()
                && c.copyright
                    == "copyright (c) 2005 troy d. straszheim <troy@resophonic.com> http://www.resophonic.com"
        }),
        "copyrights: {copyrights:?}"
    );
    assert!(
        !copyrights.iter().any(|c| c.start_line == LineNumber::ONE
            && c.end_line == LineNumber::ONE
            && c.copyright == "copyright (c) 2005"),
        "copyrights: {copyrights:?}"
    );
    assert!(
        holders.iter().any(|h| h.holder == "troy d. straszheim"),
        "holders: {holders:?}"
    );
}

#[test]
fn test_descriptive_line_does_not_expand_year_only_copyright_holder() {
    let input = "Tru64 audio module for SDL (Simple DirectMedia Layer)\nCopyright (C) 2003\n";
    let (copyrights, holders, _authors) = detect_copyrights_from_text(input);

    assert!(
        copyrights
            .iter()
            .any(|c| c.copyright == "Copyright (c) 2003"),
        "copyrights: {copyrights:?}"
    );
    assert!(
        !copyrights
            .iter()
            .any(|c| c.copyright == "Tru64 audio module for SDL, Copyright (c) 2003"),
        "copyrights: {copyrights:?}"
    );
    assert!(
        holders
            .iter()
            .all(|h| h.holder != "Tru64 audio module for SDL"),
        "holders: {holders:?}"
    );
}

#[test]
fn test_drop_trademarked_materials_prose_false_positive_copyrights_and_holders() {
    let input = "SPDX-FileCopyrightText: <years> Univention GmbH\n\nBinary versions of this program provided by Univention to you as well\nas other copyrighted, protected or trademarked materials like Logos,\ngraphics, fonts, specific documentations and configurations,\ncryptographic keys etc. are subject to a license agreement between you\nand Univention and not subject to the AGPL-3.0-only.\n";
    let (copyrights, holders, _authors) = detect_copyrights_from_text(input);

    assert!(
        copyrights
            .iter()
            .all(|c| !c.copyright.contains("protected or trademarked materials")),
        "copyrights: {copyrights:?}"
    );
    assert!(
        holders
            .iter()
            .all(|h| !h.holder.contains("protected or trademarked materials")),
        "holders: {holders:?}"
    );
    assert!(
        holders.iter().any(|h| h.holder == "Univention GmbH"),
        "holders: {holders:?}"
    );
}

#[test]
fn test_drop_code_and_cc0_prose_false_positive_copyrights() {
    let input = concat!(
        "String generateCode(CodeSample sample, { File? output, String? copyright, String? description, bool includeAssumptions = false, }) {\n",
        "  return '${addCopyright ? '{{copyright}}\\n\\n' : ''}$template'.replaceAllMapped(RegExp(r'{{([^}]+)}}'), (Match match) {\n",
        "    final String name = match[1]!;\n",
        "  });\n",
        "}\n\n",
        "the copyright and related or neighboring legal rights previously held by the Affirmer in the Work, to the greatest extent permitted by law.\n",
    );
    let (copyrights, _holders, _authors) = detect_copyrights_from_text(input);

    assert!(
        copyrights
            .iter()
            .all(|c| !c.copyright.contains("String? description, bool")),
        "copyrights: {copyrights:?}"
    );
    assert!(
        copyrights
            .iter()
            .all(|c| !c.copyright.contains("replaceAllMapped") && !c.copyright.contains("RegExp")),
        "copyrights: {copyrights:?}"
    );
    assert!(
        copyrights
            .iter()
            .all(|c| !c.copyright.contains("related or neighboring legal rights")),
        "copyrights: {copyrights:?}"
    );
}

// A copyright followed by a ruler line and unrelated text must not bleed across
// the divider into that text (issue #973).
#[test]
fn test_copyright_does_not_bleed_across_ruler_line() {
    let input = "\t(c) Brendan O'Donoghue, Stanford University, 2012\n----------------------------------\nLin-sys: sparse-indirect, nnz in A = 24\n";
    let (copyrights, holders, _a) = detect_copyrights_from_text(input);
    assert_eq!(
        copyrights
            .iter()
            .map(|c| c.copyright.as_str())
            .collect::<Vec<_>>(),
        vec!["(c) Brendan O'Donoghue, Stanford University, 2012"],
        "copyright should stop at the ruler"
    );
    assert_eq!(
        holders
            .iter()
            .map(|h| h.holder.as_str())
            .collect::<Vec<_>>(),
        vec!["Brendan O'Donoghue, Stanford University"],
        "holder should not absorb the line after the ruler"
    );
}

// Two copyright/ruler pairs in one group: both notices stay clean, neither
// bleeds across its divider (issue #973, multi-ruler case).
#[test]
fn test_copyright_does_not_bleed_across_multiple_rulers() {
    let input = "\t(c) Alice Example, Example Inc, 2010\n----------------------------------\nnoise line one\n----------------------------------\n\t(c) Bob Sample, Sample Corp, 2020\n----------------------------------\nnoise line two\n";
    let (copyrights, _h, _a) = detect_copyrights_from_text(input);
    assert!(
        copyrights
            .iter()
            .any(|c| c.copyright == "(c) Alice Example, Example Inc, 2010"),
        "copyrights: {copyrights:?}"
    );
    assert!(
        copyrights
            .iter()
            .any(|c| c.copyright == "(c) Bob Sample, Sample Corp, 2020"),
        "copyrights: {copyrights:?}"
    );
    assert!(
        copyrights.iter().all(|c| !c.copyright.contains("noise")),
        "no copyright should absorb a post-ruler line: {copyrights:?}"
    );
}

// An `SPDX-License-Identifier:` line is a license declaration and must never be
// absorbed into a copyright statement or holder, even when the preceding
// copyright line ends with a trailing `, et al.` that would otherwise drive a
// multiline continuation into it (and into any code/prose after it).
#[test]
fn test_et_al_copyright_does_not_bleed_into_following_spdx_license_identifier() {
    let input = "# Copyright (c) 2020 Acme Corp, et al.\n# SPDX-License-Identifier: Apache-2.0\nprint(\"hi\")\n";
    let (copyrights, holders, _a) = detect_copyrights_from_text(input);

    assert_eq!(
        copyrights
            .iter()
            .map(|c| c.copyright.as_str())
            .collect::<Vec<_>>(),
        vec!["Copyright (c) 2020 Acme Corp, et al."],
        "et al. is preserved with its source period; SPDX/code never bleed in: {copyrights:?}"
    );
    assert_eq!(
        holders
            .iter()
            .map(|h| h.holder.as_str())
            .collect::<Vec<_>>(),
        vec!["Acme Corp"],
        "holder is the party name only, without et al or SPDX bleed: {holders:?}"
    );
    assert!(
        copyrights
            .iter()
            .all(|c| !c.copyright.to_ascii_uppercase().contains("SPDX")
                && !c.copyright.contains("print")),
        "no SPDX/code bleed: {copyrights:?}"
    );
}

// A blank comment line already breaks the group between the copyright and the
// SPDX tag, but the trailing `, et al.` must still be preserved on the
// copyright statement (previously it was dropped entirely).
#[test]
fn test_et_al_preserved_with_blank_comment_line_before_spdx() {
    let input = "/*\n * Copyright (c) Jane Doe, <jane@example.com>, et al.\n *\n * SPDX-License-Identifier: MIT\n */\n";
    let (copyrights, holders, _a) = detect_copyrights_from_text(input);

    assert!(
        copyrights
            .iter()
            .any(|c| c.copyright == "Copyright (c) Jane Doe, <jane@example.com>, et al."),
        "et al. must be preserved (with its source period) on the copyright statement: {copyrights:?}"
    );
    assert!(
        copyrights
            .iter()
            .all(|c| !c.copyright.to_ascii_uppercase().contains("SPDX")),
        "no SPDX bleed: {copyrights:?}"
    );
    assert!(
        holders.iter().any(|h| h.holder == "Jane Doe"),
        "holder is the party name only: {holders:?}"
    );
}

// The `and others` additional-holders marker behaves like `et al`: preserved on
// the copyright statement, no SPDX/code bleed, and never duplicated into a
// second same-span copyright that differs only by the marker.
#[test]
fn test_and_others_preserved_without_spdx_bleed_or_duplicate() {
    let input = "/* Copyright (c) 2020 Acme Corp and others\n * SPDX-License-Identifier: MIT\n */\nint x;\n";
    let (copyrights, _h, _a) = detect_copyrights_from_text(input);

    assert_eq!(
        copyrights
            .iter()
            .map(|c| c.copyright.as_str())
            .collect::<Vec<_>>(),
        vec!["Copyright (c) 2020 Acme Corp and others"],
        "and others is preserved exactly once, no SPDX/code bleed: {copyrights:?}"
    );
}

// The additional-holders marker is a hard terminator for forward absorption:
// once the walk reaches `et al.`, it must not pull in any token from a later
// line, whatever that line holds (here: a plain code line). This is the general
// rule — not tied to the SPDX-License-Identifier token specifically.
#[test]
fn test_et_al_does_not_absorb_following_code_line() {
    let input =
        "/* Copyright (C) Jane Doe, et al. */\nint compute_something(void) { return 42; }\n";
    let (copyrights, holders, _a) = detect_copyrights_from_text(input);

    assert_eq!(
        copyrights
            .iter()
            .map(|c| c.copyright.as_str())
            .collect::<Vec<_>>(),
        vec!["Copyright (c) Jane Doe, et al."],
        "et al. preserved with its source period; no code from the next line absorbed: {copyrights:?}"
    );
    assert_eq!(
        holders
            .iter()
            .map(|h| h.holder.as_str())
            .collect::<Vec<_>>(),
        vec!["Jane Doe"],
        "holder is the party name only, without et al or code bleed: {holders:?}"
    );
}

// The marker terminates forward absorption in its BARE (period-less) form too:
// `et al` without a period tokenizes differently (`al` as a plain noun) but
// must still stop the walk before a following code line. The marker stays bare
// (no period is force-added), and no code leaks into the copyright or holder.
#[test]
fn test_bare_et_al_does_not_absorb_following_code_line() {
    let input = "# Copyright (c) 2020 Acme Corp, et al\nx=1\n";
    let (copyrights, holders, _a) = detect_copyrights_from_text(input);

    assert_eq!(
        copyrights
            .iter()
            .map(|c| c.copyright.as_str())
            .collect::<Vec<_>>(),
        vec!["Copyright (c) 2020 Acme Corp, et al"],
        "bare et al preserved (no period added); no next-line code absorbed: {copyrights:?}"
    );
    assert_eq!(
        holders
            .iter()
            .map(|h| h.holder.as_str())
            .collect::<Vec<_>>(),
        vec!["Acme Corp"],
        "holder is the party name only, without et al or code bleed: {holders:?}"
    );
}

// The marker's trailing period is source-faithful: a source `et al.` keeps its
// period (the Latin abbreviation's period is intrinsic, like `Inc.`/`Ltd.`),
// while a bare source `et al` stays bare. No period is ever force-added.
#[test]
fn test_et_al_trailing_period_is_source_faithful() {
    let (with_period, _h, _a) =
        detect_copyrights_from_text("Copyright (c) 2020 Acme Corp, et al.\n");
    assert_eq!(
        with_period
            .iter()
            .map(|c| c.copyright.as_str())
            .collect::<Vec<_>>(),
        vec!["Copyright (c) 2020 Acme Corp, et al."],
        "source period must be preserved: {with_period:?}"
    );

    let (bare, _h, _a) = detect_copyrights_from_text("Copyright (c) 2020 Acme Corp, et al\n");
    assert_eq!(
        bare.iter()
            .map(|c| c.copyright.as_str())
            .collect::<Vec<_>>(),
        vec!["Copyright (c) 2020 Acme Corp, et al"],
        "bare marker must stay bare (no period force-added): {bare:?}"
    );
}