luff 0.2.1

Print files with formatting
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
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
//! End-to-end tests for the WASM processing pipeline.
//!
//! These exercise the public API surface of `luff::wasm` as a library
//! consumer would use it — construction, configuration, processing,
//! and error handling. They run on the host target (not under a WASM
//! runtime) since the module is pure Rust with no platform deps.
//!
//! Requires the `wasm` feature.
#![cfg(feature = "wasm")]

use luff::wasm::{
    OutputFormat, ProcessResult, ProcessorOptions, VirtualFile, WasmError, WasmProcessor,
};

fn file(path: &str, content: &str) -> VirtualFile {
    VirtualFile::new(path, content).expect("test path should be valid")
}

fn default_processor() -> WasmProcessor {
    WasmProcessor::default()
}

fn sample_files() -> Vec<VirtualFile> {
    vec![
        file("src/main.rs", "fn main() {}\n"),
        file("src/lib.rs", "pub mod utils;\n"),
        file("README.md", "# My Project\n"),
        file("Cargo.toml", "[package]\nname = \"demo\"\n"),
    ]
}

#[test]
fn process_to_string_returns_output_and_metadata() {
    let proc = default_processor();
    let (output, result) = proc.process_to_string(sample_files()).unwrap();

    assert!(!output.is_empty());
    assert_eq!(result.files_processed, 4);
    assert_eq!(result.files_skipped, 0);
    assert_eq!(result.total_files(), 4);
    assert!(result.output_bytes > 0);
    assert_eq!(result.output_bytes, output.len());
}

#[test]
fn process_writes_to_external_sink() {
    let proc = default_processor();
    let mut sink = String::new();
    let result = proc.process(sample_files(), &mut sink).unwrap();

    assert_eq!(result.files_processed, 4);
    assert_eq!(sink.len(), result.output_bytes);
}

#[test]
fn process_and_process_to_string_produce_identical_output() {
    let proc = default_processor();
    let files = sample_files();

    let (string_output, string_result) = proc.process_to_string(files.clone()).unwrap();

    let mut sink_output = String::new();
    let sink_result = proc.process(files, &mut sink_output).unwrap();

    assert_eq!(string_output, sink_output);
    assert_eq!(string_result, sink_result);
}

#[test]
fn empty_input_produces_empty_output() {
    let proc = default_processor();
    let (output, result) = proc.process_to_string(Vec::<VirtualFile>::new()).unwrap();

    assert!(output.is_empty());
    assert_eq!(result.files_processed, 0);
    assert_eq!(result.files_skipped, 0);
    assert_eq!(result.output_bytes, 0);
}

#[test]
fn output_is_deterministic_across_input_orderings() {
    let proc = default_processor();

    let forward = sample_files();
    let mut reversed = sample_files();
    reversed.reverse();

    let (out_a, _) = proc.process_to_string(forward).unwrap();
    let (out_b, _) = proc.process_to_string(reversed).unwrap();

    assert_eq!(
        out_a, out_b,
        "output should be identical regardless of input order"
    );
}

#[test]
fn markdown_output_contains_fenced_code_blocks() {
    let proc = default_processor();
    let (output, _) = proc
        .process_to_string(vec![file("main.rs", "fn main() {}\n")])
        .unwrap();

    assert!(output.contains("```rs"));
    assert!(output.contains("```\n"));
    assert!(output.contains("## `main.rs`"));
}

#[test]
fn markdown_uses_extension_as_language_hint() {
    let proc = default_processor();
    let files = vec![
        file("app.py", "print('hello')\n"),
        file("style.css", "body {}\n"),
        file("Makefile", "all:\n"),
    ];
    let (output, _) = proc.process_to_string(files).unwrap();

    assert!(output.contains("```py"));
    assert!(output.contains("```css"));
    // Makefile has no extension → empty language hint.
    assert!(output.contains("```\nall:"));
}

