6

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

soerenD
  • 138
  • 6
  • 1
    Inno Setup's Pascal Script language is specific to Inno Setup, so you have to compile it in its native compiler. I doubt there are alternative compilers. Yes, there are some (even I'm using my own), but they usually add some features to the scripting language and are based on the original compiler core. If you're asking because your compilation takes a long time, you may "turn off" compression or conditionally remove files section if that's possible in your case. Could you elaborate why you're asking ? – TLama Jan 07 '14 at 14:19
  • By hitting Ctrl+F9 you can "test" your code by compiling it without launching the installer. But I suppose you mean something like "debugging" the code which is possible only by running the generated installer. – Slappy Jan 08 '14 at 05:50
  • The reason is mainly debugging. I have lots of functions that do small things like manipulating paths, checking versions of installed software and so on. If one of these functions has a bug its relatively annoying work to find the error, because for each change I have to compile and step through the installation process until the step that uses my function. Of course i can remove all the files not needed for a function i want to de-bug or all the steps which are not needed for a certain function, but this is not very comfortable if I only want to see if a function works like intended., – soerenD Jan 08 '14 at 11:02
  • 2
    You can call the function you want to check from `InitializeSetup`. – Newbee Jan 22 '14 at 15:14
  • @Newbee is it possible to sent hard-coded switches, like `/myswitch` to `InitializeSetup` – T.S. Aug 04 '20 at 20:56

2 Answers2

1

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.)

Bill_Stewart
  • 22,916
  • 4
  • 51
  • 62
-2

I think yes

  • For compiling: Use 'Ctrl+F9'

  • For testing use only 'F9' (_without '' in inno setup).

Thanks.

EDIT:

Sorry You cant use this Processes.Look into Tlama comment.

Community
  • 1
  • 1
Kushal
  • 605
  • 8
  • 29
  • No. You cannot test the setup with the Inno Setup compiler without building it. F9 shortcut still makes the initial build of the script. – TLama Jun 14 '15 at 11:13