Closed SoftAllan closed 7 months ago
I had a look at the code:
Procedure OnExecute Variant vCommandBarControl
Boolean bExists bEnabled
String sProgramPath sProgramFile sSourceFile sBinPath sHome
Get DFBinPath of ghoApplication to sBinPath
Get vFolderFormat sBinPath to sBinPath
Get psHome of (phoWorkspace(ghoApplication)) to sHome
Get vFolderFormat sHome to sHome
Get psProgramPath of (phoWorkspace(ghoApplication)) to sProgramPath
Get vFolderFormat sProgramPath to sProgramPath
Move (CS_DFUnitTest + ".src") to sSourceFile
Move (Replace(".src", sSourceFile, ".exe")) to sProgramFile
Get vFilePathExists (sProgramPath + sProgramFile) to bExists
Runprogram Wait ('"' + sBinPath + CS_Compiler + '"' * "-x" + '"' + sHome + CS_SWSFile + '"' * CS_CompOptions * sSourceFile)
// If program compilation failed:
If (bExists = False) Begin
Send Info_Box ("The compilation of the" * (CS_DFUnitTest + ".src program") * "failed and can't be started. Please check it with the Studio.")
End
Else Begin
Runprogram Background sProgramFile
End
End_Procedure
It seems that you are checking if the program file exists before it is compiled. I will change this so the file is checked after the compile has been executed and finished.
Turns out that is not enough. Because this is compiled to 64-bit the filename gets the "64" postfix. That is why TestBench cannot find the file.
Do not try to change this. The logic is fine and correct! But for some reason DataFlex may be unable to correctly compile the program and then you get this error message. If this happens, just try again and it probably goes through.
I tried with the following code
#IFDEF IS$WIN64
Move (Replace(".src", sSourceFile, "64.exe")) to sProgramFile
#ELSE
Move (Replace(".src", sSourceFile, ".exe")) to sProgramFile
#ENDIF
And tested with both 64 and 32 bit compilation of the TestBench.src. It works with 64 bit but it seems that the command for compiling the Unit test project is always compiling to 64 bit even if the TestBench.src is running in 32 bit.
Do not try to change this. The logic is fine and correct! But for some reason DataFlex may be unable to correctly compile the program and then you get this error message. If this happens, just try again and it probably goes through.
I am not sure why the logic is correct on this?
Get vFilePathExists (sProgramPath + sProgramFile) to bExists
Runprogram Wait ('"' + sBinPath + CS_Compiler + '"' * "-x" + '"' + sHome + CS_SWSFile + '"' * CS_CompOptions * sSourceFile)
This seems not logically to me that you test if the program exists before you try to compile?
The logic always calls the compiler and it is up to the compiler to decide if a re-compilation is needed or not. That is the first "Runprogram Wait..." line.
As all programs has been set to compile as x64 bits programs no changes should be necessary.
Right, I now see what you mean. The line "Get vFilePathExists (sProgramPath + sProgramFile) to bExists" should be moved to after the "Runprogram Wait...".
Thanks! Committed and pushed.
I still think there is an issue here. You are checking for a file that is compiled with another exe file name. Please check to see, if you can make this work.
What I mean is that the file compiles as DFUnit_TestRunner64.exe. But your are trying to find the file with the name: DFUnit_TestRunner.exe.
Yes, you are correct. The logic was flaky. And not only that, the logic also was duplicated in the two Run program toolbar items. A common method has been created: // Common method for oExternalProgramsToolbar and oDFRefactor_MenuItem OnExectute. Procedure CompileRunProgram String sProgram
Fixed!
I get this error if I try to run the Unit Test application from within the Test Bench application
I am able to compile and run the unit test from the studio though.