Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-08

Unit testing aid...

8 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt

Hi,

for those that do unit testing, I committed a small tool "pas2ut" which analyses a unit, and creates a unit with a number of (empty) test cases. Obviously, the unit should be compileable (well, at least it must be parseable).

The output is very configurable, and should cover a lot of cases that one is likely to encounter when doing unit tests.

In particular, it handles creates tests for all members of the classes it finds in the unit (visibilities can be specified).

The basis for this tool is in the fcl-passrc unit pastounittest unit.

I would appreaciate feedback and suggestions.

(For one, integration with the Lazarus IDE is on my list)

Michael.

Reply by email

Daniel Gaspary
to Michael Van Canneyt

On Wed, Aug 22, 2012 at 2:08 PM, Michael Van Canneyt

I would appreaciate feedback and

suggestions.

I believe could be interesting to have a similar tool to generate "annotations" to a unit(or set of units).

The obvious example: insert calls to logging procedures at the enter and exit of each method, procedure or function of a unit.

With options to specify targets (all procedures, name some, etc... ) and templates to insert.

But anyway, thank you for these two tools, the pas2ut in special I believe will be very helpful.

Daniel

Reply by email

Graeme Geldenhuys
to Daniel Gaspary
Daniel Gaspary wrote
The obvious example: insert calls to logging procedures at the enter and exit of each method, procedure or function of a unit.

This is already possible for some time. Take a look at the 'fpprofiler' project. I have a version of it that I worked on at:

https://github.com/graemeg/fpprofiler

But I think there is a newer fpprofiler repository hosted somewhere else now...

Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email

Martin
to Michael Van Canneyt: for those that do unit testing, I committed a small tool "pas2ut" which analyses a unit,…
Michael Van Canneyt wrote 8 lines
Hi, for those that do unit testing, I committed a small tool "pas2ut" which analyses a unit, and creates a unit with a number of (empty) test cases. Obviously, the unit should be compileable (well, at least it must be parseable).

I just updated from SVN (after make clean), using fpc 2.6.0 (only ppc, no full install, I admit it could be may fault, I still dare to ask for help)

make.exe -C fpcmkcfg all
make.exe[3]: Entering directory `C:/FPC/SVN/trunc/utils/fpcmkcfg' C:/FPC/SVN/trunk_build/gmkdir.exe -p units/i386-win32 C:/FPC/SVN/trunc/compiler/ppc386.exe -XX -CX -Ur -Xs -O2 -n -O2 -FuC:/FPC/SVN/trunc/rtl/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/paszli b/units/i386-win32
-FuC:/FPC/SVN/trunc/packages/fcl-process/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/hash/units/i386-win32 -FuC:/FPC/SV N/trunc/packages/fpmkunit/units/i386-win32
-FuC:/FPC/SVN/trunc/packages/fcl-base/units/i386-win32 -FE. -FUunits/i386-win32 -gl -O3 -Or -CpPE
NTIUMM -OpPENTIUMM -di386 -dRELEASE fpcmkcfg.pp
make.exe[3]: Leaving directory `C:/FPC/SVN/trunc/utils/fpcmkcfg' make.exe -C pas2ut all
make.exe[3]: Entering directory `C:/FPC/SVN/trunc/utils/pas2ut' C:/FPC/SVN/trunk_build/gmkdir.exe -p units/i386-win32 C:/FPC/SVN/trunc/compiler/ppc386.exe -XX -CX -Ur -Xs -O2 -n -O2 -S2h -FuC:/FPC/SVN/trunc/rtl/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/p aszlib/units/i386-win32
-FuC:/FPC/SVN/trunc/packages/fcl-process/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/hash/units/i386-win32 -FuC:/F PC/SVN/trunc/packages/fpmkunit/units/i386-win32
-FuC:/FPC/SVN/trunc/packages/fcl-passrc/units/i386-win32 -FE. -FUunits/i386-win32 -gl -O3 -O
r -CpPENTIUMM -OpPENTIUMM -di386 -dRELEASE pas2ut.pp pas2ut.pp(20,45) Fatal: Can't find unit CustApp used by pas2ut Fatal: Compilation aborted
make.exe[3]: *** [pas2ut.exe] Error 1
make.exe[3]: Leaving directory `C:/FPC/SVN/trunc/utils/pas2ut' make.exe[2]: *** [pas2ut_all] Error 2
make.exe[2]: Leaving directory `C:/FPC/SVN/trunc/utils' make.exe[1]: *** [utils_all] Error 2
make.exe[1]: Leaving directory `C:/FPC/SVN/trunc'
make.exe: *** [build-stamp.i386-win32] Error 2

