Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Side by Side Diff: tools/test.dart

Issue 11810004: Make browser tests all run from a server instead of the local filesystem. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env dart 1 #!/usr/bin/env dart
2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 5
6 /** 6 /**
7 * This file is the entrypoint of the dart test suite. This suite is used 7 * This file is the entrypoint of the dart test suite. This suite is used
8 * to test: 8 * to test:
9 * 9 *
10 * 1. the dart vm 10 * 1. the dart vm
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 // Extract global options from first configuration. 75 // Extract global options from first configuration.
76 var firstConf = configurations[0]; 76 var firstConf = configurations[0];
77 Map<String, RegExp> selectors = firstConf['selectors']; 77 Map<String, RegExp> selectors = firstConf['selectors'];
78 var maxProcesses = firstConf['tasks']; 78 var maxProcesses = firstConf['tasks'];
79 var progressIndicator = firstConf['progress']; 79 var progressIndicator = firstConf['progress'];
80 BuildbotProgressIndicator.stepName = firstConf['step_name']; 80 BuildbotProgressIndicator.stepName = firstConf['step_name'];
81 var verbose = firstConf['verbose']; 81 var verbose = firstConf['verbose'];
82 var printTiming = firstConf['time']; 82 var printTiming = firstConf['time'];
83 var listTests = firstConf['list']; 83 var listTests = firstConf['list'];
84 84
85 if (!firstConf['append_flaky_log']) { 85 if (!firstConf['append_flaky_log']) {
86 var file = new File(TestUtils.flakyFileName()); 86 var file = new File(TestUtils.flakyFileName());
87 if (file.existsSync()) { 87 if (file.existsSync()) {
88 file.deleteSync(); 88 file.deleteSync();
89 } 89 }
90 } 90 }
91 91
92 // Print the configurations being run by this execution of 92 // Print the configurations being run by this execution of
93 // test.dart. However, don't do it if the silent progress indicator 93 // test.dart. However, don't do it if the silent progress indicator
94 // is used. This is only needed because of the junit tests. 94 // is used. This is only needed because of the junit tests.
95 if (progressIndicator != 'silent') { 95 if (progressIndicator != 'silent') {
96 List output_words = configurations.length > 1 ? 96 List output_words = configurations.length > 1 ?
97 ['Test configurations:'] : ['Test configuration:']; 97 ['Test configurations:'] : ['Test configuration:'];
98 for (Map conf in configurations) { 98 for (Map conf in configurations) {
99 List settings = ['compiler', 'runtime', 'mode', 'arch'] 99 List settings = ['compiler', 'runtime', 'mode', 'arch']
100 .mappedBy((name) => conf[name]).toList(); 100 .mappedBy((name) => conf[name]).toList();
101 if (conf['checked']) settings.add('checked'); 101 if (conf['checked']) settings.add('checked');
102 output_words.add(Strings.join(settings, '_')); 102 output_words.add(Strings.join(settings, '_'));
103 } 103 }
104 print(Strings.join(output_words, ' ')); 104 print(Strings.join(output_words, ' '));
105 } 105 }
106 106
107 // Start global http servers that serve the entire dart repo.
108 // The http server is available on window.location.port, and a second server
109 // for cross-domain tests can be found by calling getCrossOriginPortNumber().
110 if (!listTests) {
111 // Only start the server if we are running browser tests.
112 var runningBrowserTests = configurations.any((config) {
113 return TestUtils.isBrowserRuntime(config['runtime']);
114 });
115 if (runningBrowserTests) {
116 TestingServerRunner.startHttpServer('127.0.0.1');
117 // We start two servers so that we can test cross-domain tests.
118 TestingServerRunner.startHttpServer('127.0.0.1',
119 allowedPort: TestingServerRunner.serverList[0].port);
120 }
121 }
122
107 var configurationIterator = configurations.iterator; 123 var configurationIterator = configurations.iterator;
108 void enqueueConfiguration(ProcessQueue queue) { 124 void enqueueConfiguration(ProcessQueue queue) {
109 if (!configurationIterator.moveNext()) return; 125 if (!configurationIterator.moveNext()) return;
110 126
111 var conf = configurationIterator.current; 127 var conf = configurationIterator.current;
128 TestingServerRunner.setPackageRootDir(conf);
129
112 for (String key in selectors.keys) { 130 for (String key in selectors.keys) {
113 if (key == 'co19') { 131 if (key == 'co19') {
114 queue.addTestSuite(new Co19TestSuite(conf)); 132 queue.addTestSuite(new Co19TestSuite(conf));
115 } else if (conf['runtime'] == 'vm' && key == 'vm') { 133 } else if (conf['runtime'] == 'vm' && key == 'vm') {
116 // vm tests contain both cc tests (added here) and dart tests (added in 134 // vm tests contain both cc tests (added here) and dart tests (added in
117 // [TEST_SUITE_DIRECTORIES]). 135 // [TEST_SUITE_DIRECTORIES]).
118 queue.addTestSuite(new VMTestSuite(conf)); 136 queue.addTestSuite(new VMTestSuite(conf));
119 } else if (conf['compiler'] == 'dartc' && key == 'dartc') { 137 } else if (conf['compiler'] == 'dartc' && key == 'dartc') {
120 queue.addTestSuite(new SamplesDartcTestSuite(conf)); 138 queue.addTestSuite(new SamplesDartcTestSuite(conf));
121 queue.addTestSuite(new JUnitDartcTestSuite(conf)); 139 queue.addTestSuite(new JUnitDartcTestSuite(conf));
122 } 140 }
123 } 141 }
124 142
125 for (final testSuiteDir in TEST_SUITE_DIRECTORIES) { 143 for (final testSuiteDir in TEST_SUITE_DIRECTORIES) {
126 final name = testSuiteDir.filename; 144 final name = testSuiteDir.filename;
127 if (selectors.containsKey(name)) { 145 if (selectors.containsKey(name)) {
128 queue.addTestSuite( 146 queue.addTestSuite(
129 new StandardTestSuite.forDirectory(conf, testSuiteDir)); 147 new StandardTestSuite.forDirectory(conf, testSuiteDir,
148 serverList: TestingServerRunner.serverList));
130 } 149 }
131 } 150 }
132 } 151 }
133 152
134 // Start global http server that serves the entire dart repo.
135 // The http server is available on localhost:9876 for any
136 // test that needs to load resources from the repo over http.
137 if (!listTests) {
138 // Only start the server if we are running browser tests.
139 var runningBrowserTests = configurations.any((config) {
140 return TestUtils.isBrowserRuntime(config['runtime']);
141 });
142 if (runningBrowserTests) startHttpServer('127.0.0.1', 9876);
143 }
144
145 // Start process queue. 153 // Start process queue.
146 new ProcessQueue(maxProcesses, 154 new ProcessQueue(maxProcesses,
147 progressIndicator, 155 progressIndicator,
148 startTime, 156 startTime,
149 printTiming, 157 printTiming,
150 enqueueConfiguration, 158 enqueueConfiguration,
151 () => terminateHttpServer(), 159 () => TestingServerRunner.terminateHttpServers(),
152 verbose, 160 verbose,
153 listTests); 161 listTests);
154 } 162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698