#[test]
fn markdown_handles_content_with_backticks() {
    let proc = default_processor();
    let content = "```rust\nfn example() {}\n```\n";
    let (output, _) = proc
        .process_to_string(vec![file("nested.md", content)])
        .unwrap();

    // The outer fence must be longer than the inner triple backticks.
    assert!(
        output.contains("````"),
        "outer fence must escape inner triple backticks"
    );
    // Content should appear verbatim.
    assert!(output.contains(content));
}

#[test]
fn tree_output_shows_directory_hierarchy() {
    let opts = ProcessorOptions::builder()
        .output_format(OutputFormat::Tree)
        .root_label("project")
        .build()
        .unwrap();
    let proc = WasmProcessor::new(opts);

    let (output, result) = proc.process_to_string(sample_files()).unwrap();

    assert!(output.starts_with("project\n"));
    assert!(output.contains("src/"));
    assert!(output.contains("main.rs"));
    assert!(output.contains("lib.rs"));
    assert!(output.contains("README.md"));
    assert!(output.contains("Cargo.toml"));
    assert_eq!(result.files_processed, 4);
}

#[test]
fn tree_uses_box_drawing_characters() {
    let opts = ProcessorOptions::builder()
        .output_format(OutputFormat::Tree)
        .build()
        .unwrap();
    let proc = WasmProcessor::new(opts);

    let (output, _) = proc
        .process_to_string(vec![file("a.txt", ""), file("b.txt", "")])
        .unwrap();

    assert!(output.contains("├── ") || output.contains("└── "));
}

#[test]
fn dotfiles_excluded_by_default() {
    let proc = default_processor();
    let files = vec![
        file(".gitignore", "target/\n"),
        file("src/.env", "SECRET=x\n"),
        file("visible.rs", "fn v() {}\n"),
    ];
    let (output, result) = proc.process_to_string(files).unwrap();

    assert!(!output.contains(".gitignore"));
    assert!(!output.contains(".env"));
    assert!(output.contains("visible.rs"));
    assert_eq!(result.files_processed, 1);
    assert_eq!(result.files_skipped, 2);
}

#[test]
fn dotfiles_included_when_configured() {
    let opts = ProcessorOptions::builder()
        .include_dotfiles(true)
        .build()
        .unwrap();
    let proc = WasmProcessor::new(opts);

    let files = vec![
        file(".gitignore", "target/\n"),
        file("visible.rs", "fn v() {}\n"),
    ];
    let (output, result) = proc.process_to_string(files).unwrap();

    assert!(output.contains(".gitignore"));
    assert!(output.contains("visible.rs"));
    assert_eq!(result.files_processed, 2);
    assert_eq!(result.files_skipped, 0);
}

#[test]
fn extension_filtering_is_case_insensitive() {
    let opts = ProcessorOptions::builder()
        .ignore_extensions(["lock", "log"])
        .build()
        .unwrap();
    let proc = WasmProcessor::new(opts);

    let files = vec![
        file("Cargo.lock", ""),
        file("debug.LOG", ""),
        file("app.rs", "fn app() {}\n"),
    ];
    let (output, result) = proc.process_to_string(files).unwrap();

    assert!(!output.contains("Cargo.lock"));
    assert!(!output.contains("debug.LOG"));
    assert!(output.contains("app.rs"));
    assert_eq!(result.files_processed, 1);
    assert_eq!(result.files_skipped, 2);
}

#[test]
fn glob_filtering_excludes_matched_paths() {
    let opts = ProcessorOptions::builder()
        .ignore_globs(["**/target/**", "dist/**"])
        .include_dotfiles(true)
        .build()
        .unwrap();
    let proc = WasmProcessor::new(opts);

    let files = vec![
        file("src/main.rs", "fn main() {}\n"),
        file("target/debug/app", "binary"),
        file("dist/bundle.js", "compiled"),
    ];
    let (output, result) = proc.process_to_string(files).unwrap();

    assert!(output.contains("main.rs"));
    assert!(!output.contains("target"));
    assert!(!output.contains("dist"));
    assert_eq!(result.files_processed, 1);
    assert_eq!(result.files_skipped, 2);
}

