Unit testing aid...

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Unit testing aid...

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.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Unit testing aid...

Daniel Gaspary
On Wed, Aug 22, 2012 at 2:08 PM, Michael Van Canneyt
<[hidden email]> > 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Unit testing aid...

Graeme Geldenhuys-2
On 22 August 2012 18:47, Daniel Gaspary <[hidden email]> 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Unit testing aid...

Martin Frb
In reply to this post by Michael Van Canneyt
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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Unit testing aid...

Sven Barth-2
Am 22.08.2012 21:56, schrieb Martin:

> 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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Unit testing aid...

Sven Barth-2
In reply to this post by Martin Frb
Am 22.08.2012 21:56, schrieb Martin:

> 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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Unit testing aid...

Reinier Olislagers
On 23-8-2012 9:36, Sven Barth wrote:

> 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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Unit testing aid...

michael.vancanneyt
In reply to this post by Martin Frb


On Wed, 22 Aug 2012, Martin wrote:

> 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.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal