PureUnit triggers GUI alert on fail

Post bugreports for the Windows version here
tored
User
User
Posts: 88
Joined: Wed Feb 16, 2022 12:47 pm
Location: Sweden

PureUnit triggers GUI alert on fail

Post by tored »

Calling Assert() with a falsy expression or Fail() inside a module triggers a GUI alert (MessageRequester) when calling PureUnit.exe from the command line.

Test case

test.pbi

Code: Select all

Procedure MyProcedure()
  Assert(#False)
EndProcedure  

DeclareModule MyModule
  Declare MyProcedure()  
EndDeclareModule  

Module MyModule
  Procedure MyProcedure()
    Assert(#False)
  EndProcedure  
EndModule

ProcedureUnit TestMyProcedure()
  MyProcedure()
EndProcedureUnit

ProcedureUnit TestMyModuleMyProcedure()
  MyModule::MyProcedure() ; Triggers GUI alert
EndProcedureUnit

Code: Select all

"%ProgramFiles%\PureBasic\SDK\PureUnit\PureUnit.exe" /ignore test.pb
This will show MessageRequester where the error occured instead of printing the error to console.

Why have Assert() or Fail() inside a module? Typically a TestHelper module to make testing easier. Calling Assert() or Fail() inside a standalone procedure works as expected.

Personally I would prefer if PureUnit.exe was cli only and PureUnitGui.exe was the GUI PureUnit, to avoid any pontential problems when running PureUnit.exe in batch jobs.

Calling PureUnit.exe without any arguments launches the PureUnit GUI, perhaps showing help would be better.
Fred
Administrator
Administrator
Posts: 18335
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PureUnit triggers GUI alert on fail

Post by Fred »

As we have 2 version, it makes sense than the console version would be without GUI. That said, you can use the '-q' flag (quiet) which should solve your requester issue.
tored
User
User
Posts: 88
Joined: Wed Feb 16, 2022 12:47 pm
Location: Sweden

Re: PureUnit triggers GUI alert on fail

Post by tored »

Fred wrote: Wed Oct 01, 2025 3:34 pm As we have 2 version, it makes sense than the console version would be without GUI. That said, you can use the '-q' flag (quiet) which should solve your requester issue.
Sorry for forgetting to mention, the q quiet flag doesn't work in this case. Already tested that.

Code: Select all

"%ProgramFiles%\PureBasic\SDK\PureUnit\PureUnit.exe" /ignore /quiet test.pb
freak
PureBasic Team
PureBasic Team
Posts: 5946
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: PureUnit triggers GUI alert on fail

Post by freak »

It is because the whole thing is not aware of modules. The macros think you are running the test code without PureUnit because they cannot see the framework procedures and so the macros fall back to a MessageRequester() for the alert.

It needs to be reworked to properly support modules.
quidquid Latine dictum sit altum videtur
Post Reply