#[test]
fn glob_matches_normalized_paths() {
    let opts = ProcessorOptions::builder()
        .ignore_globs(["src/**"])
        .include_dotfiles(true)
        .build()
        .unwrap();
    let proc = WasmProcessor::new(opts);

    // `./src/main.rs` should match `src/**` after normalization.
    let (output, result) = proc
        .process_to_string(vec![
            file("./src/main.rs", "fn main() {}\n"),
            file("README.md", "# Hello\n"),
        ])
        .unwrap();

    assert!(!output.contains("main.rs"));
    assert!(output.contains("README.md"));
    assert_eq!(result.files_processed, 1);
    assert_eq!(result.files_skipped, 1);
}

#[test]
fn max_files_truncates_output() {
    let opts = ProcessorOptions::builder().max_files(2).build().unwrap();
    let proc = WasmProcessor::new(opts);

    let (_, result) = proc.process_to_string(sample_files()).unwrap();

    // sample_files() has 4 non-dotfiles, no ignored extensions/globs.
    // Default options exclude dotfiles, but none of the sample files
    // are dotfiles → files_skipped == 0, files_truncated == 2.
    assert_eq!(result.files_processed, 2);
    assert_eq!(result.files_skipped, 0);
    assert_eq!(result.files_truncated, 2);
    assert_eq!(result.total_files(), 4);
}

#[test]
fn max_files_larger_than_input_is_noop() {
    let opts = ProcessorOptions::builder().max_files(100).build().unwrap();
    let proc = WasmProcessor::new(opts);

    let (_, result) = proc.process_to_string(sample_files()).unwrap();
    assert_eq!(result.files_processed, 4);
    assert_eq!(result.files_skipped, 0);
}

#[test]
fn max_output_bytes_triggers_error() {
    let opts = ProcessorOptions::builder()
        .max_output_bytes(10)
        .build()
        .unwrap();
    let proc = WasmProcessor::new(opts);

    let err = proc
        .process_to_string(vec![file(
            "big.txt",
            "this is definitely more than 10 bytes",
        )])
        .unwrap_err();

    match err {
        WasmError::OutputTooLarge { size, max } => {
            assert!(size > max);
            assert_eq!(max, 10);
        }
        other => panic!("expected OutputTooLarge, got: {other}"),
    }
}

#[test]
fn generous_max_output_bytes_allows_processing() {
    let opts = ProcessorOptions::builder()
        .max_output_bytes(1_000_000)
        .build()
        .unwrap();
    let proc = WasmProcessor::new(opts);

    let (_, result) = proc.process_to_string(sample_files()).unwrap();
    assert_eq!(result.files_processed, 4);
}

#[test]
fn processed_plus_skipped_plus_truncated_equals_total_input() {
    let opts = ProcessorOptions::builder()
        .ignore_extensions(["lock"])
        .max_files(2)
        .build()
        .unwrap();
    let proc = WasmProcessor::new(opts);

    let files = vec![
        file("a.rs", ""),
        file("b.lock", ""),
        file("c.rs", ""),
        file("d.rs", ""),
    ];
    let total = files.len();
    let (_, result) = proc.process_to_string(files).unwrap();

    assert_eq!(
        result.total_files(),
        total,
        "processed ({}) + skipped ({}) + truncated ({}) must equal total ({})",
        result.files_processed,
        result.files_skipped,
        result.files_truncated,
        total,
    );
    // b.lock filtered by extension → skipped.
    assert_eq!(result.files_skipped, 1);
    // 3 files pass filter, max_files=2 → 1 truncated.
    assert_eq!(result.files_truncated, 1);
    assert_eq!(result.files_processed, 2);
}

#[test]
fn virtual_file_rejects_empty_path() {
    assert!(VirtualFile::new("", "content").is_err());
}

