Gianfrancoalongi / APLUnit

APLUnit - a library to facilitate Unit Testing and Test Driven Development of code written in Dyalog APL, developed together with Morten Kromberg (CTO Dyalog Ltd)
7 stars 5 forks source link

Coverage of functions in a File NameSpace fails #3

Closed Gianfrancoalongi closed 11 years ago

Gianfrancoalongi commented 11 years ago

It is currently not possible to cover functions in a file when running the file-path version of unit test execution.

Conf ← ⎕NEW UTcover Conf.pages ← '/home/APL/coverage' Conf.cover ← ⊂ '#.UTFile.plus_function' Conf UT.run '/path/to/file/File.dyalog'

Will not cover the plus_function in the UTFile NameSpace in the file File.dyalog.

Gianfrancoalongi commented 11 years ago

The problem is that, although the function is correctly pinpointed

Conf.cover ← ⊂ '#.UTFile.plus_function'

Once the file is loaded, the namespace will be embedded within the UT namespace. Therefore, the namespace the functions are in, will be #.UT.UTFile.plus_function This only happens for file execution.

Gianfrancoalongi commented 11 years ago

The ⎕CR of functions to be covered has not been affected, since the File to test on has previously (and still is) loaded into the workspace before testing.

Thus, #.UTFile exists, alongisde #.UT And so, the framework can ⎕CR #.UTFile.plus_function but, it is #.UT.UTFile that is executed.

Gianfrancoalongi commented 11 years ago

Morten Kromberg suggests that the ‘-target’ modifier, could possibly be a solution to this problem.

   ⎕SE.SALT.Load '/blah/blah/UT -target=#'

… will always put the namespace in #.UT, even if you are in some other space at the time.

Gianfrancoalongi commented 11 years ago

Actually, this could work fine. Seems to fit the bill.

Gianfrancoalongi commented 11 years ago

Fixed!