I am wondering if it is somehow possible to test the functions in my [Code] section without compiling the whole installer each time and run it. This would make the development and testing of the functions much easier.
Many thanks! Sören
I am wondering if it is somehow possible to test the functions in my [Code] section without compiling the whole installer each time and run it. This would make the development and testing of the functions much easier.
Many thanks! Sören
The direct answer to the question "Is it possible to test Pascal Script functions without compiling the installer?" is "no." Compilation is required to run the code. The real issue, I think, is not that compilation is required but rather that large projects can be time-consuming to recompile when you are performing code testing.
One workaround for time-consuming recompiles is to create a "stub" setup for code testing. Simple example:
[Setup]
AppName=TestCode
ArchitecturesInstallIn64BitMode=x64
AppVerName=TestCode
UsePreviousAppDir=false
DefaultDirName={commonpf}\TestCode
Uninstallable=false
OutputDir=.
OutputBaseFilename=TestCode
PrivilegesRequired=none
[Messages]
SetupAppTitle=TestCode
[Code]
function BoolToStr(const B: Boolean): string;
begin
if B then
result := 'true'
else
result := 'false';
end;
procedure Test();
begin
MsgBox(BoolToStr(true), mbInformation, MB_OK);
end;
function InitializeSetup(): Boolean;
begin
result := false;
Test();
end;
In the InitializeSetup
event function we set result
to false
so nothing actually gets "installed"; the whole purpose is simply to run the Test
procedure and then terminate. The Test
procedure tests the sample BoolToStr
function to make sure it works as expected.
When you are certain your code works as expected, you can copy it to your main project. (Don't forget to copy all dependencies such as global variables, DLL import statements, etc.)
For compiling: Use 'Ctrl+F9'
For testing use only 'F9' (_without '' in inno setup).
Thanks.
Sorry You cant use this Processes.Look into Tlama comment.