| 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 BUILD_ONLY: "--build-only", | |
| 14 DEBUG_DEVTOOLS: "--debug-devtools", | 13 DEBUG_DEVTOOLS: "--debug-devtools", |
| 15 DEBUG_DEVTOOLS_SHORTHAND: "-d", | 14 DEBUG_DEVTOOLS_SHORTHAND: "-d", |
| 16 TEST_ONLY: "--test-only", | |
| 17 FETCH_CONTENT_SHELL: "--fetch-content-shell", | 15 FETCH_CONTENT_SHELL: "--fetch-content-shell", |
| 18 }; | 16 }; |
| 19 | 17 |
| 20 var IS_DEBUG_ENABLED = utils.includes(process.argv, Flags.DEBUG_DEVTOOLS) || | 18 var IS_DEBUG_ENABLED = utils.includes(process.argv, Flags.DEBUG_DEVTOOLS) || |
| 21 utils.includes(process.argv, Flags.DEBUG_DEVTOOLS_SHORTHAND); | 19 utils.includes(process.argv, Flags.DEBUG_DEVTOOLS_SHORTHAND); |
| 22 var IS_BUILD_ONLY = utils.includes(process.argv, Flags.BUILD_ONLY); | |
| 23 var IS_TEST_ONLY = utils.includes(process.argv, Flags.TEST_ONLY); | |
| 24 var IS_FETCH_CONTENT_SHELL = utils.includes(process.argv, Flags.FETCH_CONTENT_SH
ELL); | 20 var IS_FETCH_CONTENT_SHELL = utils.includes(process.argv, Flags.FETCH_CONTENT_SH
ELL); |
| 25 | 21 |
| 26 var CONTENT_SHELL_ZIP = "content-shell.zip"; | 22 var CONTENT_SHELL_ZIP = "content-shell.zip"; |
| 27 var MAX_CONTENT_SHELLS = 10; | 23 var MAX_CONTENT_SHELLS = 10; |
| 28 var PLATFORM = getPlatform(); | 24 var PLATFORM = getPlatform(); |
| 29 var PYTHON = process.platform === "win32" ? "python.bat" : "python"; | 25 var PYTHON = process.platform === "win32" ? "python.bat" : "python"; |
| 30 | 26 |
| 31 var CHROMIUM_SRC_PATH = path.resolve(__dirname, "..", "..", "..", "..", ".."); | 27 var CHROMIUM_SRC_PATH = path.resolve(__dirname, "..", "..", "..", "..", ".."); |
| 32 var RELEASE_PATH = path.resolve(CHROMIUM_SRC_PATH, "out", "Release"); | 28 var RELEASE_PATH = path.resolve(CHROMIUM_SRC_PATH, "out", "Release"); |
| 33 var BLINK_TEST_PATH = path.resolve(CHROMIUM_SRC_PATH, "blink", "tools", "run_lay
out_tests.py"); | 29 var BLINK_TEST_PATH = path.resolve(CHROMIUM_SRC_PATH, "blink", "tools", "run_lay
out_tests.py"); |
| 34 var CACHE_PATH = path.resolve(__dirname, "..", ".test_cache"); | 30 var CACHE_PATH = path.resolve(__dirname, "..", ".test_cache"); |
| 35 var SOURCE_PATH = path.resolve(__dirname, "..", "front_end"); | 31 var SOURCE_PATH = path.resolve(__dirname, "..", "front_end"); |
| 36 | 32 |
| 33 var useDebugDevtools = true; |
| 34 |
| 37 function main(){ | 35 function main(){ |
| 38 var hasUserCompiledContentShell = utils.isFile(getContentShellBinaryPath(REL
EASE_PATH)); | 36 var hasUserCompiledContentShell = utils.isFile(getContentShellBinaryPath(REL
EASE_PATH)); |
| 39 if (!IS_FETCH_CONTENT_SHELL && hasUserCompiledContentShell) { | 37 if (!IS_FETCH_CONTENT_SHELL && hasUserCompiledContentShell) { |
| 40 var outDir = path.resolve(RELEASE_PATH, ".."); | 38 var outDir = path.resolve(RELEASE_PATH, ".."); |
| 41 if (!IS_DEBUG_ENABLED) { | 39 if (!IS_DEBUG_ENABLED) { |
| 42 console.log("Compiling devtools frontend"); | 40 console.log("Compiling devtools frontend"); |
| 43 shell(`ninja -C ${RELEASE_PATH} devtools_frontend_resources`); | 41 shell(`ninja -C ${RELEASE_PATH} devtools_frontend_resources`); |
| 44 } | 42 } |
| 45 runTests(outDir, {useRelease: !IS_DEBUG_ENABLED}); | 43 if (!IS_DEBUG_ENABLED) |
| 46 return; | 44 useDebugDevtools = false; |
| 47 } | 45 setupAndTest(outDir); |
| 48 if (IS_TEST_ONLY) { | |
| 49 findPreviousUploadedPosition(findMostRecentChromiumCommit()) | |
| 50 .then(commitPosition => runTests(path.resolve(CACHE_PATH, commitPosi
tion, "out"), {useRelease: false})); | |
| 51 return; | 46 return; |
| 52 } | 47 } |
| 53 if (!utils.isDir(CACHE_PATH)) | 48 if (!utils.isDir(CACHE_PATH)) |
| 54 fs.mkdirSync(CACHE_PATH); | 49 fs.mkdirSync(CACHE_PATH); |
| 55 deleteOldContentShells(); | 50 deleteOldContentShells(); |
| 56 findPreviousUploadedPosition(findMostRecentChromiumCommit()) | 51 findPreviousUploadedPosition(findMostRecentChromiumCommit()) |
| 57 .then(onUploadedCommitPosition) | 52 .then(onUploadedCommitPosition) |
| 58 .catch(onError); | 53 .catch(onError); |
| 59 | 54 |
| 60 function onError(error) { | 55 function onError(error) { |
| 61 console.log("Unable to run tests because of error:", error); | 56 console.log("Unable to run tests because of error:", error); |
| 62 console.log(`Try removing the .test_cache folder [${CACHE_PATH}] and ret
rying`); | 57 console.log(`Try removing the .test_cache folder [${CACHE_PATH}] and ret
rying`); |
| 63 } | 58 } |
| 64 } | 59 } |
| 65 main(); | 60 main(); |
| 66 | 61 |
| 67 function onUploadedCommitPosition(commitPosition) | 62 function onUploadedCommitPosition(commitPosition) |
| 68 { | 63 { |
| 69 var contentShellDirPath = path.resolve(CACHE_PATH, commitPosition, "out", "R
elease"); | 64 var contentShellDirPath = path.resolve(CACHE_PATH, commitPosition, "out", "R
elease"); |
| 70 var hasCachedContentShell = utils.isFile(getContentShellBinaryPath(contentSh
ellDirPath)); | 65 var hasCachedContentShell = utils.isFile(getContentShellBinaryPath(contentSh
ellDirPath)); |
| 71 if (hasCachedContentShell) { | 66 if (hasCachedContentShell) { |
| 72 var contentShellPath = path.resolve(CACHE_PATH, commitPosition, "out"); | 67 var contentShellPath = path.resolve(CACHE_PATH, commitPosition, "out"); |
| 73 console.log(`Using cached content shell at: ${contentShellPath}`); | 68 console.log(`Using cached content shell at: ${contentShellPath}`); |
| 74 return buildAndTest(contentShellPath); | 69 return setupAndTest(contentShellPath); |
| 75 } | 70 } |
| 76 return prepareContentShellDirectory(commitPosition) | 71 return prepareContentShellDirectory(commitPosition) |
| 77 .then(downloadContentShell) | 72 .then(downloadContentShell) |
| 78 .then(extractContentShell) | 73 .then(extractContentShell) |
| 79 .then(buildAndTest); | 74 .then(setupAndTest); |
| 80 } | 75 } |
| 81 | 76 |
| 82 function getPlatform() | 77 function getPlatform() |
| 83 { | 78 { |
| 84 if (process.platform === "linux") { | 79 if (process.platform === "linux") { |
| 85 if (process.arch === "x64") | 80 if (process.arch === "x64") |
| 86 return "Linux_x64"; | 81 return "Linux_x64"; |
| 87 throw new Error("Pre-compiled content shells are only available for x64
on Linux"); | 82 throw new Error("Pre-compiled content shells are only available for x64
on Linux"); |
| 88 } | 83 } |
| 89 if (process.platform === "win32") { | 84 if (process.platform === "win32") { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 return path.resolve(dirPath, "content_shell"); | 202 return path.resolve(dirPath, "content_shell"); |
| 208 } | 203 } |
| 209 if (process.platform === "win32") { | 204 if (process.platform === "win32") { |
| 210 return path.resolve(dirPath, "content_shell.exe"); | 205 return path.resolve(dirPath, "content_shell.exe"); |
| 211 } | 206 } |
| 212 if (process.platform === "darwin") { | 207 if (process.platform === "darwin") { |
| 213 return path.resolve(dirPath, "Content Shell.app", "Contents", "MacOS", "
Content Shell"); | 208 return path.resolve(dirPath, "Content Shell.app", "Contents", "MacOS", "
Content Shell"); |
| 214 } | 209 } |
| 215 } | 210 } |
| 216 | 211 |
| 217 function buildAndTest(buildDirectoryPath) | 212 function setupAndTest(buildDirectoryPath) |
| 218 { | 213 { |
| 219 var contentShellResourcesPath = path.resolve(buildDirectoryPath, "Release",
"resources"); | 214 var contentShellResourcesPath = path.resolve(buildDirectoryPath, "Release",
"resources"); |
| 220 build(contentShellResourcesPath); | 215 copyMetadata(contentShellResourcesPath); |
| 221 if (IS_BUILD_ONLY) | 216 runTests(buildDirectoryPath); |
| 222 return; | |
| 223 runTests(buildDirectoryPath, {useRelease: false}); | |
| 224 } | 217 } |
| 225 | 218 |
| 226 function build(contentShellResourcesPath) | 219 function copyMetadata(contentShellResourcesPath) |
| 227 { | 220 { |
| 228 var devtoolsResourcesPath = path.resolve(contentShellResourcesPath, "inspect
or"); | 221 var devtoolsResourcesPath = path.resolve(contentShellResourcesPath, "inspect
or"); |
| 229 var inspectorBackendCommandsPath = path.resolve(devtoolsResourcesPath, "Insp
ectorBackendCommands.js"); | 222 var inspectorBackendCommandsPath = path.resolve(devtoolsResourcesPath, "Insp
ectorBackendCommands.js"); |
| 230 var supportedCSSPropertiesPath = path.resolve(devtoolsResourcesPath, "Suppor
tedCSSProperties.js"); | 223 var supportedCSSPropertiesPath = path.resolve(devtoolsResourcesPath, "Suppor
tedCSSProperties.js"); |
| 231 utils.copy(inspectorBackendCommandsPath, SOURCE_PATH); | 224 utils.copy(inspectorBackendCommandsPath, SOURCE_PATH); |
| 232 utils.copy(supportedCSSPropertiesPath, SOURCE_PATH); | 225 utils.copy(supportedCSSPropertiesPath, SOURCE_PATH); |
| 233 } | 226 } |
| 234 | 227 |
| 235 function runTests(buildDirectoryPath, options) | 228 function runTests(buildDirectoryPath) |
| 236 { | 229 { |
| 237 var testArgs = getInspectorTests().concat([ | 230 var testArgs = getInspectorTests().concat([ |
| 238 "--no-pixel-tests", | 231 "--no-pixel-tests", |
| 239 "--build-directory", | 232 "--build-directory", |
| 240 buildDirectoryPath, | 233 buildDirectoryPath, |
| 241 ]); | 234 ]); |
| 242 if (!options.useRelease) { | 235 if (useDebugDevtools) { |
| 243 testArgs.push("--additional-driver-flag=--debug-devtools"); | 236 testArgs.push("--additional-driver-flag=--debug-devtools"); |
| 244 testArgs.push(`--additional-driver-flag=--custom-devtools-frontend=${SOU
RCE_PATH}`); | 237 testArgs.push(`--additional-driver-flag=--custom-devtools-frontend=${SOU
RCE_PATH}`); |
| 245 } | 238 } |
| 246 if (IS_DEBUG_ENABLED) { | 239 if (IS_DEBUG_ENABLED) { |
| 247 testArgs.push("--additional-driver-flag=--remote-debugging-port=9222"); | 240 testArgs.push("--additional-driver-flag=--remote-debugging-port=9222"); |
| 248 testArgs.push("--time-out-ms=6000000"); | 241 testArgs.push("--time-out-ms=6000000"); |
| 249 console.log("\n============================================="); | 242 console.log("\n============================================="); |
| 250 console.log("Go to: http://localhost:9222/"); | 243 console.log("Go to: http://localhost:9222/"); |
| 251 console.log("Click on link and in console execute: test()"); | 244 console.log("Click on link and in console execute: test()"); |
| 252 console.log("=============================================\n"); | 245 console.log("=============================================\n"); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 267 function getInspectorTests() | 260 function getInspectorTests() |
| 268 { | 261 { |
| 269 var specificTests = process.argv.filter(arg => utils.includes(arg, "inspecto
r")); | 262 var specificTests = process.argv.filter(arg => utils.includes(arg, "inspecto
r")); |
| 270 if (specificTests.length) | 263 if (specificTests.length) |
| 271 return specificTests; | 264 return specificTests; |
| 272 return [ | 265 return [ |
| 273 "inspector*", | 266 "inspector*", |
| 274 "http/tests/inspector*", | 267 "http/tests/inspector*", |
| 275 ]; | 268 ]; |
| 276 } | 269 } |
| OLD | NEW |