Reply by email

Sven Barth
to Martin
Martin wrote 50 lines
On 22/08/2012 18:08, Michael Van Canneyt wrote: > > Hi, > > for those that do unit testing, I committed a small tool "pas2ut" which > analyses a unit, and creates a unit with a number of (empty) test > cases. Obviously, the unit should be compileable (well, at least it > must be > parseable). I just updated from SVN (after make clean), using fpc 2.6.0 (only ppc, no full install, I admit it could be may fault, I still dare to ask for help) make.exe -C fpcmkcfg all make.exe[3]: Entering directory `C:/FPC/SVN/trunc/utils/fpcmkcfg' C:/FPC/SVN/trunk_build/gmkdir.exe -p units/i386-win32 C:/FPC/SVN/trunc/compiler/ppc386.exe -XX -CX -Ur -Xs -O2 -n -O2 -FuC:/FPC/SVN/trunc/rtl/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/paszli b/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/fcl-process/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/hash/units/i386-win32 -FuC:/FPC/SV N/trunc/packages/fpmkunit/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/fcl-base/units/i386-win32 -FE. -FUunits/i386-win32 -gl -O3 -Or -CpPE NTIUMM -OpPENTIUMM -di386 -dRELEASE fpcmkcfg.pp make.exe[3]: Leaving directory `C:/FPC/SVN/trunc/utils/fpcmkcfg' make.exe -C pas2ut all make.exe[3]: Entering directory `C:/FPC/SVN/trunc/utils/pas2ut' C:/FPC/SVN/trunk_build/gmkdir.exe -p units/i386-win32 C:/FPC/SVN/trunc/compiler/ppc386.exe -XX -CX -Ur -Xs -O2 -n -O2 -S2h -FuC:/FPC/SVN/trunc/rtl/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/p aszlib/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/fcl-process/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/hash/units/i386-win32 -FuC:/F PC/SVN/trunc/packages/fpmkunit/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/fcl-passrc/units/i386-win32 -FE. -FUunits/i386-win32 -gl -O3 -O r -CpPENTIUMM -OpPENTIUMM -di386 -dRELEASE pas2ut.pp pas2ut.pp(20,45) Fatal: Can't find unit CustApp used by pas2ut Fatal: Compilation aborted make.exe[3]: *** [pas2ut.exe] Error 1 make.exe[3]: Leaving directory `C:/FPC/SVN/trunc/utils/pas2ut' make.exe[2]: *** [pas2ut_all] Error 2 make.exe[2]: Leaving directory `C:/FPC/SVN/trunc/utils' make.exe[1]: *** [utils_all] Error 2 make.exe[1]: Leaving directory `C:/FPC/SVN/trunc' make.exe: *** [build-stamp.i386-win32] Error 2

Where the packages also built?

Regards,
Sven

Reply by email

