FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

New option to use the test executable's path as working directory by tschroff · Pull Request #5 · DelphiCodeCoverage/DelphiCodeCoverage · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .markdown  (1) .pas  (3) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 1 addition & 0 deletions README.markdown
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
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ unfinished form on my harddrive for more than a year. Finally it slipped out.
<tr><td><code>-mns name dll_or_exe [dll_or_exe_2]</code></td><td>Create a separate namespace with the given name for the listed dll:s. All modules loaded in those module(s) will be namespaced.</td></tr>
<tr><td><code>-lcl LineCountLimit</code></td><td>Count number of times a line is executed up to the specified limit</td></tr>
<tr><td><code>-tec</code></td><td>Passthrough the exitcode of the application inspected</td></tr>
<tr><td><code>-twd</code></td><td>Use the application's path as working directory</td></tr>
</table>

## License
Expand Down
11 changes: 10 additions & 1 deletion Source/CoverageConfiguration.pas
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ TCoverageConfiguration = class(TInterfacedObject, ICoverageConfiguration)
FXmlMergeGenerics: Boolean;
FHtmlOutput: Boolean;
FTestExeExitCode: Boolean;
FUseTestExePathAsWorkingDir: Boolean;
FExcludeSourceMaskLst: TStrings;
FLoadingFromDProj: Boolean;
FModuleNameSpaces: TModuleNameSpaceList;
Expand Down Expand Up @@ -112,6 +113,7 @@ TCoverageConfiguration = class(TInterfacedObject, ICoverageConfiguration)
function XmlMergeGenerics: Boolean;
function HtmlOutput: Boolean;
function TestExeExitCode: Boolean;
function UseTestExePathAsWorkingDir: Boolean;
function LineCountLimit: Integer;

function ModuleNameSpace(const AModuleName: string): TModuleNameSpace;
Expand Down Expand Up @@ -362,6 +364,11 @@ function TCoverageConfiguration.TestExeExitCode: Boolean;
Result := FTestExeExitCode;
end;

function TCoverageConfiguration.UseTestExePathAsWorkingDir: Boolean;
begin
Result := FUseTestExePathAsWorkingDir;
end;

function TCoverageConfiguration.IsPathInExclusionList(const APath: TFileName): Boolean;
var
Mask: string;
Expand Down Expand Up @@ -396,6 +403,7 @@ procedure TCoverageConfiguration.ParseBooleanSwitches;
FHtmlOutput := IsSet(I_CoverageConfiguration.cPARAMETER_HTML_OUTPUT);
uConsoleOutput.G_Verbose_Output := IsSet(I_CoverageConfiguration.cPARAMETER_VERBOSE);
FTestExeExitCode := IsSet(I_CoverageConfiguration.cPARAMETER_TESTEXE_EXIT_CODE);
FUseTestExePathAsWorkingDir := IsSet(I_CoverageConfiguration.cPARAMETER_USE_TESTEXE_WORKING_DIR);
end;

procedure TCoverageConfiguration.ExcludeSourcePaths;
Expand Down Expand Up @@ -572,7 +580,8 @@ procedure TCoverageConfiguration.ParseSwitch(var AParameter: Integer);
or (SwitchItem = I_CoverageConfiguration.cPARAMETER_XML_LINES_MERGE_GENERICS)
or (SwitchItem = I_CoverageConfiguration.cPARAMETER_HTML_OUTPUT)
or (SwitchItem = I_CoverageConfiguration.cPARAMETER_VERBOSE)
or (SwitchItem = I_CoverageConfiguration.cPARAMETER_TESTEXE_EXIT_CODE) then
or (SwitchItem = I_CoverageConfiguration.cPARAMETER_TESTEXE_EXIT_CODE)
or (SwitchItem = I_CoverageConfiguration.cPARAMETER_USE_TESTEXE_WORKING_DIR) then
begin
// do nothing, because its already parsed
end
Expand Down
13 changes: 11 additions & 2 deletions Source/Debugger.pas
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
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ procedure TDebugger.PrintUsage;
ConsoleOutput(I_CoverageConfiguration.cPARAMETER_LINE_COUNT +
' [number] -- Count number of times a line is executed up to the specified limit (default 0 - disabled)');
ConsoleOutput(I_CoverageConfiguration.cPARAMETER_TESTEXE_EXIT_CODE +
' [number] -- Passthrough the exitcode of the application');
' -- Passthrough the exitcode of the application');
ConsoleOutput(I_CoverageConfiguration.cPARAMETER_USE_TESTEXE_WORKING_DIR +
' -- Use the application''s path as working directory');

end;

Expand Down Expand Up @@ -387,6 +389,7 @@ function TDebugger.StartProcessToDebug: Boolean;
StartInfo: TStartupInfo;
ProcInfo: TProcessInformation;
Parameters: string;
WorkingDir: PChar;
begin
Parameters := FCoverageConfiguration.ApplicationParameters;
FLogManager.Log(
Expand All @@ -402,6 +405,12 @@ function TDebugger.StartProcessToDebug: Boolean;
StartInfo.hStdOutput := GetStdHandle(STD_OUTPUT_HANDLE);
StartInfo.hStdError := GetStdHandle(STD_ERROR_HANDLE);

WorkingDir := nil;
if FCoverageConfiguration.UseTestExePathAsWorkingDir then
begin
WorkingDir := PChar(ExtractFilePath(FCoverageConfiguration.ExeFileName));
end;

Parameters := '"' + FCoverageConfiguration.ExeFileName + '" ' + Parameters;
Result := CreateProcess(
nil,
Expand All @@ -411,7 +420,7 @@ function TDebugger.StartProcessToDebug: Boolean;
True,
CREATE_NEW_PROCESS_GROUP + NORMAL_PRIORITY_CLASS + DEBUG_PROCESS,
nil,
nil,
WorkingDir,
StartInfo,
ProcInfo
);
Expand Down
2 changes: 2 additions & 0 deletions Source/I_CoverageConfiguration.pas
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ interface
function XmlMergeGenerics: Boolean;
function HtmlOutput: Boolean;
function TestExeExitCode: Boolean;
function UseTestExePathAsWorkingDir: Boolean;
function ModuleNameSpace(const AModuleName: string): TModuleNameSpace;
function UnitNameSpace(const AModuleName: string): TUnitNameSpace;
function LineCountLimit: Integer;
Expand Down Expand Up @@ -74,6 +75,7 @@ interface
cPARAMETER_UNIT_NAMESPACE = '-uns';
cPARAMETER_EMMA_SEPARATE_META = '-meta';
cPARAMETER_TESTEXE_EXIT_CODE = '-tec';
cPARAMETER_USE_TESTEXE_WORKING_DIR = '-twd';
cPARAMETER_LINE_COUNT = '-lcl';

cIGNORE_UNIT_PREFIX = '!';
Expand Down

Back | FazBrowse Home | New Git URL