#[test]
fn virtual_file_rejects_null_byte() {
    assert!(VirtualFile::new("src/\0bad.rs", "").is_err());
}

#[test]
fn virtual_file_rejects_path_traversal() {
    assert!(VirtualFile::new("../etc/passwd", "").is_err());
    assert!(VirtualFile::new("src/../../etc/shadow", "").is_err());
}

#[test]
fn virtual_file_allows_double_dot_in_filename() {
    assert!(VirtualFile::new("src/..config", "").is_ok());
}

#[test]
fn virtual_file_serde_round_trip() {
    let original = VirtualFile::new("src/lib.rs", "pub fn hello() {}\n").unwrap();
    let json = serde_json::to_string(&original).unwrap();
    let recovered: VirtualFile = serde_json::from_str(&json).unwrap();
    assert_eq!(original, recovered);
}

#[test]
fn virtual_file_deserialize_rejects_traversal() {
    let json = r#"{"path": "../etc/passwd", "content": "root:x:0:0"}"#;
    let result: Result<VirtualFile, _> = serde_json::from_str(json);
    assert!(result.is_err());
}

#[test]
fn builder_default_values() {
    let opts = ProcessorOptions::builder().build().unwrap();
    assert_eq!(opts.output_format(), OutputFormat::Markdown);
    assert!(!opts.include_dotfiles());
    assert!(opts.max_files().is_none());
    assert!(opts.max_output_bytes().is_none());
    assert!(opts.ignore_extensions().is_empty());
    assert!(opts.ignore_glob_strings().is_empty());
    assert_eq!(opts.root_label(), ".");
}

#[test]
fn builder_rejects_invalid_glob() {
    let result = ProcessorOptions::builder()
        .ignore_globs(["[unterminated"])
        .build();
    assert!(result.is_err());
}

#[test]
fn builder_glob_strings_round_trip() {
    let patterns = ["**/target/**", "dist/**"];
    let opts = ProcessorOptions::builder()
        .ignore_globs(patterns)
        .build()
        .unwrap();
    assert_eq!(opts.ignore_glob_strings(), &["**/target/**", "dist/**"]);
}

#[test]
fn process_result_default_is_zero() {
    let r = ProcessResult::default();
    assert_eq!(r.files_processed, 0);
    assert_eq!(r.files_skipped, 0);
    assert_eq!(r.output_bytes, 0);
    assert_eq!(r.total_files(), 0);
}

#[test]
fn process_result_is_copy() {
    let proc = default_processor();
    let (_, result) = proc.process_to_string(sample_files()).unwrap();
    let a = result;
    let b = result; // implicit copy
    assert_eq!(a, b);
}

#[test]
fn all_filters_compose() {
    let opts = ProcessorOptions::builder()
        .ignore_extensions(["lock"])
        .ignore_globs(["dist/**"])
        .include_dotfiles(false)
        .max_files(1)
        .build()
        .unwrap();
    let proc = WasmProcessor::new(opts);

    let files = vec![
        file(".hidden", "secret"),
        file("Cargo.lock", "lockfile"),
        file("dist/bundle.js", "compiled"),
        file("src/a.rs", "first"),
        file("src/b.rs", "second"),
    ];
    let total = files.len();
    let (output, result) = proc.process_to_string(files).unwrap();

    // .hidden → dotfile filter (skipped)
    // Cargo.lock → extension filter (skipped)
    // dist/bundle.js → glob filter (skipped)
    // src/a.rs, src/b.rs → pass filter, but max_files=1 → 1 truncated
    assert_eq!(result.files_skipped, 3);
    assert_eq!(result.files_truncated, 1);
    assert_eq!(result.files_processed, 1);
    assert_eq!(result.total_files(), total);
    assert!(output.contains("src/a.rs") || output.contains("src/b.rs"));
}