Sven Barth
to Martin: I just updated from SVN (after make clean), using fpc 2.6.0 (only ppc, no full install, I…
Martin wrote 50 lines
On 22/08/2012 18:08, Michael Van Canneyt wrote: > > Hi, > > for those that do unit testing, I committed a small tool "pas2ut" which > analyses a unit, and creates a unit with a number of (empty) test > cases. Obviously, the unit should be compileable (well, at least it > must be > parseable). I just updated from SVN (after make clean), using fpc 2.6.0 (only ppc, no full install, I admit it could be may fault, I still dare to ask for help) make.exe -C fpcmkcfg all make.exe[3]: Entering directory `C:/FPC/SVN/trunc/utils/fpcmkcfg' C:/FPC/SVN/trunk_build/gmkdir.exe -p units/i386-win32 C:/FPC/SVN/trunc/compiler/ppc386.exe -XX -CX -Ur -Xs -O2 -n -O2 -FuC:/FPC/SVN/trunc/rtl/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/paszli b/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/fcl-process/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/hash/units/i386-win32 -FuC:/FPC/SV N/trunc/packages/fpmkunit/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/fcl-base/units/i386-win32 -FE. -FUunits/i386-win32 -gl -O3 -Or -CpPE NTIUMM -OpPENTIUMM -di386 -dRELEASE fpcmkcfg.pp make.exe[3]: Leaving directory `C:/FPC/SVN/trunc/utils/fpcmkcfg' make.exe -C pas2ut all make.exe[3]: Entering directory `C:/FPC/SVN/trunc/utils/pas2ut' C:/FPC/SVN/trunk_build/gmkdir.exe -p units/i386-win32 C:/FPC/SVN/trunc/compiler/ppc386.exe -XX -CX -Ur -Xs -O2 -n -O2 -S2h -FuC:/FPC/SVN/trunc/rtl/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/p aszlib/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/fcl-process/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/hash/units/i386-win32 -FuC:/F PC/SVN/trunc/packages/fpmkunit/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/fcl-passrc/units/i386-win32 -FE. -FUunits/i386-win32 -gl -O3 -O r -CpPENTIUMM -OpPENTIUMM -di386 -dRELEASE pas2ut.pp pas2ut.pp(20,45) Fatal: Can't find unit CustApp used by pas2ut Fatal: Compilation aborted make.exe[3]: *** [pas2ut.exe] Error 1 make.exe[3]: Leaving directory `C:/FPC/SVN/trunc/utils/pas2ut' make.exe[2]: *** [pas2ut_all] Error 2 make.exe[2]: Leaving directory `C:/FPC/SVN/trunc/utils' make.exe[1]: *** [utils_all] Error 2 make.exe[1]: Leaving directory `C:/FPC/SVN/trunc' make.exe: *** [build-stamp.i386-win32] Error 2

I just see that a -Fu for fcl-base is missing, so that might be the cause...

Reagrds,
Sven

Reply by email

Reinier Olislagers
to Sven Barth
Sven Barth wrote 25 lines
Am 22.08.2012 21:56, schrieb Martin: > make.exe[3]: Entering directory `C:/FPC/SVN/trunc/utils/pas2ut' > C:/FPC/SVN/trunk_build/gmkdir.exe -p units/i386-win32 > C:/FPC/SVN/trunc/compiler/ppc386.exe -XX -CX -Ur -Xs -O2 -n -O2 -S2h > -FuC:/FPC/SVN/trunc/rtl/units/i386-win32 -FuC:/FPC/SVN/trunc/packages/p > aszlib/units/i386-win32 > -FuC:/FPC/SVN/trunc/packages/fcl-process/units/i386-win32 > -FuC:/FPC/SVN/trunc/packages/hash/units/i386-win32 -FuC:/F > PC/SVN/trunc/packages/fpmkunit/units/i386-win32 > -FuC:/FPC/SVN/trunc/packages/fcl-passrc/units/i386-win32 -FE. > -FUunits/i386-win32 -gl -O3 -O > r -CpPENTIUMM -OpPENTIUMM -di386 -dRELEASE pas2ut.pp > pas2ut.pp(20,45) Fatal: Can't find unit CustApp used by pas2ut > Fatal: Compilation aborted > make.exe[3]: *** [pas2ut.exe] Error 1 > make.exe[3]: Leaving directory `C:/FPC/SVN/trunc/utils/pas2ut' > make.exe[2]: *** [pas2ut_all] Error 2 > make.exe[2]: Leaving directory `C:/FPC/SVN/trunc/utils' > make.exe[1]: *** [utils_all] Error 2 > make.exe[1]: Leaving directory `C:/FPC/SVN/trunc' > make.exe: *** [build-stamp.i386-win32] Error 2 I just see that a -Fu for fcl-base is missing, so that might be the cause...

Yep, tried to patch it in
http://bugs.freepascal.org/view.php?id=22707
but my make/fpmake skills are quite weak ;)

Reinier

Reply by email

Unknown author
to Martin: I just updated from SVN (after make clean), using fpc 2.6.0 (only ppc, no full install, I…
Martin wrote 11 lines
On 22/08/2012 18:08, Michael Van Canneyt wrote: > > Hi, > > for those that do unit testing, I committed a small tool "pas2ut" which > analyses a unit, and creates a unit with a number of (empty) test cases. > Obviously, the unit should be compileable (well, at least it must be > parseable). I just updated from SVN (after make clean), using fpc 2.6.0 (only ppc, no full install, I admit it could be may fault, I still dare to ask for help)

My mistake. I forgot to add a dependency.

So, number 2 on the to-do list for pas2fpm: Add tracking of package dependencies :)

Michael.

Reply by email