grep用テスト#6
Closed
hpmy-dev wants to merge 1 commit into
Closed
Conversation
9a0fd2c to
1fbad90
Compare
1fbad90 to
bea6726
Compare
Owner
Author
|
#5 に取り込んだのでclose |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
grep 関連の機能リファクタリングとテスト強化
概要
CGrepAgent/CDlgGrepに対するリファクタリングと、Grep 機能の回帰テストを追加変更規模: 11 ファイル / テストコード約 2,500 行・138 テスト追加
関連
sakura-editor#2439
sakura-editor#2459
sakura-editor#1689
主な変更内容
CGrepAgent::DoGrep)FormatGrepResultLine/BuildGrepHeader/BuildGrepFooter(テスト容易化)CDlgGrepAPI 整理:DetermineDefaultExcludePatterns/BuildHwndFileToken/IsHwndFileToken/GetPackedGFileStringの*.*補完 / 自テキスト検索時の履歴非汚染リファクタリングの目的とテスト実行方法
プロダクトコードから HWND 非依存の純粋ロジックを
static関数として切り出すことで、エディタ全体を起動せずにユニットテストから直接検証可能にした。以下のコマンドで機能単位の確認ができる。CGrepAgent 切り出し関数
FormatGrepResultLine/BuildGrepHeader/BuildGrepFooter/CreateFolders/ChopYen/AddTail/OnBeforeCloseCDlgGrep 切り出し関数
DetermineDefaultExcludePatterns/BuildHwndFileToken/IsHwndFileToken/GetPackedGFileStringDoGrepFileWorker(既存 + 異常系)
全件
継続課題
test-grep-irregular.cpp ソース
IRR-16: 長大コマンドライン引数テスト(コメントアウト中)
DEBUG_TRACE→DebugOutW(バッファサイズ 16,000 文字)でバッファ溢れが発生し、Debug ビルドで::DebugBreak()によるクラッシュが起きる。-GKEY以外の全オプション引数(-GREPR、-GFILE、-GFOLDER等)に対してもCCommandLine::CheckCommandLineで文字数制限をかけた後に復活テストで発覚したので動確は出来てそう。
変更ファイル一覧
sakura_core/agent/CGrepAgent.hSGrepFileTask、static ヘルパ 3 関数、DoGrepFileWorker/DoGrepTreeEnumerate宣言sakura_core/agent/CGrepAgent.cppDoGrepFileWorker/DoGrepTreeEnumerate実装sakura_core/dlg/CDlgGrep.hDetermineDefaultExcludePatterns/BuildHwndFileToken/IsHwndFileToken宣言sakura_core/dlg/CDlgGrep.cppGetPackedGFileString*.*補完、履歴汚染防止sakura_core/tests1.vcxprojsakura_core/tests1.vcxproj.filterssrc/test/cpp/tests1/test-ccommandline.cppsrc/test/cpp/tests1/test-cdlggrep.cppsrc/test/cpp/tests1/test-cgrepagent-flow.cppsrc/test/cpp/tests1/test-grep-irregular.cppsrc/test/cpp/tests1/test-grep.cppテスト一覧(ソース出現順)
📂
test-grep.cpp(41 テスト)既存相当(20 テスト)
GrepSearchEngineLiteralSearchCaseSensitivityGrepRealFileTestJapaneseLiteralSearchAcrossMixedEncodingsGrepRealFileTestRegexCompileAndMatchCGrepEnumKeysParseRegexExcludePatternCGrepEnumKeysParseFileAndFolderKeysWithDefaultsCGrepEnumKeysAbsolutePathInSearchKeyIsRejectedCCodeMediatorAutoDetectBomAndDefaultCodeGrepRealFileTestEnumerateFiles_FiltersByExtensionAndExcludeKeyGrepRealFileTestEnumerateFolders_ExcludesByHashKeyGrepRealFileTestEnumerateFiles_SubfolderRecursionGrepRealFileTestFileWorker_BasicLiteralHitsInUtf8FileGrepRealFileTestFileWorker_CaseSensitivityIsRespectedGrepRealFileTestFileWorker_RegexHitsInUtf8FileGrepRealFileTestFileWorker_JapaneseAcrossEncodingsGrepRealFileTestFileWorker_32000LinesIsSearchableGrepRealFileTestFileWorker_CancelTerminatesScanGrepRealFileTestMultiThread_HitCountMatchesSingleThreadGrepRealFileTestMultiThread_StressNoDeadlockAcrossRepeatsGrepRealFileTestRegexExclude_AppliedToEnumeratedFilesGrepRealFileTestRegexExclude_InvalidPatternFailsToCompilePhase 2-B 追加(21 テスト)
SplitPattern_SemicolonSeparator;区切りSplitPattern_SpaceSeparatorSplitPattern_CommaSeparator,区切りSplitPattern_MixedSeparatorsSplitPattern_ConsecutiveSeparatorsSplitPattern_TrailingSeparatorSplitPattern_QuotesRemovedSplitPattern_QuotesInMiddleSetFileKeys_EmptyInputFallsBackToWildcard*.*SetFileKeys_WildcardInPathReturns1SetFileKeys_AbsolutePathInSearchReturns2SetFileKeys_ExcludeFolderHashRelative#相対除外SetFileKeys_ExcludeFolderHashAbsolute#絶対除外SetFileKeys_RegexExcludeNoValidation!バリデーションスキップSetFileKeys_DuplicateKeyDeduplicatedAddExceptFile_RelativePathAddExceptFile_AbsolutePathAddExceptFolder_DefaultPatternAddExceptFile_HashIsNotSpecial#非特殊GetExcludeFiles_MergesAllThreeArraysGetExcludeFolders_MergesRelAndAbs📂
test-cgrepagent-flow.cpp(20 テスト)GA-01FormatGrepResultLine_NormalStyle1_ProducesPathLineColContentGA-02FormatGrepResultLine_WzStyle2_FileGroupedGA-03FormatGrepResultLine_ResultOnlyStyle3_NoPathGA-04FormatGrepResultLine_OutputLineType0_OnlyMatchPartGA-05FormatGrepResultLine_OutputLineType1_FullLineGA-06FormatGrepResultLine_OutputLineType2_NegativeLineGA-07BuildGrepHeader_BasicShapeGA-08BuildGrepHeader_WithRegexOption_IncludesMarkerGA-09BuildGrepHeader_WithCaseSensitive_IncludesMarkerGA-10BuildGrepFooter_ZeroHits_HasZeroMessageGA-11BuildGrepFooter_PositiveHits_HasCountGA-12CreateFolders_SemicolonSeparated_SplitsCorrectly;分割GA-13CreateFolders_QuotedSemicolon_PreservesAsOne;GA-14CreateFolders_LongFileName_ResolvedGA-15ChopYen_LastBackslashRemoved\除去GA-16ChopYen_NoTrailingYen_UnchangedGA-17ChopYen_RootPath_AlsoTrimmedC:\→C:GA-18AddTail_StdoutMode_WritesToStdoutGA-19OnBeforeClose_DuringGrepReturnsInterruptGA-20OnBeforeClose_NotRunningReturnsContinue📂
test-cdlggrep.cpp(26 テスト / DG-19 欠番)DG-01DefaultMemberValues_ConstructorDG-02DefaultExcludePatterns_ConstantsDG-03GetPackedGFileString_NoExclusionsDG-04GetPackedGFileString_WithExcludeFolders#付加DG-05GetPackedGFileString_WithExcludeFiles!付加・*.*補完DG-06GetPackedGFileString_EscapeBangInExcludeFolder!エスケープDG-07GetPackedGFileString_EscapeHashInExcludeFolder#エスケープDG-08GetPackedGFileString_EscapeSpaceInExcludeFolderDG-09GetPackedGFileString_EscapeSemicolonInExcludeFolderDG-10GetPackedGFileString_CombinedAllExclusionsDG-11RoundTrip_GuiToCliToEnumKeysDG-12DetermineDefaultExcludePatterns_EmptyHistorySetsDefaultsDG-13DetermineDefaultExcludePatterns_NonEmptyHistoryUsesHistoryTopDG-14DetermineDefaultExcludePatterns_AlreadySetSkippedDG-15BuildHwndFileToken_FormatDG-16BuildHwndFileToken_NullHwndDG-17IsHwndFileToken_PositiveCasesDG-18IsHwndFileToken_NegativeCasesDG-20DoModalCancelImmediately_NoExceptionDG-21DoModalOK_WithValidInputs_ReturnsOKDG-22DoModalOK_EmptyFolder_FallsBackToCurrentDirDG-23DoModalOK_InvalidRegex_StillReturnsOKDG-24DoModalOK_FolderWithSemicolon_IsSplitBySeparatorDG-25DoModalOK_MultipleFolders_AllResolvedDG-26DoModalOK_HistoryRecordedExceptFromThisTextDG-27DoModalOK_FromThisText_DoesNotPolluteHistory📂
test-grep-irregular.cpp(46 テスト + IRR-16 コメントアウト 1)CGrepEnumKeys 境界(IRR-01〜IRR-08 + IRR-07b)
IRR-01SetFileKeys_EmptyString_DefaultsAppliedIRR-02SetFileKeys_OnlyWhitespace_DefaultsAppliedIRR-03SetFileKeys_OnlyExcludePatterns_DefaultSearchAppliedIRR-04SetFileKeys_VeryLongPattern_4096CharsIRR-05SetFileKeys_ManyDuplicates_DeduplicatedTo1IRR-06SetFileKeys_NullByteInMiddle_TruncatesAtNullIRR-07SetFileKeys_BangPrefixWithInvalidRegex_RegisteredButFailsLaterIRR-07bRegex_InvalidExcludePatternFailsToCompileIRR-08SetFileKeys_PathWithDriveLetterInMiddle_TreatedAsRelativeCCommandLine 境界(IRR-09〜IRR-19)
IRR-09CommandLine_GKEY_EmptyValue_IgnoredIRR-10CommandLine_GREPR_EmptyValue_AcceptedAsEmptyIRR-11CommandLine_GFOLDER_NonExistentPath_StoredAsIsIRR-12CommandLine_GCODE_OutOfRange_StoredAsIsIRR-13CommandLine_GCODE_Negative_StoredAsIsIRR-14CommandLine_GKEY_WithControlChars_StoredIRR-15CommandLine_GKEY_WithSurrogatePairIRR-16(コメントアウト・継続課題)CommandLine_TotalLength_NearWindowsLimit_32767CharsIRR-17CommandLine_ResponseFileWithGrepArgs_ParsedIRR-18CommandLine_DoubleDashStopsOptionParsingIRR-19CommandLine_ColonSeparatorEquivalentToEqual除外正規表現コンパイル検証(IRR-20〜IRR-25)
IRR-20ExcludeFile_ValidRegex_CompilesSuccessfullyIRR-21ExcludeFile_GlobPattern_CompileFailsIRR-22ExcludeFile_EmptyPattern_NoCompileNoErrorIRR-23ExcludeFile_MixedRegexAndGlob_FirstSucceedsSecondFailsIRR-24ExcludeFile_MixedGlobAndRegex_OrderReversedIRR-25ExcludeFile_AllValidRegex_AllCompileSuccessfullyDoGrepFileWorker 境界(IRR-26〜IRR-34)
IRR-26FileWorker_ZeroByteFile_NoHitIRR-27FileWorker_OnlyBomFile_NoHitIRR-28FileWorker_InvalidUtf8Sequence_DoesNotCrashIRR-29FileWorker_FileWithoutFinalNewline_LastLineSearchedIRR-30FileWorker_MixedLineEndings_LineNumbersConsistentIRR-31FileWorker_VeryLongSingleLine_64KCharsIRR-32FileWorker_LockedFile_ReturnsErrorIRR-33FileWorker_ReadOnlyAttribute_SearchedIRR-34FileWorker_HiddenSystemFile_SearchedCCodeMediator 境界(IRR-35〜IRR-38)
IRR-35CodeMediator_ShortFile_FallbackToDefaultIRR-36CodeMediator_SjisSecondByteInAsciiRange_NotMisdetectedIRR-37CodeMediator_PriorCesu8Flag_TogglesDetectionIRR-38CodeMediator_Utf32LeBom_NotMisdetectedAsUtf16正規表現・並列処理(IRR-39〜IRR-46)
IRR-39Regex_EmptyPattern_CompileFailsOrEmptyMatchIRR-40Regex_DotStar_DoesNotHangIRR-41Regex_CatastrophicBacktracking_TimeoutGuardedIRR-42MultiThread_CancelImmediatelyAfterStartIRR-43MultiThread_FileDeletedMidScanIRR-44MultiThread_ZeroExcludeRegexes_EquivalentIRR-45MultiThread_100ExcludeRegexes_AllAppliedIRR-46MultiThread_RepeatedStartCancel_50Iterations📂
test-ccommandline.cppPhase 2-A(25 テスト追加)-GOPT 複合・境界値(9 テスト)
ParseGrepOpt_MultipleFlagsCombinedParseGrepOpt_AllKnownFlagsOnParseGrepOpt_DuplicateSameFlagParseGrepOpt_StyleLastWinsParseGrepOpt_OutputLineTypeLastWinsParseGrepOpt_UnknownCharIgnoredParseGrepOpt_EmptyValueRejectedParseGrepOpt_MixedDigitsAndLetters-GREPR / -GKEY 連動(4 テスト)
ParseGrepReplace_GREPRSetsReplaceFlagParseGrepReplace_OnlyGKEYDoesNotSetReplaceFlagParseGrepReplace_GREPREmptyAllowedParseGrepReplace_ClipboardPasteFlagCase-insensitive・引数順序(5 テスト)
ParseGrep_OptionNameLowerCaseParseGrep_OptionNameMixedCaseParseGrep_ArgumentOrderInvariantParseGrep_GrepModeAndGrepDlgBothSpecifiedParseGrep_GKeyDuplicate_LaterWins-GKEY / -GFILE / -GFOLDER 値境界(8 テスト)
ParseGrepKey_SingleChar_BoundaryParseGrepKey_VeryLongValue_4096CharsParseGrepKey_JapaneseCharsAndEmojiParseGrepKey_ContainsEqualsInValueParseGrepKey_EscapedDoubleQuotesParseGrepFile_RegexExcludePatternFromPR2449ParseGrepFolder_RelativePathParseGrepFolder_UncPathテスト数サマリー
test-grep.cpptest-cgrepagent-flow.cpptest-cdlggrep.cpptest-grep-irregular.cpptest-ccommandline.cppPhase 2-Aライセンス
Zlib License (SPDX-License-Identifier: Zlib)