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

Side by Side Diff: third_party/WebKit/Source/devtools/scripts/npm_test.js

Issue 2669593003: DevTools: npm test - add --target=SUB_DIRECTORY_NAME (Closed)
Patch Set: fix readme Created 3 years, 10 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
« no previous file with comments | « third_party/WebKit/Source/devtools/readme.md ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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', // backwards compatibility testing 16 COMPAT_PROTOCOL: '--compat-protocol', // backwards compatibility testing
17 CHROMIUM_PATH: '--chromium-path' // useful for bisecting 17 CHROMIUM_PATH: '--chromium-path', // useful for bisecting
18 TARGET: '--target', // build sub-directory (e.g. Release, D efault)
18 }; 19 };
19 20
20 var COMPAT_URL_MAPPING = { 21 var COMPAT_URL_MAPPING = {
21 '1.2': 'https://storage.googleapis.com/content-shell-devtools-compat/content_s hell_417361.zip', 22 '1.2': 'https://storage.googleapis.com/content-shell-devtools-compat/content_s hell_417361.zip',
22 }; 23 };
23 24
24 var IS_DEBUG_ENABLED = 25 var IS_DEBUG_ENABLED =
25 utils.includes(process.argv, Flags.DEBUG_DEVTOOLS) || utils.includes(process .argv, Flags.DEBUG_DEVTOOLS_SHORTHAND); 26 utils.includes(process.argv, Flags.DEBUG_DEVTOOLS) || utils.includes(process .argv, Flags.DEBUG_DEVTOOLS_SHORTHAND);
26 var COMPAT_PROTOCOL = utils.parseArgs(process.argv)[Flags.COMPAT_PROTOCOL]; 27 var COMPAT_PROTOCOL = utils.parseArgs(process.argv)[Flags.COMPAT_PROTOCOL];
27 var CUSTOM_CHROMIUM_PATH = utils.parseArgs(process.argv)[Flags.CHROMIUM_PATH]; 28 var CUSTOM_CHROMIUM_PATH = utils.parseArgs(process.argv)[Flags.CHROMIUM_PATH];
28 var IS_FETCH_CONTENT_SHELL = utils.includes(process.argv, Flags.FETCH_CONTENT_SH ELL); 29 var IS_FETCH_CONTENT_SHELL = utils.includes(process.argv, Flags.FETCH_CONTENT_SH ELL);
30 var TARGET = utils.parseArgs(process.argv)[Flags.TARGET] || 'Release';
29 31
30 var CONTENT_SHELL_ZIP = 'content-shell.zip'; 32 var CONTENT_SHELL_ZIP = 'content-shell.zip';
31 var MAX_CONTENT_SHELLS = 10; 33 var MAX_CONTENT_SHELLS = 10;
32 var PLATFORM = getPlatform(); 34 var PLATFORM = getPlatform();
33 var PYTHON = process.platform === 'win32' ? 'python.bat' : 'python'; 35 var PYTHON = process.platform === 'win32' ? 'python.bat' : 'python';
34 36
35 var CHROMIUM_SRC_PATH = CUSTOM_CHROMIUM_PATH || path.resolve(__dirname, '..', '. .', '..', '..', '..'); 37 var CHROMIUM_SRC_PATH = CUSTOM_CHROMIUM_PATH || path.resolve(__dirname, '..', '. .', '..', '..', '..');
36 var RELEASE_PATH = path.resolve(CHROMIUM_SRC_PATH, 'out', 'Release'); 38 var RELEASE_PATH = path.resolve(CHROMIUM_SRC_PATH, 'out', TARGET);
37 var BLINK_TEST_PATH = path.resolve(CHROMIUM_SRC_PATH, 'blink', 'tools', 'run_lay out_tests.py'); 39 var BLINK_TEST_PATH = path.resolve(CHROMIUM_SRC_PATH, 'blink', 'tools', 'run_lay out_tests.py');
38 var DEVTOOLS_PATH = path.resolve(CHROMIUM_SRC_PATH, 'third_party', 'WebKit', 'So urce', 'devtools'); 40 var DEVTOOLS_PATH = path.resolve(CHROMIUM_SRC_PATH, 'third_party', 'WebKit', 'So urce', 'devtools');
39 var CACHE_PATH = path.resolve(DEVTOOLS_PATH, '.test_cache'); 41 var CACHE_PATH = path.resolve(DEVTOOLS_PATH, '.test_cache');
40 var SOURCE_PATH = path.resolve(DEVTOOLS_PATH, 'front_end'); 42 var SOURCE_PATH = path.resolve(DEVTOOLS_PATH, 'front_end');
41 43
42 function main() { 44 function main() {
43 if (!utils.isDir(CACHE_PATH)) 45 if (!utils.isDir(CACHE_PATH))
44 fs.mkdirSync(CACHE_PATH); 46 fs.mkdirSync(CACHE_PATH);
45 deleteOldContentShells(); 47 deleteOldContentShells();
46 48
(...skipping 18 matching lines...) Expand all
65 console.log(`Try removing the .test_cache folder [${CACHE_PATH}] and retryin g`); 67 console.log(`Try removing the .test_cache folder [${CACHE_PATH}] and retryin g`);
66 } 68 }
67 } 69 }
68 main(); 70 main();
69 71
70 function runCompatibilityTests() { 72 function runCompatibilityTests() {
71 const folder = `compat-protocol-${COMPAT_PROTOCOL}`; 73 const folder = `compat-protocol-${COMPAT_PROTOCOL}`;
72 utils.removeRecursive(path.resolve(RELEASE_PATH, 'resources', 'inspector')); 74 utils.removeRecursive(path.resolve(RELEASE_PATH, 'resources', 'inspector'));
73 compileFrontend(); 75 compileFrontend();
74 var outPath = path.resolve(CACHE_PATH, folder, 'out'); 76 var outPath = path.resolve(CACHE_PATH, folder, 'out');
75 var contentShellDirPath = path.resolve(outPath, 'Release'); 77 var contentShellDirPath = path.resolve(outPath, TARGET);
76 var hasCachedContentShell = utils.isFile(getContentShellBinaryPath(contentShel lDirPath)); 78 var hasCachedContentShell = utils.isFile(getContentShellBinaryPath(contentShel lDirPath));
77 if (hasCachedContentShell) { 79 if (hasCachedContentShell) {
78 console.log(`Using cached content shell at: ${outPath}`); 80 console.log(`Using cached content shell at: ${outPath}`);
79 copyFrontendToCompatBuildPath(contentShellDirPath, RELEASE_PATH); 81 copyFrontendToCompatBuildPath(contentShellDirPath, RELEASE_PATH);
80 runTests(outPath, IS_DEBUG_ENABLED); 82 runTests(outPath, IS_DEBUG_ENABLED);
81 return; 83 return;
82 } 84 }
83 prepareContentShellDirectory(folder) 85 prepareContentShellDirectory(folder)
84 .then(() => downloadContentShell(COMPAT_URL_MAPPING[COMPAT_PROTOCOL], fold er)) 86 .then(() => downloadContentShell(COMPAT_URL_MAPPING[COMPAT_PROTOCOL], fold er))
85 .then(extractContentShell) 87 .then(extractContentShell)
86 .then(() => copyFrontendToCompatBuildPath(contentShellDirPath, RELEASE_PAT H)) 88 .then(() => copyFrontendToCompatBuildPath(contentShellDirPath, RELEASE_PAT H))
87 .then(() => runTests(outPath, IS_DEBUG_ENABLED)); 89 .then(() => runTests(outPath, IS_DEBUG_ENABLED));
88 } 90 }
89 91
90 function compileFrontend() { 92 function compileFrontend() {
91 console.log('Compiling devtools frontend'); 93 console.log('Compiling devtools frontend');
92 try { 94 try {
93 shell(`ninja -C ${RELEASE_PATH} devtools_frontend_resources`, {cwd: CHROMIUM _SRC_PATH}); 95 shell(`ninja -C ${RELEASE_PATH} devtools_frontend_resources`, {cwd: CHROMIUM _SRC_PATH});
94 } catch (err) { 96 } catch (err) {
95 console.log(err.stdout.toString()); 97 console.log(err.stdout.toString());
96 console.log('ERROR: Cannot compile frontend\n' + err); 98 console.log('ERROR: Cannot compile frontend\n' + err);
97 process.exit(1); 99 process.exit(1);
98 } 100 }
99 } 101 }
100 102
101 function onUploadedCommitPosition(commitPosition) { 103 function onUploadedCommitPosition(commitPosition) {
102 var contentShellDirPath = path.resolve(CACHE_PATH, commitPosition, 'out', 'Rel ease'); 104 var contentShellDirPath = path.resolve(CACHE_PATH, commitPosition, 'out', TARG ET);
103 var contentShellResourcesPath = path.resolve(contentShellDirPath, 'resources') ; 105 var contentShellResourcesPath = path.resolve(contentShellDirPath, 'resources') ;
104 var contentShellPath = path.resolve(CACHE_PATH, commitPosition, 'out'); 106 var contentShellPath = path.resolve(CACHE_PATH, commitPosition, 'out');
105 107
106 var hasCachedContentShell = utils.isFile(getContentShellBinaryPath(contentShel lDirPath)); 108 var hasCachedContentShell = utils.isFile(getContentShellBinaryPath(contentShel lDirPath));
107 if (hasCachedContentShell) { 109 if (hasCachedContentShell) {
108 console.log(`Using cached content shell at: ${contentShellPath}`); 110 console.log(`Using cached content shell at: ${contentShellPath}`);
109 copyFrontend(contentShellResourcesPath); 111 copyFrontend(contentShellResourcesPath);
110 return runTests(contentShellPath, true); 112 return runTests(contentShellPath, true);
111 } 113 }
112 var url = `http://commondatastorage.googleapis.com/chromium-browser-snapshots/ ${PLATFORM}/${commitPosition 114 var url = `http://commondatastorage.googleapis.com/chromium-browser-snapshots/ ${PLATFORM}/${commitPosition
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 234 }
233 235
234 function extractContentShell(contentShellZipPath) { 236 function extractContentShell(contentShellZipPath) {
235 console.log(`Extracting content shell zip: ${contentShellZipPath}`); 237 console.log(`Extracting content shell zip: ${contentShellZipPath}`);
236 var unzipScriptPath = path.resolve(__dirname, 'unzip.py'); 238 var unzipScriptPath = path.resolve(__dirname, 'unzip.py');
237 var src = contentShellZipPath; 239 var src = contentShellZipPath;
238 var dest = path.resolve(path.dirname(src), 'out'); 240 var dest = path.resolve(path.dirname(src), 'out');
239 shell(`${PYTHON} ${unzipScriptPath} ${src} ${dest}`); 241 shell(`${PYTHON} ${unzipScriptPath} ${src} ${dest}`);
240 fs.unlinkSync(src); 242 fs.unlinkSync(src);
241 var originalDirPath = path.resolve(dest, 'content-shell'); 243 var originalDirPath = path.resolve(dest, 'content-shell');
242 var newDirPath = path.resolve(dest, 'Release'); 244 var newDirPath = path.resolve(dest, TARGET);
243 fs.renameSync(originalDirPath, newDirPath); 245 fs.renameSync(originalDirPath, newDirPath);
244 fs.chmodSync(getContentShellBinaryPath(newDirPath), '755'); 246 fs.chmodSync(getContentShellBinaryPath(newDirPath), '755');
245 if (process.platform === 'darwin') { 247 if (process.platform === 'darwin') {
246 var helperPath = path.resolve( 248 var helperPath = path.resolve(
247 newDirPath, 'Content Shell.app', 'Contents', 'Frameworks', 'Content Shel l Helper.app', 'Contents', 'MacOS', 249 newDirPath, 'Content Shell.app', 'Contents', 'Frameworks', 'Content Shel l Helper.app', 'Contents', 'MacOS',
248 'Content Shell Helper'); 250 'Content Shell Helper');
249 fs.chmodSync(helperPath, '755'); 251 fs.chmodSync(helperPath, '755');
250 } 252 }
251 return dest; 253 return dest;
252 } 254 }
253 255
254 function getContentShellBinaryPath(dirPath) { 256 function getContentShellBinaryPath(dirPath) {
255 if (process.platform === 'linux') 257 if (process.platform === 'linux')
256 return path.resolve(dirPath, 'content_shell'); 258 return path.resolve(dirPath, 'content_shell');
257 259
258 if (process.platform === 'win32') 260 if (process.platform === 'win32')
259 return path.resolve(dirPath, 'content_shell.exe'); 261 return path.resolve(dirPath, 'content_shell.exe');
260 262
261 if (process.platform === 'darwin') 263 if (process.platform === 'darwin')
262 return path.resolve(dirPath, 'Content Shell.app', 'Contents', 'MacOS', 'Cont ent Shell'); 264 return path.resolve(dirPath, 'Content Shell.app', 'Contents', 'MacOS', 'Cont ent Shell');
263 } 265 }
264 266
265 function runTests(buildDirectoryPath, useDebugDevtools) { 267 function runTests(buildDirectoryPath, useDebugDevtools) {
266 var testArgs = getInspectorTests().concat([ 268 var testArgs = getInspectorTests().concat([
267 '--no-pixel-tests', 269 '--no-pixel-tests',
268 '--build-directory', 270 '--build-directory',
269 buildDirectoryPath, 271 buildDirectoryPath,
272 '--target',
273 TARGET,
270 ]); 274 ]);
271 if (useDebugDevtools) 275 if (useDebugDevtools)
272 testArgs.push('--additional-driver-flag=--debug-devtools'); 276 testArgs.push('--additional-driver-flag=--debug-devtools');
273 else 277 else
274 console.log('TIP: You can debug a test using: npm run debug-test inspector/t est-name.html'); 278 console.log('TIP: You can debug a test using: npm run debug-test inspector/t est-name.html');
275 279
276 if (COMPAT_PROTOCOL) { 280 if (COMPAT_PROTOCOL) {
277 const platform = `protocol-${COMPAT_PROTOCOL}`; 281 const platform = `protocol-${COMPAT_PROTOCOL}`;
278 const testsPath = path.resolve(DEVTOOLS_PATH, 'tests'); 282 const testsPath = path.resolve(DEVTOOLS_PATH, 'tests');
279 const compatBaselinePath = path.resolve(testsPath, 'baseline', platform); 283 const compatBaselinePath = path.resolve(testsPath, 'baseline', platform);
(...skipping 24 matching lines...) Expand all
304 308
305 function getInspectorTests() { 309 function getInspectorTests() {
306 var specificTests = process.argv.filter(arg => utils.includes(arg, 'inspector' )); 310 var specificTests = process.argv.filter(arg => utils.includes(arg, 'inspector' ));
307 if (specificTests.length) 311 if (specificTests.length)
308 return specificTests; 312 return specificTests;
309 return [ 313 return [
310 'inspector*', 314 'inspector*',
311 'http/tests/inspector*', 315 'http/tests/inspector*',
312 ]; 316 ];
313 } 317 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/readme.md ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698