OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var childProcess = require('child_process'); | 5 var childProcess = require('child_process'); |
6 var fs = require('fs'); | 6 var fs = require('fs'); |
7 var path = require('path'); | 7 var path = require('path'); |
8 var shell = require('child_process').execSync; | 8 var shell = require('child_process').execSync; |
9 | 9 |
10 var utils = require('./utils'); | 10 var utils = require('./utils'); |
11 | 11 |
12 var Flags = { | 12 var Flags = { |
13 DEBUG_DEVTOOLS: '--debug-devtools', | 13 DEBUG_DEVTOOLS: '--debug-devtools', |
14 DEBUG_DEVTOOLS_SHORTHAND: '-d', | 14 DEBUG_DEVTOOLS_SHORTHAND: '-d', |
15 FETCH_CONTENT_SHELL: '--fetch-content-shell', | 15 FETCH_CONTENT_SHELL: '--fetch-content-shell', |
16 COMPAT_PROTOCOL: '--compat-protocol', | 16 COMPAT_PROTOCOL: '--compat-protocol', // backwards compatibility testing |
| 17 CHROMIUM_PATH: '--chromium-path' // useful for bisecting |
17 }; | 18 }; |
18 | 19 |
19 var COMPAT_URL_MAPPING = { | 20 var COMPAT_URL_MAPPING = { |
20 '1.2': 'https://storage.googleapis.com/content-shell-devtools-compat/content_s
hell_417361.zip', | 21 '1.2': 'https://storage.googleapis.com/content-shell-devtools-compat/content_s
hell_417361.zip', |
21 }; | 22 }; |
22 | 23 |
23 var IS_DEBUG_ENABLED = | 24 var IS_DEBUG_ENABLED = |
24 utils.includes(process.argv, Flags.DEBUG_DEVTOOLS) || utils.includes(process
.argv, Flags.DEBUG_DEVTOOLS_SHORTHAND); | 25 utils.includes(process.argv, Flags.DEBUG_DEVTOOLS) || utils.includes(process
.argv, Flags.DEBUG_DEVTOOLS_SHORTHAND); |
25 var COMPAT_PROTOCOL = utils.parseArgs(process.argv)[Flags.COMPAT_PROTOCOL]; | 26 var COMPAT_PROTOCOL = utils.parseArgs(process.argv)[Flags.COMPAT_PROTOCOL]; |
| 27 var CUSTOM_CHROMIUM_PATH = utils.parseArgs(process.argv)[Flags.CHROMIUM_PATH]; |
26 var IS_FETCH_CONTENT_SHELL = utils.includes(process.argv, Flags.FETCH_CONTENT_SH
ELL); | 28 var IS_FETCH_CONTENT_SHELL = utils.includes(process.argv, Flags.FETCH_CONTENT_SH
ELL); |
27 | 29 |
28 var CONTENT_SHELL_ZIP = 'content-shell.zip'; | 30 var CONTENT_SHELL_ZIP = 'content-shell.zip'; |
29 var MAX_CONTENT_SHELLS = 10; | 31 var MAX_CONTENT_SHELLS = 10; |
30 var PLATFORM = getPlatform(); | 32 var PLATFORM = getPlatform(); |
31 var PYTHON = process.platform === 'win32' ? 'python.bat' : 'python'; | 33 var PYTHON = process.platform === 'win32' ? 'python.bat' : 'python'; |
32 | 34 |
33 var CHROMIUM_SRC_PATH = path.resolve(__dirname, '..', '..', '..', '..', '..'); | 35 var CHROMIUM_SRC_PATH = CUSTOM_CHROMIUM_PATH || path.resolve(__dirname, '..', '.
.', '..', '..', '..'); |
34 var RELEASE_PATH = path.resolve(CHROMIUM_SRC_PATH, 'out', 'Release'); | 36 var RELEASE_PATH = path.resolve(CHROMIUM_SRC_PATH, 'out', 'Release'); |
35 var BLINK_TEST_PATH = path.resolve(CHROMIUM_SRC_PATH, 'blink', 'tools', 'run_lay
out_tests.py'); | 37 var BLINK_TEST_PATH = path.resolve(CHROMIUM_SRC_PATH, 'blink', 'tools', 'run_lay
out_tests.py'); |
36 var DEVTOOLS_PATH = path.resolve(__dirname, '..'); | 38 var DEVTOOLS_PATH = path.resolve(CHROMIUM_SRC_PATH, 'third_party', 'WebKit', 'So
urce', 'devtools'); |
37 var CACHE_PATH = path.resolve(DEVTOOLS_PATH, '.test_cache'); | 39 var CACHE_PATH = path.resolve(DEVTOOLS_PATH, '.test_cache'); |
38 var SOURCE_PATH = path.resolve(DEVTOOLS_PATH, 'front_end'); | 40 var SOURCE_PATH = path.resolve(DEVTOOLS_PATH, 'front_end'); |
39 | 41 |
40 function main() { | 42 function main() { |
41 if (!utils.isDir(CACHE_PATH)) | 43 if (!utils.isDir(CACHE_PATH)) |
42 fs.mkdirSync(CACHE_PATH); | 44 fs.mkdirSync(CACHE_PATH); |
43 deleteOldContentShells(); | 45 deleteOldContentShells(); |
44 | 46 |
45 if (COMPAT_PROTOCOL) { | 47 if (COMPAT_PROTOCOL) { |
46 runCompatibilityTests(); | 48 runCompatibilityTests(); |
(...skipping 13 matching lines...) Expand all Loading... |
60 | 62 |
61 function onError(error) { | 63 function onError(error) { |
62 console.log('Unable to run tests because of error:', error); | 64 console.log('Unable to run tests because of error:', error); |
63 console.log(`Try removing the .test_cache folder [${CACHE_PATH}] and retryin
g`); | 65 console.log(`Try removing the .test_cache folder [${CACHE_PATH}] and retryin
g`); |
64 } | 66 } |
65 } | 67 } |
66 main(); | 68 main(); |
67 | 69 |
68 function runCompatibilityTests() { | 70 function runCompatibilityTests() { |
69 const folder = `compat-protocol-${COMPAT_PROTOCOL}`; | 71 const folder = `compat-protocol-${COMPAT_PROTOCOL}`; |
| 72 utils.removeRecursive(path.resolve(RELEASE_PATH, 'resources', 'inspector')); |
70 compileFrontend(); | 73 compileFrontend(); |
71 var outPath = path.resolve(CACHE_PATH, folder, 'out'); | 74 var outPath = path.resolve(CACHE_PATH, folder, 'out'); |
72 var contentShellDirPath = path.resolve(outPath, 'Release'); | 75 var contentShellDirPath = path.resolve(outPath, 'Release'); |
73 var hasCachedContentShell = utils.isFile(getContentShellBinaryPath(contentShel
lDirPath)); | 76 var hasCachedContentShell = utils.isFile(getContentShellBinaryPath(contentShel
lDirPath)); |
74 if (hasCachedContentShell) { | 77 if (hasCachedContentShell) { |
75 console.log(`Using cached content shell at: ${outPath}`); | 78 console.log(`Using cached content shell at: ${outPath}`); |
76 copyFrontendToCompatBuildPath(contentShellDirPath, RELEASE_PATH); | 79 copyFrontendToCompatBuildPath(contentShellDirPath, RELEASE_PATH); |
77 runTests(outPath, IS_DEBUG_ENABLED); | 80 runTests(outPath, IS_DEBUG_ENABLED); |
78 return; | 81 return; |
79 } | 82 } |
80 prepareContentShellDirectory(folder) | 83 prepareContentShellDirectory(folder) |
81 .then(() => downloadContentShell(COMPAT_URL_MAPPING[COMPAT_PROTOCOL], fold
er)) | 84 .then(() => downloadContentShell(COMPAT_URL_MAPPING[COMPAT_PROTOCOL], fold
er)) |
82 .then(extractContentShell) | 85 .then(extractContentShell) |
83 .then(() => copyFrontendToCompatBuildPath(contentShellDirPath, RELEASE_PAT
H)) | 86 .then(() => copyFrontendToCompatBuildPath(contentShellDirPath, RELEASE_PAT
H)) |
84 .then(() => runTests(outPath, IS_DEBUG_ENABLED)); | 87 .then(() => runTests(outPath, IS_DEBUG_ENABLED)); |
85 } | 88 } |
86 | 89 |
87 function compileFrontend() { | 90 function compileFrontend() { |
88 console.log('Compiling devtools frontend'); | 91 console.log('Compiling devtools frontend'); |
89 try { | 92 try { |
90 shell(`ninja -C ${RELEASE_PATH} devtools_frontend_resources`); | 93 shell(`ninja -C ${RELEASE_PATH} devtools_frontend_resources`, {cwd: CHROMIUM
_SRC_PATH}); |
91 } catch (err) { | 94 } catch (err) { |
92 console.log(err.stdout.toString()); | 95 console.log(err.stdout.toString()); |
93 console.log('ERROR: Cannot compile frontend\n' + err); | 96 console.log('ERROR: Cannot compile frontend\n' + err); |
94 process.exit(1); | 97 process.exit(1); |
95 } | 98 } |
96 } | 99 } |
97 | 100 |
98 function onUploadedCommitPosition(commitPosition) { | 101 function onUploadedCommitPosition(commitPosition) { |
99 var contentShellDirPath = path.resolve(CACHE_PATH, commitPosition, 'out', 'Rel
ease'); | 102 var contentShellDirPath = path.resolve(CACHE_PATH, commitPosition, 'out', 'Rel
ease'); |
100 var contentShellResourcesPath = path.resolve(contentShellDirPath, 'resources')
; | 103 var contentShellResourcesPath = path.resolve(contentShellDirPath, 'resources')
; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 '--no-pixel-tests', | 267 '--no-pixel-tests', |
265 '--build-directory', | 268 '--build-directory', |
266 buildDirectoryPath, | 269 buildDirectoryPath, |
267 ]); | 270 ]); |
268 if (useDebugDevtools) | 271 if (useDebugDevtools) |
269 testArgs.push('--additional-driver-flag=--debug-devtools'); | 272 testArgs.push('--additional-driver-flag=--debug-devtools'); |
270 else | 273 else |
271 console.log('TIP: You can debug a test using: npm run debug-test inspector/t
est-name.html'); | 274 console.log('TIP: You can debug a test using: npm run debug-test inspector/t
est-name.html'); |
272 | 275 |
273 if (COMPAT_PROTOCOL) { | 276 if (COMPAT_PROTOCOL) { |
274 let platform = `protocol-${COMPAT_PROTOCOL}`; | 277 const platform = `protocol-${COMPAT_PROTOCOL}`; |
275 let compatBaselinePath = path.resolve(DEVTOOLS_PATH, 'tests', 'baseline', pl
atform); | 278 const testsPath = path.resolve(DEVTOOLS_PATH, 'tests'); |
| 279 const compatBaselinePath = path.resolve(testsPath, 'baseline', platform); |
276 testArgs.push(`--additional-platform-directory=${compatBaselinePath}`); | 280 testArgs.push(`--additional-platform-directory=${compatBaselinePath}`); |
| 281 const expectationsPath = path.resolve(testsPath, 'TestExpectations'); |
| 282 testArgs.push(`--additional-expectations=${expectationsPath}`); |
277 } | 283 } |
278 if (IS_DEBUG_ENABLED) { | 284 if (IS_DEBUG_ENABLED) { |
279 testArgs.push('--additional-driver-flag=--remote-debugging-port=9222'); | 285 testArgs.push('--additional-driver-flag=--remote-debugging-port=9222'); |
280 testArgs.push('--time-out-ms=6000000'); | 286 testArgs.push('--time-out-ms=6000000'); |
281 console.log('\n============================================='); | 287 console.log('\n============================================='); |
282 console.log('Go to: http://localhost:9222/'); | 288 console.log('Go to: http://localhost:9222/'); |
283 console.log('Click on link and in console execute: test()'); | 289 console.log('Click on link and in console execute: test()'); |
284 console.log('=============================================\n'); | 290 console.log('=============================================\n'); |
285 } | 291 } |
286 var args = [BLINK_TEST_PATH].concat(testArgs).concat(getTestFlags()); | 292 var args = [BLINK_TEST_PATH].concat(testArgs).concat(getTestFlags()); |
(...skipping 11 matching lines...) Expand all Loading... |
298 | 304 |
299 function getInspectorTests() { | 305 function getInspectorTests() { |
300 var specificTests = process.argv.filter(arg => utils.includes(arg, 'inspector'
)); | 306 var specificTests = process.argv.filter(arg => utils.includes(arg, 'inspector'
)); |
301 if (specificTests.length) | 307 if (specificTests.length) |
302 return specificTests; | 308 return specificTests; |
303 return [ | 309 return [ |
304 'inspector*', | 310 'inspector*', |
305 'http/tests/inspector*', | 311 'http/tests/inspector*', |
306 ]; | 312 ]; |
307 } | 313 } |
OLD | NEW |