#[test]
fn output_format_display() {
    assert_eq!(OutputFormat::Markdown.to_string(), "markdown");
    assert_eq!(OutputFormat::Tree.to_string(), "tree");
}

#[test]
fn output_format_serde_round_trip() {
    for fmt in [OutputFormat::Markdown, OutputFormat::Tree] {
        let json = serde_json::to_string(&fmt).unwrap();
        let recovered: OutputFormat = serde_json::from_str(&json).unwrap();
        assert_eq!(fmt, recovered);
    }
}

mod prop {
    use super::*;
    use proptest::prelude::*;

    /// Strategy for a valid path component.
    fn path_component() -> impl Strategy<Value = String> {
        proptest::string::string_regex("[a-zA-Z_][a-zA-Z0-9_.\\-]{0,30}").unwrap()
    }

    /// Strategy for a valid relative path.
    fn valid_path() -> impl Strategy<Value = String> {
        proptest::collection::vec(path_component(), 1..=4).prop_map(|parts| parts.join("/"))
    }

    /// Strategy for a dotfile path.
    fn dotfile_path() -> impl Strategy<Value = String> {
        (
            proptest::collection::vec(path_component(), 0..=2),
            proptest::string::string_regex("\\.[a-zA-Z][a-zA-Z0-9_]{0,10}").unwrap(),
        )
            .prop_map(|(prefix, dot)| {
                let mut parts = prefix;
                parts.push(dot);
                parts.join("/")
            })
    }

    /// Strategy for file content.
    fn file_content() -> impl Strategy<Value = String> {
        proptest::string::string_regex("[\\s\\S]{0,200}").unwrap()
    }

    /// Strategy for a VirtualFile (either normal or dotfile).
    fn virtual_file() -> impl Strategy<Value = VirtualFile> {
        prop_oneof![
            (valid_path(), file_content()),
            (dotfile_path(), file_content()),
        ]
        .prop_map(|(path, content)| VirtualFile::new(&path, &content).unwrap())
    }

    /// Strategy for a Vec<VirtualFile>.
    fn virtual_files(max: usize) -> impl Strategy<Value = Vec<VirtualFile>> {
        proptest::collection::vec(virtual_file(), 0..=max)
    }

    /// Strategy for file extension (no leading dot).
    fn extension() -> impl Strategy<Value = String> {
        proptest::string::string_regex("[a-z]{1,6}").unwrap()
    }

    /// Strategy for a valid glob pattern.
    fn glob_pattern() -> impl Strategy<Value = String> {
        prop_oneof![
            Just("**/target/**".to_string()),
            Just("*.lock".to_string()),
            Just("dist/**".to_string()),
            extension().prop_map(|e| format!("*.{e}")),
        ]
    }

    /// Strategy for ProcessorOptions.
    fn processor_options() -> impl Strategy<Value = ProcessorOptions> {
        (
            proptest::bool::ANY,
            proptest::option::of(1..100usize),
            proptest::option::of(64..50_000usize),
            proptest::collection::vec(extension(), 0..=3),
            proptest::collection::vec(glob_pattern(), 0..=2),
            prop_oneof![Just(OutputFormat::Markdown), Just(OutputFormat::Tree)],
        )
            .prop_map(|(dotfiles, max_files, max_bytes, exts, globs, fmt)| {
                let mut b = ProcessorOptions::builder()
                    .output_format(fmt)
                    .ignore_extensions(exts)
                    .ignore_globs(globs)
                    .include_dotfiles(dotfiles);
                if let Some(m) = max_files {
                    b = b.max_files(m);
                }
                if let Some(m) = max_bytes {
                    b = b.max_output_bytes(m);
                }
                b.build().expect("generated globs are always valid")
            })
    }

    proptest! {
        /// Conservation invariant: processed + skipped + truncated == total.
        #[test]
        fn conservation_invariant(
            files in virtual_files(30),
            opts in processor_options(),
        ) {
            let total = files.len();
            let proc = WasmProcessor::new(opts);
            let mut sink = String::new();
            if let Ok(result) = proc.process(files, &mut sink) {
                prop_assert_eq!(
                    result.total_files(),
                    total,
                    "processed={} skipped={} truncated={} total={}",
                    result.files_processed,
                    result.files_skipped,
                    result.files_truncated,
                    total,
                );
            }
        }

        /// Output is deterministic regardless of input order.
        #[test]
        fn deterministic_output(
            files in virtual_files(20),
            opts in processor_options(),
        ) {
            let proc = WasmProcessor::new(opts);
            let mut shuffled = files.clone();
            shuffled.reverse();
            match (proc.process_to_string(files), proc.process_to_string(shuffled)) {
                (Ok((a, ra)), Ok((b, rb))) => {
                    prop_assert_eq!(a, b);
                    prop_assert_eq!(ra, rb);
                }
                (Err(_), Err(_)) => {}
                (a, b) => prop_assert!(false, "divergent: {a:?} vs {b:?}"),
            }
        }

        /// process() and process_to_string() produce identical output.
        #[test]
        fn process_matches_process_to_string(
            files in virtual_files(20),
            opts in processor_options(),
        ) {
            let proc = WasmProcessor::new(opts);
            let str_result = proc.process_to_string(files.clone());
            let mut sink = String::new();
            let sink_result = proc.process(files, &mut sink);
            match (str_result, sink_result) {
                (Ok((s, sr)), Ok(wr)) => {
                    prop_assert_eq!(s, sink);
                    prop_assert_eq!(sr, wr);
                }
                (Err(_), Err(_)) => {}
                (a, b) => prop_assert!(false, "divergent: {a:?} vs {b:?}"),
            }
        }

        /// max_files is always respected.
        #[test]
        fn max_files_always_respected(
            files in virtual_files(30),
            limit in 1..20usize,
        ) {
            let opts = ProcessorOptions::builder()
                .max_files(limit)
                .include_dotfiles(true)
                .build()
                .unwrap();
            let proc = WasmProcessor::new(opts);
            let mut sink = String::new();
            if let Ok(result) = proc.process(files, &mut sink) {
                prop_assert!(result.files_processed <= limit);
            }
        }

        /// With no filters, nothing is skipped.
        #[test]
        fn no_filters_means_no_skips(
            files in proptest::collection::vec(
                (valid_path(), file_content()).prop_map(|(p, c)| VirtualFile::new(&p, &c).unwrap()),
                0..=20,
            ),
        ) {
            let opts = ProcessorOptions::builder()
                .include_dotfiles(true)
                .build()
                .unwrap();
            let proc = WasmProcessor::new(opts);
            let mut sink = String::new();
            if let Ok(result) = proc.process(files, &mut sink) {
                prop_assert_eq!(result.files_skipped, 0);
                prop_assert_eq!(result.files_truncated, 0);
            }
        }

        /// output_bytes matches actual output length.
        #[test]
        fn output_bytes_matches_string_len(
            files in virtual_files(15),
            opts in processor_options(),
        ) {
            let proc = WasmProcessor::new(opts);
            if let Ok((output, result)) = proc.process_to_string(files) {
                prop_assert_eq!(result.output_bytes, output.len());
            }
        }

        /// VirtualFile::new always succeeds for paths from valid_path().
        #[test]
        fn valid_paths_always_accepted(
            path in valid_path(),
            content in file_content(),
        ) {
            prop_assert!(VirtualFile::new(&path, &content).is_ok());
        }

        /// Serde round-trip preserves VirtualFile identity.
        #[test]
        fn virtual_file_serde_identity(
            path in valid_path(),
            content in file_content(),
        ) {
            let original = VirtualFile::new(&path, &content).unwrap();
            let json = serde_json::to_string(&original).unwrap();
            let recovered: VirtualFile = serde_json::from_str(&json).unwrap();
            prop_assert_eq!(original, recovered);
        }
    }
}