| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * This test verifies that if reanalysis is performed while reanalysis is in |
| 7 * progress, no problems occur. See dartbug.com/21448. |
| 8 */ |
| 9 library test.integration.analysis.reanalyze_concurrent; |
| 10 |
| 11 import 'dart:async'; |
| 12 |
| 13 import 'package:analysis_server/src/protocol.dart'; |
| 14 import 'package:unittest/unittest.dart'; |
| 15 |
| 16 import '../../reflective_tests.dart'; |
| 17 import '../integration_tests.dart'; |
| 18 |
| 19 @ReflectiveTestCase() |
| 20 class Test extends AbstractAnalysisServerIntegrationTest { |
| 21 test_reanalyze_concurrent() { |
| 22 String pathname = sourcePath('test.dart'); |
| 23 String text = ''' |
| 24 // Do a bunch of imports so that analysis has some work to do. |
| 25 import 'dart:io'; |
| 26 import 'dart:convert'; |
| 27 import 'dart:async'; |
| 28 |
| 29 main() {}'''; |
| 30 writeFile(pathname, text); |
| 31 standardAnalysisSetup(); |
| 32 return analysisFinished.then((_) { |
| 33 sendAnalysisReanalyze(); |
| 34 // Wait for reanalysis to start. |
| 35 return onServerStatus.first.then((_) { |
| 36 sendAnalysisReanalyze(); |
| 37 return analysisFinished.then((_) { |
| 38 // Now that reanalysis has finished, no further analysis should occur. |
| 39 onServerStatus.listen((ServerStatusParams data) { |
| 40 if (data.analysis != null) { |
| 41 if (data.analysis.isAnalyzing) { |
| 42 // Most likely what happened is that the first reanalyze |
| 43 // completed before the second reanalyze had a chance to start, |
| 44 // and we are just now starting the second reanalyze. If this i
s |
| 45 // the case, then the test isn't testing what it's meant to test |
| 46 // (because we are trying to test what happens when one reanalyz
e |
| 47 // starts while another is in progress). In which case we will |
| 48 // need to give the analyzer more work to do. |
| 49 fail('First reanalyze finished before second started.'); |
| 50 } |
| 51 } |
| 52 }); |
| 53 // Give the server an extra second to make sure it doesn't take any |
| 54 // more actions. |
| 55 return new Future.delayed(new Duration(seconds: 1)); |
| 56 }); |
| 57 }); |
| 58 }); |
| 59 } |
| 60 } |
| 61 |
| 62 main() { |
| 63 runReflectiveTests(Test); |
| 64 } |
| OLD | NEW |