Include si sistemul de depanare/testare headless din Teste\ (harness UI cu capturi, verificare de sintaxa prin compilare, wrappere text<->binar) si docs\depanare_testare_flora2roa.md.
103 lines
3.4 KiB
Plaintext
103 lines
3.4 KiB
Plaintext
* test_init_env_auto.prg
|
|
* Initializare NEINTERACTIVA a mediului FLORA2ROA pentru rulare headless
|
|
* (vfp9.exe -A -T "script.prg"), echivalentul programului principal main.prg fara
|
|
* DO FORM / READ EVENTS.
|
|
*
|
|
* Utilizare dintr-un script de test:
|
|
* DO Teste\test_init_env_auto WITH .F. && fara conectare Oracle (implicit)
|
|
* DO Teste\test_init_env_auto WITH .T. && conectare cu datele din settings.ini
|
|
* DO Teste\test_init_env_auto WITH .T., 'ROA', 'XENOTI', 'parola'
|
|
*
|
|
* Parametri:
|
|
* tlConnect - .T. = se conecteaza la Oracle (goConn.Connect); implicit .F.
|
|
* tcHost/tcUser/tcPassword - suprascriu datele din settings.ini
|
|
* tcAppPath - radacina aplicatiei; implicit se deduce din calea acestui program
|
|
*
|
|
* Dupa apel sunt disponibile: gcAppName, gcAppPath, gcTempPath, goLog, goApp, goConn,
|
|
* goExecutor, gnHandle si SET PROCEDURE / SET LIBRARY ca in main.prg. Se poate face
|
|
* CREATEOBJECT('frm_import') sau DO FORM frm_import si apela metodele punctual.
|
|
*
|
|
* ATENTIE: ErrorHandler-ul din main.prg deschide MESSAGEBOX (blocheaza headless). Aici se
|
|
* instaleaza TestErrorHandler (test_helpers.prg), care logheaza in gcTestErrLog si continua.
|
|
|
|
LPARAMETERS tlConnect, tcHost, tcUser, tcPassword, tcAppPath
|
|
|
|
SET SAFETY OFF
|
|
SET TALK OFF
|
|
CLOSE DATABASES ALL
|
|
SET DELETED ON
|
|
SET EXCLUSIVE ON
|
|
SET ANSI ON
|
|
SET EXACT ON
|
|
SET CENTURY ON
|
|
SET DATE DMY
|
|
SET NULLDISPLAY TO ''
|
|
|
|
PUBLIC gcAppName, gcAppPath, gcTempPath, gcTestErrLog
|
|
PUBLIC goApp, goLog, goConn, goExecutor, goImportFrm, gnHandle
|
|
|
|
LOCAL lcHere
|
|
lcHere = ADDBS(JUSTPATH(SYS(16, 0)))
|
|
IF TYPE('tcAppPath') = 'C' AND !EMPTY(tcAppPath)
|
|
gcAppPath = ADDBS(tcAppPath)
|
|
ELSE
|
|
* scriptul sta in <radacina>\Teste\, deci radacina e cu un nivel mai sus
|
|
gcAppPath = ADDBS(JUSTPATH(SUBSTR(lcHere, 1, LEN(lcHere) - 1)))
|
|
ENDIF
|
|
|
|
gcAppName = 'FLORA2ROA'
|
|
gcTempPath = GETENV("TEMP")
|
|
gcTestErrLog = gcAppPath + 'Teste\_erori_test.txt'
|
|
SET DEFAULT TO (gcAppPath)
|
|
SET PATH TO (gcAppPath) ADDITIVE
|
|
SET PATH TO (gcAppPath + 'Teste') ADDITIVE
|
|
|
|
* aceleasi fisiere de proceduri ca in main.prg; mock-urile se incarca DUPA, in test
|
|
SET PROCEDURE TO (gcAppPath + 'capp.prg') ADDITIVE
|
|
SET PROCEDURE TO (gcAppPath + 'app.prg') ADDITIVE
|
|
SET PROCEDURE TO (gcAppPath + 'myutils.prg') ADDITIVE
|
|
SET PROCEDURE TO (gcAppPath + 'vfpconnection_utils.prg') ADDITIVE
|
|
SET PROCEDURE TO (gcAppPath + 'myapp.prg') ADDITIVE
|
|
SET PROCEDURE TO (gcAppPath + 'Teste\test_helpers.prg') ADDITIVE
|
|
|
|
LOCAL lnLib, lcLib
|
|
FOR lnLib = 1 TO 2
|
|
lcLib = IIF(lnLib = 1, 'vfpconnection.fll', 'vfpencryption.fll')
|
|
IF FILE(gcAppPath + lcLib)
|
|
TRY
|
|
SET LIBRARY TO (gcAppPath + lcLib) ADDITIVE
|
|
CATCH
|
|
STRTOFILE('Nu s-a putut incarca ' + lcLib + CHR(13) + CHR(10), gcTestErrLog, .T.)
|
|
ENDTRY
|
|
ENDIF
|
|
ENDFOR
|
|
|
|
ON ERROR DO TestErrorHandler WITH ERROR(), MESSAGE(), PROGRAM(), LINENO()
|
|
|
|
goImportFrm = NULL
|
|
goConn = CREATEOBJECT("oConn")
|
|
goExecutor = CREATEOBJECT("oExecutor")
|
|
goLog = CREATEOBJECT("Log", gcAppPath + "log\log_test_" + gcAppName + "_" + DTOS(DATE()) + ".txt")
|
|
goApp = CREATEOBJECT("MyApp")
|
|
gnHandle = 0
|
|
|
|
IF TYPE('tcHost') = 'C' AND !EMPTY(tcHost)
|
|
goApp.oSettings.host = ALLTRIM(tcHost)
|
|
ENDIF
|
|
IF TYPE('tcUser') = 'C' AND !EMPTY(tcUser)
|
|
goApp.oSettings.user = ALLTRIM(tcUser)
|
|
ENDIF
|
|
IF TYPE('tcPassword') = 'C' AND !EMPTY(tcPassword)
|
|
goApp.oSettings.password = ALLTRIM(tcPassword)
|
|
ENDIF
|
|
|
|
IF TYPE('tlConnect') = 'L' AND tlConnect
|
|
goConn.Connect()
|
|
gnHandle = goConn.GetHandle()
|
|
IF gnHandle <= 0
|
|
RETURN .F.
|
|
ENDIF
|
|
ENDIF
|
|
|
|
RETURN .T.
|