| 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", | 13 BUILD_ONLY: "--build-only", |
| 14 DEBUG_DEVTOOLS: "--debug-devtools", | 14 DEBUG_DEVTOOLS: "--debug-devtools", |
| 15 DEBUG_DEVTOOLS_SHORTHAND: "-d", |
| 15 TEST_ONLY: "--test-only", | 16 TEST_ONLY: "--test-only", |
| 17 FETCH_CONTENT_SHELL: "--fetch-content-shell", |
| 16 }; | 18 }; |
| 17 | 19 |
| 18 var IS_DEBUG_ENABLED = utils.includes(process.argv, Flags.DEBUG_DEVTOOLS); | 20 var IS_DEBUG_ENABLED = utils.includes(process.argv, Flags.DEBUG_DEVTOOLS) || |
| 21 utils.includes(process.argv, Flags.DEBUG_DEVTOOLS_SHORTHAND); |
| 19 var IS_BUILD_ONLY = utils.includes(process.argv, Flags.BUILD_ONLY); | 22 var IS_BUILD_ONLY = utils.includes(process.argv, Flags.BUILD_ONLY); |
| 20 var IS_TEST_ONLY = utils.includes(process.argv, Flags.TEST_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); |
| 21 | 25 |
| 22 var CONTENT_SHELL_ZIP = "content-shell.zip"; | 26 var CONTENT_SHELL_ZIP = "content-shell.zip"; |
| 23 var MAX_CONTENT_SHELLS = 10; | 27 var MAX_CONTENT_SHELLS = 10; |
| 24 var PLATFORM = getPlatform(); | 28 var PLATFORM = getPlatform(); |
| 25 var PYTHON = process.platform === "win32" ? "python.bat" : "python"; | 29 var PYTHON = process.platform === "win32" ? "python.bat" : "python"; |
| 26 | 30 |
| 27 var BLINK_TEST_PATH = path.resolve(__dirname, "..", "..", "..", "..", "..", "bli
nk", "tools", "run_layout_tests.py"); | 31 var CHROMIUM_SRC_PATH = path.resolve(__dirname, "..", "..", "..", "..", ".."); |
| 32 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"); |
| 28 var CACHE_PATH = path.resolve(__dirname, "..", ".test_cache"); | 34 var CACHE_PATH = path.resolve(__dirname, "..", ".test_cache"); |
| 29 var SOURCE_PATH = path.resolve(__dirname, "..", "front_end"); | 35 var SOURCE_PATH = path.resolve(__dirname, "..", "front_end"); |
| 30 | 36 |
| 31 function main(){ | 37 function main(){ |
| 38 var hasUserCompiledContentShell = utils.isFile(getContentShellBinaryPath(REL
EASE_PATH)); |
| 39 if (!IS_FETCH_CONTENT_SHELL && hasUserCompiledContentShell) { |
| 40 var outDir = path.resolve(RELEASE_PATH, ".."); |
| 41 if (!IS_DEBUG_ENABLED) { |
| 42 console.log("Compiling devtools frontend"); |
| 43 shell(`ninja -C ${RELEASE_PATH} devtools_frontend_resources`); |
| 44 } |
| 45 runTests(outDir, {useRelease: !IS_DEBUG_ENABLED}); |
| 46 return; |
| 47 } |
| 32 if (IS_TEST_ONLY) { | 48 if (IS_TEST_ONLY) { |
| 33 findPreviousUploadedPosition(findMostRecentChromiumCommit()) | 49 findPreviousUploadedPosition(findMostRecentChromiumCommit()) |
| 34 .then(commitPosition => runTests(path.resolve(CACHE_PATH, commitPosi
tion, "out"))); | 50 .then(commitPosition => runTests(path.resolve(CACHE_PATH, commitPosi
tion, "out"), {useRelease: false})); |
| 35 return; | 51 return; |
| 36 } | 52 } |
| 37 if (!utils.isDir(CACHE_PATH)) | 53 if (!utils.isDir(CACHE_PATH)) |
| 38 fs.mkdirSync(CACHE_PATH); | 54 fs.mkdirSync(CACHE_PATH); |
| 39 deleteOldContentShells(); | 55 deleteOldContentShells(); |
| 40 findPreviousUploadedPosition(findMostRecentChromiumCommit()) | 56 findPreviousUploadedPosition(findMostRecentChromiumCommit()) |
| 41 .then(onUploadedCommitPosition) | 57 .then(onUploadedCommitPosition) |
| 42 .catch(onError); | 58 .catch(onError); |
| 43 | 59 |
| 44 function onError(error) { | 60 function onError(error) { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 return path.resolve(dirPath, "Content Shell.app", "Contents", "MacOS", "
Content Shell"); | 213 return path.resolve(dirPath, "Content Shell.app", "Contents", "MacOS", "
Content Shell"); |
| 198 } | 214 } |
| 199 } | 215 } |
| 200 | 216 |
| 201 function buildAndTest(buildDirectoryPath) | 217 function buildAndTest(buildDirectoryPath) |
| 202 { | 218 { |
| 203 var contentShellResourcesPath = path.resolve(buildDirectoryPath, "Release",
"resources"); | 219 var contentShellResourcesPath = path.resolve(buildDirectoryPath, "Release",
"resources"); |
| 204 build(contentShellResourcesPath); | 220 build(contentShellResourcesPath); |
| 205 if (IS_BUILD_ONLY) | 221 if (IS_BUILD_ONLY) |
| 206 return; | 222 return; |
| 207 runTests(buildDirectoryPath); | 223 runTests(buildDirectoryPath, {useRelease: false}); |
| 208 } | 224 } |
| 209 | 225 |
| 210 function build(contentShellResourcesPath) | 226 function build(contentShellResourcesPath) |
| 211 { | 227 { |
| 212 var devtoolsResourcesPath = path.resolve(contentShellResourcesPath, "inspect
or"); | 228 var devtoolsResourcesPath = path.resolve(contentShellResourcesPath, "inspect
or"); |
| 213 var copiedFrontendPath = path.resolve(devtoolsResourcesPath, "front_end"); | 229 var copiedFrontendPath = path.resolve(devtoolsResourcesPath, "front_end"); |
| 214 var debugPath = path.resolve(devtoolsResourcesPath, "debug"); | 230 var debugPath = path.resolve(devtoolsResourcesPath, "debug"); |
| 215 utils.removeRecursive(copiedFrontendPath); | 231 utils.removeRecursive(copiedFrontendPath); |
| 216 utils.removeRecursive(debugPath); | 232 utils.removeRecursive(debugPath); |
| 217 utils.copyRecursive(SOURCE_PATH, devtoolsResourcesPath); | 233 utils.copyRecursive(SOURCE_PATH, devtoolsResourcesPath); |
| 218 fs.renameSync(copiedFrontendPath, debugPath); | 234 fs.renameSync(copiedFrontendPath, debugPath); |
| 219 var inspectorBackendCommandsPath = path.resolve(devtoolsResourcesPath, "Insp
ectorBackendCommands.js"); | 235 var inspectorBackendCommandsPath = path.resolve(devtoolsResourcesPath, "Insp
ectorBackendCommands.js"); |
| 220 var supportedCSSPropertiesPath = path.resolve(devtoolsResourcesPath, "Suppor
tedCSSProperties.js"); | 236 var supportedCSSPropertiesPath = path.resolve(devtoolsResourcesPath, "Suppor
tedCSSProperties.js"); |
| 221 utils.copy(inspectorBackendCommandsPath, debugPath); | 237 utils.copy(inspectorBackendCommandsPath, debugPath); |
| 222 utils.copy(supportedCSSPropertiesPath, debugPath); | 238 utils.copy(supportedCSSPropertiesPath, debugPath); |
| 223 } | 239 } |
| 224 | 240 |
| 225 function runTests(buildDirectoryPath) | 241 function runTests(buildDirectoryPath, options) |
| 226 { | 242 { |
| 227 var testArgs = [ | 243 var testArgs = getInspectorTests().concat([ |
| 228 "--additional-drt-flag=--debug-devtools", | |
| 229 "--no-pixel-tests", | 244 "--no-pixel-tests", |
| 230 "--build-directory", | 245 "--build-directory", |
| 231 buildDirectoryPath, | 246 buildDirectoryPath, |
| 232 ].concat(getInspectorTests()); | 247 ]); |
| 248 if (!options.useRelease) |
| 249 testArgs.push("--additional-driver-flag=--debug-devtools"); |
| 233 if (IS_DEBUG_ENABLED) { | 250 if (IS_DEBUG_ENABLED) { |
| 234 testArgs.push("--additional-drt-flag=--remote-debugging-port=9222"); | 251 testArgs.push("--additional-driver-flag=--remote-debugging-port=9222"); |
| 235 testArgs.push("--time-out-ms=6000000"); | 252 testArgs.push("--time-out-ms=6000000"); |
| 236 console.log("\n============================================="); | 253 console.log("\n============================================="); |
| 237 console.log("Go to: http://localhost:9222/"); | 254 console.log("Go to: http://localhost:9222/"); |
| 238 console.log("Click on link and in console execute: test()"); | 255 console.log("Click on link and in console execute: test()"); |
| 239 console.log("=============================================\n"); | 256 console.log("=============================================\n"); |
| 240 } | 257 } |
| 241 var args = [BLINK_TEST_PATH].concat(testArgs).concat(getTestFlags()); | 258 var args = [BLINK_TEST_PATH].concat(testArgs).concat(getTestFlags()); |
| 242 console.log(`Running layout tests with args: ${args}`); | 259 console.log(`Running layout tests with args: ${args}`); |
| 243 childProcess.spawn(PYTHON, args, {stdio: "inherit"}); | 260 childProcess.spawn(PYTHON, args, {stdio: "inherit"}); |
| 244 } | 261 } |
| 245 | 262 |
| 246 function getTestFlags() | 263 function getTestFlags() |
| 247 { | 264 { |
| 248 var flagValues = Object.keys(Flags).map(key => Flags[key]); | 265 var flagValues = Object.keys(Flags).map(key => Flags[key]); |
| 249 return process.argv | 266 return process.argv |
| 250 .slice(2) | 267 .slice(2) |
| 251 .filter(arg => !utils.includes(flagValues, arg) && !utils.includes(arg,
"inspector")); | 268 .filter(arg => !utils.includes(flagValues, arg) && !utils.includes(arg,
"inspector")); |
| 252 } | 269 } |
| 253 | 270 |
| 254 function getInspectorTests() | 271 function getInspectorTests() |
| 255 { | 272 { |
| 256 var specificTests = process.argv.filter(arg => utils.includes(arg, "inspecto
r")); | 273 var specificTests = process.argv.filter(arg => utils.includes(arg, "inspecto
r")); |
| 257 if (specificTests.length) | 274 if (specificTests.length) |
| 258 return specificTests; | 275 return specificTests; |
| 259 return [ | 276 return [ |
| 260 "inspector*", | 277 "inspector*", |
| 261 "http/tests/inspector*", | 278 "http/tests/inspector*", |
| 262 ]; | 279 ]; |
| 263 } | 280 } |
| OLD | NEW |