qickrooms / flexcover

Automatically exported from code.google.com/p/flexcover
0 stars 0 forks source link

Flexcover hangs intermittently in ANT build #32

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Compile code using coverage modified sdk in ANT build
2. Have ANT start coverage viewer then execute tests
3. Coverage view will intermittently not close on build server (about 1/10
of time) causing build to hang.
4. If update is clicked, coverage report will be written as expected and
build will continue when viewer closed.

What is the expected output? What do you see instead?
Output report written, viewer terminates.  Viewer sits and waits.

What version of the product are you using? On what operating system?
V.81 on Windows 2003 server Enterprise Edition

Please provide any additional information below.

Original issue reported on code.google.com by masmana...@gmail.com on 18 May 2009 at 3:50

GoogleCodeExporter commented 8 years ago
I've noticed the same thing with our build.

My belief is that sometimes report data is still pending when the
CoverageManager.exit() is called, and the when the application exits, the
localConnection is closed prior to the DATA_EXIT_HANDLER exit request being 
sent to
the CoverageViewer.

One way around this seems to be to have the application being tested not 
immediately
call CoverageManager.exit(), but to have it create a timer, and call
CoverageManager.exit() after waiting a short period.

  // In the TestRunner completion handler
  var timer:Timer = new Timer(5000, 1);
  timer.addEventListener(TimerEvent.TIMER_COMPLETE, onWaitTimerDone);
  timer.start();

...
  private function onWaitTimerDone(event:Event):void {
    CoverageManager.exit();
  }

Another option is to cast the CoverageManager.agent to a LocalConnectionAgent, 
and
check the operationsPending() property for a false value.  If it's false, exit
immediately, otherwise, setup a Timer, and periodically check, then exit when 
false.

  // In the TestRunner completion handler
  var timer:Timer = new Timer(500, 0);
  timer.addEventListener(TimerEvent.TIMER_COMPLETE, onWaitTimerTick);
  timer.start();

... 

  private function onWaitTimerTick(event:TimerEvent):void {
     var agent:LocalConnectionCoverageAgent = CoverageManager.agent as
LocalConnectionCoverageAgent;

     if (! agent || ! agent.operationsPending) {
       CoverageManager.exit();
     }
  }

Original comment by boni...@frii.com on 18 Jun 2009 at 5:39

GoogleCodeExporter commented 8 years ago
I am feeling it's more like the CoverageViewer is shutdown before it finished 
processing the coverage data / flushing the file.

I noticed that in the com.allurent.coverage.view.model.CoverageViewerPM it set 
a timer/delay to process the coverage data (ie. call to parseCoverageData is 
delayed)

        private function performHeavyOperation( callback : Function, parameters : Array = null ) : void
        {
            handleHeavyOperationEvent( new HeavyOperationEvent( callback, parameters ));
        }

        private function handleHeavyOperationEvent( event : HeavyOperationEvent ) : void
        {
            showMessageOverlay = true;
            timer.delay( 500, event.execute );
        }

        private function handleRecordingEnd( event : CoverageEvent ) : void
        {
            performHeavyOperation( parseCoverageData );
        }

        private function parseCoverageData() : void
        {
            trace( "CoverageViewerPM.parseCoverageData " );
            controller.applyCoverageData();
            showMessageOverlay = false;
        }

which suggested that applyCoverageData is probably taking up a lot time or is 
asynchronous...I am not exactly sure.

so I added an event listened in the close method of Controller class, so that 
it only tries to close the app after it PARSING_END event occurs. And it seemed 
to work! I 
occasionally still experience premature closing of CoverageViewer but the last 
few runs were complete.

        /**
         * Handle closure of the application.
         *
         */
        public function close() : void
        {
            if ( coverageOutputFile != null )
            {
                this.addEventListener( CoverageEvent.PARSING_END, function() : void
                    {
                        writeReport( coverageOutputFile);
                        NativeApplication.nativeApplication.exit();
                    });
                applyCoverageData();
            }
            else
            {
                NativeApplication.nativeApplication.exit();
            }
        }

I also changed the exit method in AbstractCoverageAgent.as. But maybe this 
isn't necessary.

        public function exit() : void
        {
            stopped = true;
            flushCoverageData();

            if ( !broken )
            {
                requestExit();
            }
            checkForExit();
        }

Original comment by cooln...@gmail.com on 13 Aug 2009 at 6:48