stamail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit c2460281a13ca908cfdfc97b4ee1e91ce43f5085
parent 6a7276de9b85b30b80dfdc1fce5f0d9013f6c19f
Author: Nathaniel Chappelle <nathaniel@chappelle.dev>
Date:   Sat, 24 Jan 2026 16:42:16 -0800

big ol test case generation script

Diffstat:
AREADME | 4++++
Msetup-mock-maildir | 321++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 314 insertions(+), 11 deletions(-)

diff --git a/README b/README @@ -0,0 +1,4 @@ +Eventually wrap with a mb2md option script. + +notmuch show --format=json '*' | ./stamail + diff --git a/setup-mock-maildir b/setup-mock-maildir @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# mock-maildir.sh +# mock-maildir.sh - Create realistic test mailing list MAILDIR="./test" mkdir -p "$MAILDIR"/{cur,new,tmp} @@ -10,7 +10,9 @@ create_msg() { local subject="$2" local from="$3" local inreplyto="$4" - local date="$5" + local references="$5" + local date="$6" + local body="$7" local filename="$MAILDIR/cur/$msgid:2,S" @@ -20,19 +22,316 @@ Date: $date Subject: $subject Message-ID: <$msgid@example.com> ${inreplyto:+In-Reply-To: <$inreplyto@example.com>} -${inreplyto:+References: <$inreplyto@example.com>} +${references:+References: $references} -This is a test message about $subject. +${body:-This is a test message about $subject.} EOF } -# Create a simple thread -create_msg "msg001" "Feature proposal" "alice@example.com" "" "Mon, 20 Jan 2025 10:00:00 +0000" -create_msg "msg002" "Re: Feature proposal" "bob@example.com" "msg001" "Mon, 20 Jan 2025 11:00:00 +0000" -create_msg "msg003" "Re: Feature proposal" "charlie@example.com" "msg002" "Mon, 20 Jan 2025 12:00:00 +0000" +echo "Creating realistic mailing list archive..." -# Another thread -create_msg "msg004" "Bug report" "david@example.com" "" "Tue, 21 Jan 2025 09:00:00 +0000" -create_msg "msg005" "Re: Bug report" "alice@example.com" "msg004" "Tue, 21 Jan 2025 10:00:00 +0000" +# Thread 1: Deep nested discussion (7 levels) +create_msg "001" "RFC: New authentication system" "alice@example.com" "" "" \ + "Mon, 13 Jan 2025 09:00:00 +0000" \ + "Hi all, +I'd like to propose a new authentication system for our project. +The current system has several limitations: + +1. No support for 2FA +2. Sessions expire too quickly +3. Password reset flow is clunky + +Thoughts? + +--Alice" + +create_msg "002" "Re: RFC: New authentication system" "bob@example.com" "001" \ + "<001@example.com>" "Mon, 13 Jan 2025 10:30:00 +0000" \ + "Great idea! I've been wanting 2FA support. + +What library are you thinking of using? + +--Bob" + +create_msg "003" "Re: RFC: New authentication system" "alice@example.com" "002" \ + "<001@example.com> <002@example.com>" "Mon, 13 Jan 2025 11:15:00 +0000" \ + "I was looking at libauth or maybe rolling our own with TOTP. + +What do you think about WebAuthn support? + +--Alice" + +create_msg "004" "Re: RFC: New authentication system" "charlie@example.com" "003" \ + "<001@example.com> <002@example.com> <003@example.com>" "Mon, 13 Jan 2025 14:20:00 +0000" \ + "WebAuthn would be excellent! We should definitely support it. + +However, I'm concerned about backwards compatibility. + +--Charlie" + +create_msg "005" "Re: RFC: New authentication system" "alice@example.com" "004" \ + "<001@example.com> <002@example.com> <003@example.com> <004@example.com>" \ + "Mon, 13 Jan 2025 15:00:00 +0000" \ + "Good point. We can support both old and new systems during migration. + +I'll draft a detailed proposal by end of week. + +--Alice" + +create_msg "006" "Re: RFC: New authentication system" "david@example.com" "005" \ + "<001@example.com> <002@example.com> <003@example.com> <004@example.com> <005@example.com>" \ + "Mon, 13 Jan 2025 16:45:00 +0000" \ + "Looking forward to it! + +One more thing - what about rate limiting? + +--David" + +create_msg "007" "Re: RFC: New authentication system" "alice@example.com" "006" \ + "<001@example.com> <002@example.com> <003@example.com> <004@example.com> <005@example.com> <006@example.com>" \ + "Tue, 14 Jan 2025 09:00:00 +0000" \ + "Yes, rate limiting is in the plan. I'll include it in the RFC. + +--Alice" + +# Thread 1 - Branch: Side discussion from msg002 +create_msg "008" "Re: RFC: New authentication system" "eve@example.com" "002" \ + "<001@example.com> <002@example.com>" "Mon, 13 Jan 2025 12:00:00 +0000" \ + "Has anyone considered OAuth2 integration? + +This could be useful for third-party apps. + +--Eve" + +create_msg "009" "Re: RFC: New authentication system" "frank@example.com" "008" \ + "<001@example.com> <002@example.com> <008@example.com>" "Mon, 13 Jan 2025 13:30:00 +0000" \ + "OAuth2 is a great idea! We should support it. + +I can help with the implementation if needed. + +--Frank" + +# Thread 2: Bug report with multiple parallel replies +create_msg "010" "[BUG] Segfault in parser module" "grace@example.com" "" "" \ + "Tue, 14 Jan 2025 10:00:00 +0000" \ + "Steps to reproduce: +1. Load large JSON file (>10MB) +2. Call parse_json() +3. Observe crash + +Stack trace attached. + +--Grace" + +create_msg "011" "Re: [BUG] Segfault in parser module" "henry@example.com" "010" \ + "<010@example.com>" "Tue, 14 Jan 2025 10:30:00 +0000" \ + "I can reproduce this. Looking into it now. + +--Henry" + +create_msg "012" "Re: [BUG] Segfault in parser module" "alice@example.com" "010" \ + "<010@example.com>" "Tue, 14 Jan 2025 10:45:00 +0000" \ + "This looks like a buffer overflow in the string handling code. + +I'll submit a patch. + +--Alice" + +create_msg "013" "Re: [BUG] Segfault in parser module" "henry@example.com" "012" \ + "<010@example.com> <012@example.com>" "Tue, 14 Jan 2025 11:00:00 +0000" \ + "You're right! The fix should be in realloc() logic. + +--Henry" + +# Thread 3: Orphaned reply (broken thread) +create_msg "014" "Re: Non-existent parent message" "iris@example.com" "999" \ + "<999@example.com>" "Wed, 15 Jan 2025 09:00:00 +0000" \ + "I agree with the points made earlier. + +This is an orphaned message - parent doesn't exist! + +--Iris" + +# Thread 4: Very wide thread (many direct replies to root) +create_msg "015" "Release 2.0 planning" "alice@example.com" "" "" \ + "Wed, 15 Jan 2025 14:00:00 +0000" \ + "Let's plan the 2.0 release. What features should we include? + +--Alice" + +create_msg "016" "Re: Release 2.0 planning" "bob@example.com" "015" \ + "<015@example.com>" "Wed, 15 Jan 2025 14:15:00 +0000" \ + "Performance improvements!" + +create_msg "017" "Re: Release 2.0 planning" "charlie@example.com" "015" \ + "<015@example.com>" "Wed, 15 Jan 2025 14:20:00 +0000" \ + "Better documentation" + +create_msg "018" "Re: Release 2.0 planning" "david@example.com" "015" \ + "<015@example.com>" "Wed, 15 Jan 2025 14:25:00 +0000" \ + "Plugin system" + +create_msg "019" "Re: Release 2.0 planning" "eve@example.com" "015" \ + "<015@example.com>" "Wed, 15 Jan 2025 14:30:00 +0000" \ + "Multi-language support" + +create_msg "020" "Re: Release 2.0 planning" "frank@example.com" "015" \ + "<015@example.com>" "Wed, 15 Jan 2025 14:35:00 +0000" \ + "Better test coverage" + +create_msg "021" "Re: Release 2.0 planning" "grace@example.com" "015" \ + "<015@example.com>" "Wed, 15 Jan 2025 14:40:00 +0000" \ + "CI/CD improvements" + +# Thread 5: Multiple references (complex threading) +create_msg "022" "Documentation update needed" "henry@example.com" "" "" \ + "Thu, 16 Jan 2025 09:00:00 +0000" \ + "Our docs are out of date. We should update them." + +create_msg "023" "Re: Documentation update needed" "iris@example.com" "022" \ + "<022@example.com>" "Thu, 16 Jan 2025 09:30:00 +0000" \ + "I can help with this." + +create_msg "024" "Re: Documentation update needed" "alice@example.com" "023" \ + "<022@example.com> <023@example.com>" "Thu, 16 Jan 2025 10:00:00 +0000" \ + "Great! Let's split the work." + +create_msg "025" "Re: Documentation update needed" "bob@example.com" "022" \ + "<022@example.com>" "Thu, 16 Jan 2025 10:15:00 +0000" \ + "I'll review the API docs section." + +# Thread 6: Long-running discussion (spans multiple days) +create_msg "026" "Code style guidelines" "charlie@example.com" "" "" \ + "Fri, 17 Jan 2025 10:00:00 +0000" \ + "Should we adopt a specific code style?" + +create_msg "027" "Re: Code style guidelines" "david@example.com" "026" \ + "<026@example.com>" "Fri, 17 Jan 2025 11:00:00 +0000" \ + "Yes! I suggest KNF style." + +create_msg "028" "Re: Code style guidelines" "eve@example.com" "027" \ + "<026@example.com> <027@example.com>" "Sat, 18 Jan 2025 09:00:00 +0000" \ + "KNF is good but maybe too strict?" + +create_msg "029" "Re: Code style guidelines" "charlie@example.com" "028" \ + "<026@example.com> <027@example.com> <028@example.com>" \ + "Mon, 20 Jan 2025 08:00:00 +0000" \ + "Let's vote on it next meeting." + +# Thread 7: Announcement (no replies) +create_msg "030" "[ANNOUNCE] Server maintenance scheduled" "admin@example.com" "" "" \ + "Mon, 20 Jan 2025 15:00:00 +0000" \ + "The server will be down for maintenance on Saturday. + +Expected downtime: 2 hours + +--Admin" + +# Thread 8: Patch submission with review +create_msg "031" "[PATCH] Fix memory leak in cache" "frank@example.com" "" "" \ + "Tue, 21 Jan 2025 09:00:00 +0000" \ + "This patch fixes a memory leak in the cache module. + +Tested on Linux and BSD. + +--Frank" + +create_msg "032" "Re: [PATCH] Fix memory leak in cache" "grace@example.com" "031" \ + "<031@example.com>" "Tue, 21 Jan 2025 09:30:00 +0000" \ + "Looks good! One minor comment inline..." + +create_msg "033" "Re: [PATCH] Fix memory leak in cache" "frank@example.com" "032" \ + "<031@example.com> <032@example.com>" "Tue, 21 Jan 2025 10:00:00 +0000" \ + "Updated patch attached. Thanks for the review!" + +create_msg "034" "Re: [PATCH] Fix memory leak in cache" "alice@example.com" "033" \ + "<031@example.com> <032@example.com> <033@example.com>" \ + "Tue, 21 Jan 2025 10:30:00 +0000" \ + "Merged! Thanks Frank." + +# Thread 9: Question with multiple answer branches +create_msg "035" "How to build on Windows?" "newbie@example.com" "" "" \ + "Wed, 22 Jan 2025 10:00:00 +0000" \ + "I'm trying to build this on Windows but getting errors. + +Any help appreciated! + +--Newbie" + +create_msg "036" "Re: How to build on Windows?" "henry@example.com" "035" \ + "<035@example.com>" "Wed, 22 Jan 2025 10:30:00 +0000" \ + "Use MinGW. Here's what I did..." + +create_msg "037" "Re: How to build on Windows?" "iris@example.com" "035" \ + "<035@example.com>" "Wed, 22 Jan 2025 10:45:00 +0000" \ + "Visual Studio works too. Check the wiki." + +create_msg "038" "Re: How to build on Windows?" "newbie@example.com" "036" \ + "<035@example.com> <036@example.com>" "Wed, 22 Jan 2025 11:00:00 +0000" \ + "MinGW worked! Thanks!" + +# Thread 10: Out-of-order messages (replies before parent in time) +create_msg "040" "Re: Future discussion" "bob@example.com" "039" \ + "<039@example.com>" "Thu, 23 Jan 2025 09:00:00 +0000" \ + "This is a reply that appears before its parent in the maildir!" + +create_msg "039" "Future discussion" "alice@example.com" "" "" \ + "Thu, 23 Jan 2025 10:00:00 +0000" \ + "This message was sent after the reply (simulating delayed delivery)." + +# Thread 11: Very deep thread (10 levels) +create_msg "041" "Deep thread test" "alice@example.com" "" "" \ + "Fri, 24 Jan 2025 09:00:00 +0000" "Level 0" + +create_msg "042" "Re: Deep thread test" "bob@example.com" "041" \ + "<041@example.com>" "Fri, 24 Jan 2025 09:10:00 +0000" "Level 1" + +create_msg "043" "Re: Deep thread test" "charlie@example.com" "042" \ + "<041@example.com> <042@example.com>" "Fri, 24 Jan 2025 09:20:00 +0000" "Level 2" + +create_msg "044" "Re: Deep thread test" "david@example.com" "043" \ + "<041@example.com> <042@example.com> <043@example.com>" \ + "Fri, 24 Jan 2025 09:30:00 +0000" "Level 3" + +create_msg "045" "Re: Deep thread test" "eve@example.com" "044" \ + "<041@example.com> <042@example.com> <043@example.com> <044@example.com>" \ + "Fri, 24 Jan 2025 09:40:00 +0000" "Level 4" + +create_msg "046" "Re: Deep thread test" "frank@example.com" "045" \ + "<041@example.com> <042@example.com> <043@example.com> <044@example.com> <045@example.com>" \ + "Fri, 24 Jan 2025 09:50:00 +0000" "Level 5" + +create_msg "047" "Re: Deep thread test" "grace@example.com" "046" \ + "<041@example.com> <042@example.com> <043@example.com> <044@example.com> <045@example.com> <046@example.com>" \ + "Fri, 24 Jan 2025 10:00:00 +0000" "Level 6" + +create_msg "048" "Re: Deep thread test" "henry@example.com" "047" \ + "<041@example.com> <042@example.com> <043@example.com> <044@example.com> <045@example.com> <046@example.com> <047@example.com>" \ + "Fri, 24 Jan 2025 10:10:00 +0000" "Level 7" + +create_msg "049" "Re: Deep thread test" "iris@example.com" "048" \ + "<041@example.com> <042@example.com> <043@example.com> <044@example.com> <045@example.com> <046@example.com> <047@example.com> <048@example.com>" \ + "Fri, 24 Jan 2025 10:20:00 +0000" "Level 8" + +create_msg "050" "Re: Deep thread test" "alice@example.com" "049" \ + "<041@example.com> <042@example.com> <043@example.com> <044@example.com> <045@example.com> <046@example.com> <047@example.com> <048@example.com> <049@example.com>" \ + "Fri, 24 Jan 2025 10:30:00 +0000" "Level 9" + +echo "" echo "Test maildir created at $MAILDIR" +echo "Messages created: 50" +echo "" +echo "Thread scenarios included:" +echo " - Deep nested thread (7+ levels)" +echo " - Branching threads (parallel replies)" +echo " - Orphaned replies (missing parent)" +echo " - Wide threads (many direct replies)" +echo " - Complex References chains" +echo " - Out-of-order delivery" +echo " - Standalone announcements" +echo " - Very deep thread (10 levels)" +echo "" +echo "To index with notmuch:" +echo " notmuch new --maildir=$MAILDIR" +echo " notmuch show --format=json '*' | ./stamail -o archive"