Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Constructor wrong coverage #6

Open
SharpEdgeMarshall opened this issue Mar 16, 2015 · 5 comments
Open

Missing Constructor wrong coverage #6

SharpEdgeMarshall opened this issue Mar 16, 2015 · 5 comments

Comments

@SharpEdgeMarshall
Copy link

I was trying to use flexmojos coverage and wasn't understanding why the coverage.xml was reporting a hit on a line that doesn't exist on the file.

After a night of debug i've found that apparat is instrumenting a line past the end of file when there is no constructor

@silmerusse
Copy link

Is there any fix or workaround? Right now it prevents me from importing the coverage report to sonarqube because the line number is invalid.

@joa
Copy link
Owner

joa commented May 20, 2016

If you can provide me with a reproducible test case (binary SWF, no dependencies on Flex SDK preferred) I'll fix it.

If I remember correct, there is actually code on the byte code level for each unit when being initialized.

@silmerusse
Copy link

demo.zip
binary.zip

Foo.as only has 10 lines, but it seems apparat instrumented a line number 11 during the object's initialization.

package 
{
  public class Foo
  {
    public function run():void
    {
      trace("run"); 
    }
  }
}
              Method:
                Name: Foo/Foo
                Return Type: AbcQName('null,AbcNamespace(0,'null))
                Needs Arguments: false
                Needs Rest: false
                Needs Activation: false
                Has Optional Parameters: false
                Ignore Rest: false
                Is Native: false
                DXNS: false
                Has Parameter Names: false
                Parameters:
                Method Body:
                  Max Stack: 4
                  Locals: 1
                  InitScopeDepth: 4
                  MaxScopeDepth: 5
                  Bytecode:
                    operandStack: 4
                    scopeStack:   1
                    localCount:   1
                    0 exception(s):
                    11 operation(s):
                              +1|-0  GetLocal(0)
                              +0|-1  PushScope()
                              +1|-0  GetLocal(0)
                              +0|-1  ConstructSuper(0)
                              +0|-0  DebugFile('E:\demo\src;;Foo.as)
                              +0|-0  DebugLine(11)
                              +1|-0  GetLex(AbcQName('Coverage,AbcNamespace(22,'apparat.coverage)))
                              +1|-0  PushString('E:\demo\src;;Foo.as)
                              +1|-0  PushByte(11)
                              +0|-3  CallPropVoid(AbcQName('onSample,AbcNamespace(22,')),2)
                              +0|-0  ReturnVoid()

@joa
Copy link
Owner

joa commented May 22, 2016

I just checked this. There is in fact a DebugLine instruction in the bytecode. It is being executed and therefore part of the coverage report.

You can supply Apparat a source-path. If a source path is given, one could calculate the number of lines for an instrumented source and ignore DebugLine instructions that are out of bounds. However this doesn't seem like a satisfactory solution to me, especially since we have to count the lines of code in the soruce file. This creates an additional dependency to the source code which was optional before.

I think FlexMojos is always passing the source path to Apparat but I'm not sure. I also think that FlexMojos already did something along those lines. Sorry this is all several years old. @velo do you remember?

@velo
Copy link
Contributor

velo commented May 23, 2016

Sorry @joa,
I don't touch flexmojos code since 2012, I don't remember it at all

@silmerusse For workaround I suggest you creating a constructor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants