From ede7eeff5e616ee9bef21ea73e3a38b3d41e465f Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 16 Sep 2019 10:50:54 -0700 Subject: [PATCH 1/7] build: enable native googletests --- BUILD.gn | 48 ++++++++++++++++++- .../browser/ui/accelerator_util_unittests.cc | 15 ++++++ shell/browser/ui/run_all_unittests.cc | 15 ++++++ 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 shell/browser/ui/accelerator_util_unittests.cc create mode 100644 shell/browser/ui/run_all_unittests.cc diff --git a/BUILD.gn b/BUILD.gn index 94aad7e5334ef..3a694c6e11b45 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -4,6 +4,7 @@ import("//build/config/win/manifest.gni") import("//content/public/app/mac_helpers.gni") import("//pdf/features.gni") import("//printing/buildflags/buildflags.gni") +import("//testing/test.gni") import("//third_party/ffmpeg/ffmpeg_options.gni") import("//tools/generate_library_loader/generate_library_loader.gni") import("//tools/grit/grit_rule.gni") @@ -60,6 +61,10 @@ config("branding") { ] } +config("electron_lib_config") { + include_dirs = [ "." ] +} + # We geneate the definitions twice here, once in //electron/electron.d.ts # and once in $target_gen_dir # The one in $target_gen_dir is used for the actual TSC build later one @@ -333,7 +338,10 @@ source_set("electron_lib") { configs += [ "//v8:external_startup_data" ] configs += [ "//third_party/electron_node:node_internals" ] - public_configs = [ ":branding" ] + public_configs = [ + ":branding", + ":electron_lib_config", + ] deps = [ ":atom_js2c", @@ -774,6 +782,7 @@ if (is_mac) { "Libraries", ] public_deps = [ + ":electron_framework_libraries", ":electron_lib", ] deps = [ @@ -1189,6 +1198,43 @@ if (is_mac) { } } +test("shell_browser_ui_unittests") { + sources = [ + "//electron/shell/browser/ui/accelerator_util_unittests.cc", + "//electron/shell/browser/ui/run_all_unittests.cc", + ] + + configs += [ ":electron_lib_config" ] + + deps = [ + ":electron_lib", + "//base", + "//base/test:test_support", + "//testing/gmock", + "//testing/gtest", + "//ui/base", + "//ui/strings", + ] + + if (is_mac) { + # TODO(codebytere): Why do we only need to load these two?? + libs = [ + "StoreKit.framework", + "SecurityInterface.framework", + ] + + # Resolve paths owing to different test executable locations + ldflags = [ + "-F", + rebase_path("external_binaries", root_build_dir), + "-rpath", + "@loader_path", + "-rpath", + "@executable_path/Electron.app/Contents/Frameworks", + ] + } +} + template("dist_zip") { _runtime_deps_target = "${target_name}__deps" _runtime_deps_file = diff --git a/shell/browser/ui/accelerator_util_unittests.cc b/shell/browser/ui/accelerator_util_unittests.cc new file mode 100644 index 0000000000000..ecfaee408be3e --- /dev/null +++ b/shell/browser/ui/accelerator_util_unittests.cc @@ -0,0 +1,15 @@ +// Copyright (c) 2019 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "shell/browser/ui/accelerator_util.h" + +#include "testing/gtest/include/gtest/gtest.h" + +namespace accelerator_util { + +TEST(AcceleratorUtilTest, StringToAccelerator) { + EXPECT_FALSE(false); +} + +} // namespace accelerator_util \ No newline at end of file diff --git a/shell/browser/ui/run_all_unittests.cc b/shell/browser/ui/run_all_unittests.cc new file mode 100644 index 0000000000000..eff83fde07408 --- /dev/null +++ b/shell/browser/ui/run_all_unittests.cc @@ -0,0 +1,15 @@ +// Copyright (c) 2019 GitHub, Inc. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/bind.h" +#include "base/test/launcher/unit_test_launcher.h" +#include "base/test/test_suite.h" +#include "build/build_config.h" + +int main(int argc, char** argv) { + base::TestSuite test_suite(argc, argv); + return base::LaunchUnitTests( + argc, argv, + base::BindOnce(&base::TestSuite::Run, base::Unretained(&test_suite))); +} From 17a8f953f7d25220ea12b759ad1591d1a5c288c8 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 19 Sep 2019 18:15:36 -0700 Subject: [PATCH 2/7] chore: enable native test runs via spec-runner --- script/native-test-targets.json | 3 + script/spec-runner.js | 80 ++++++++++++++++++- .../browser/ui/accelerator_util_unittests.cc | 2 +- 3 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 script/native-test-targets.json diff --git a/script/native-test-targets.json b/script/native-test-targets.json new file mode 100644 index 0000000000000..7819797145775 --- /dev/null +++ b/script/native-test-targets.json @@ -0,0 +1,3 @@ +[ + "shell_browser_ui_unittests" +] \ No newline at end of file diff --git a/script/spec-runner.js b/script/spec-runner.js index 0a588dd6ce52f..5fa1e75da46e1 100755 --- a/script/spec-runner.js +++ b/script/spec-runner.js @@ -12,7 +12,7 @@ const pass = '✓'.green const fail = '✗'.red const args = require('minimist')(process.argv, { - string: ['runners'], + string: ['runners', 'target'], unknown: arg => unknownFlags.push(arg) }) @@ -34,7 +34,8 @@ const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx' const runners = new Map([ ['main', { description: 'Main process specs', run: runMainProcessElectronTests }], - ['remote', { description: 'Remote based specs', run: runRemoteBasedElectronTests }] + ['remote', { description: 'Remote based specs', run: runRemoteBasedElectronTests }], + ['native', { description: 'Native specs', run: runNativeElectronTests }] ]) const specHashPath = path.resolve(__dirname, '../spec/.hash') @@ -48,7 +49,7 @@ if (args.runners) { } console.log('Only running:', runnersToRun) } else { - console.log(`Triggering both ${[...runners.keys()].join(' and ')} runners`) + console.log(`Triggering ${[...runners.keys()].join(' and ')} runners`) } async function main () { @@ -141,6 +142,79 @@ async function runRemoteBasedElectronTests () { console.log(`${pass} Electron remote process tests passed.`) } +async function runNativeElectronTests () { + const TEST_TARGETS = require('./native-test-targets.json') + const outDir = `out/${utils.getOutDir(false)}` + + // If native tests are being run, only one arg would be relevant + if (args.target && !TEST_TARGETS.includes(args.target)) { + console.log(`${fail} ${args.target} must be a subset of [${[TEST_TARGETS].join(', ')}]`) + process.exit(1) + } + + // If a specific target was passed, only build and run that target + if (args.target) { + console.info('\nRunning native test for target:', args.target) + + // Build single test target + const build = childProcess.spawnSync('ninja', ['-C', outDir, args.target], { + cwd: path.resolve(__dirname, '../..'), + stdio: 'inherit' + }) + + // Exit if test target failed to build + if (build.status !== 0) { + console.log(`${fail} ${args.target} failed to build.`) + process.exit(1) + } + + // Run single test target + const run = childProcess.spawnSync(`./${outDir}/${args.target}`, { + cwd: path.resolve(__dirname, '../..'), + stdio: 'inherit' + }) + + if (run.status !== 0) { + console.log(`${fail} ${args.target} test failed.`) + process.exit(1) + } + } else { + // Build all test targets + for (const target of TEST_TARGETS) { + const build = childProcess.spawnSync('ninja', ['-C', outDir, target], { + cwd: path.resolve(__dirname, '../..'), + stdio: 'inherit' + }) + + // Exit if test target failed to build + if (build.status !== 0) { + console.log(`${fail} ${target} failed to build.`) + process.exit(1) + } + } + + // Run test targets + const failures = [] + for (const target of TEST_TARGETS) { + const testRun = childProcess.spawnSync(`./${outDir}/${target}`, { + cwd: path.resolve(__dirname, '../..'), + stdio: 'inherit' + }) + + // Collect failures and log at end + if (testRun.status !== 0) failures.push(target) + } + + // Exit if any failures + if (failures.length > 0) { + console.log(`${fail} Electron native tests failed for the following targets: `, failures) + process.exit(1) + } + } + + console.log(`${pass} Electron native tests passed.`) +} + async function runMainProcessElectronTests () { let exe = path.resolve(BASE, utils.getElectronExec()) const runnerArgs = ['electron/spec-main', ...unknownArgs.slice(2)] diff --git a/shell/browser/ui/accelerator_util_unittests.cc b/shell/browser/ui/accelerator_util_unittests.cc index ecfaee408be3e..feac4c30ca7a2 100644 --- a/shell/browser/ui/accelerator_util_unittests.cc +++ b/shell/browser/ui/accelerator_util_unittests.cc @@ -12,4 +12,4 @@ TEST(AcceleratorUtilTest, StringToAccelerator) { EXPECT_FALSE(false); } -} // namespace accelerator_util \ No newline at end of file +} // namespace accelerator_util From d2e854b595810063ea1a8eda7d8cbb1caeafdc73 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Fri, 20 Sep 2019 10:56:00 -0700 Subject: [PATCH 3/7] spec: add some proof-of-concept unittests --- .circleci/config.yml | 15 +++++++ BUILD.gn | 1 + script/lib/utils.js | 2 +- script/spec-runner.js | 43 ++++++++----------- .../browser/ui/accelerator_util_unittests.cc | 16 ++++++- 5 files changed, 49 insertions(+), 28 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9edc8038ea055..ea62ae7e6f238 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -331,6 +331,14 @@ step-electron-build: &step-electron-build cd src ninja -C out/Default electron -j $NUMBER_OF_NINJA_PROCESSES +step-build-native-test-targets: &step-build-native-test-targets + run: + name: Build native test targets + no_output_timeout: 30m + command: | + cd src + ninja -C out/Default shell_browser_ui_unittests -j $NUMBER_OF_NINJA_PROCESSES + step-maybe-electron-dist-strip: &step-maybe-electron-dist-strip run: name: Strip electron binaries @@ -422,6 +430,7 @@ step-persist-data-for-tests: &step-persist-data-for-tests # Build artifacts - src/out/Default/dist.zip - src/out/Default/mksnapshot.zip + - src/out/Default/shell_browser_ui_unittests - src/out/Default/gen/node_headers - src/out/ffmpeg/ffmpeg.zip - src/electron @@ -822,6 +831,9 @@ steps-electron-build: &steps-electron-build - *step-electron-dist-store - *step-ninja-summary + # Native test targets + - *step-build-native-test-targets + # Node.js headers - *step-nodejs-headers-build - *step-nodejs-headers-store @@ -892,6 +904,9 @@ steps-electron-build-with-inline-checkout-for-tests: &steps-electron-build-with- - *step-electron-dist-store - *step-ninja-summary + # Native test targets + - *step-build-native-test-targets + # Node.js headers - *step-nodejs-headers-build - *step-nodejs-headers-store diff --git a/BUILD.gn b/BUILD.gn index 3a694c6e11b45..3a526f45ab2bc 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1219,6 +1219,7 @@ test("shell_browser_ui_unittests") { if (is_mac) { # TODO(codebytere): Why do we only need to load these two?? libs = [ + "Carbon.framework", "StoreKit.framework", "SecurityInterface.framework", ] diff --git a/script/lib/utils.js b/script/lib/utils.js index 0c1053a1d0898..56a4c8b268864 100644 --- a/script/lib/utils.js +++ b/script/lib/utils.js @@ -27,7 +27,7 @@ function getOutDir (shouldLog) { if (process.env.ELECTRON_OUT_DIR) { return process.env.ELECTRON_OUT_DIR } else { - for (const buildType of ['Debug', 'Testing', 'Release']) { + for (const buildType of ['Debug', 'Testing', 'Release', 'Default']) { const outPath = path.resolve(SRC_DIR, 'out', buildType) if (fs.existsSync(outPath)) { if (shouldLog) console.log(`OUT_DIR is: ${buildType}`) diff --git a/script/spec-runner.js b/script/spec-runner.js index 5fa1e75da46e1..db8ef7c130b3c 100755 --- a/script/spec-runner.js +++ b/script/spec-runner.js @@ -13,6 +13,7 @@ const fail = '✗'.red const args = require('minimist')(process.argv, { string: ['runners', 'target'], + boolean: ['buildNativeTests'], unknown: arg => unknownFlags.push(arg) }) @@ -152,22 +153,26 @@ async function runNativeElectronTests () { process.exit(1) } + // Optionally build all native test targets + if (args.buildNativeTests) { + for (const target of TEST_TARGETS) { + const build = childProcess.spawnSync('ninja', ['-C', outDir, target], { + cwd: path.resolve(__dirname, '../..'), + stdio: 'inherit' + }) + + // Exit if test target failed to build + if (build.status !== 0) { + console.log(`${fail} ${target} failed to build.`) + process.exit(1) + } + } + } + // If a specific target was passed, only build and run that target if (args.target) { console.info('\nRunning native test for target:', args.target) - // Build single test target - const build = childProcess.spawnSync('ninja', ['-C', outDir, args.target], { - cwd: path.resolve(__dirname, '../..'), - stdio: 'inherit' - }) - - // Exit if test target failed to build - if (build.status !== 0) { - console.log(`${fail} ${args.target} failed to build.`) - process.exit(1) - } - // Run single test target const run = childProcess.spawnSync(`./${outDir}/${args.target}`, { cwd: path.resolve(__dirname, '../..'), @@ -179,20 +184,6 @@ async function runNativeElectronTests () { process.exit(1) } } else { - // Build all test targets - for (const target of TEST_TARGETS) { - const build = childProcess.spawnSync('ninja', ['-C', outDir, target], { - cwd: path.resolve(__dirname, '../..'), - stdio: 'inherit' - }) - - // Exit if test target failed to build - if (build.status !== 0) { - console.log(`${fail} ${target} failed to build.`) - process.exit(1) - } - } - // Run test targets const failures = [] for (const target of TEST_TARGETS) { diff --git a/shell/browser/ui/accelerator_util_unittests.cc b/shell/browser/ui/accelerator_util_unittests.cc index feac4c30ca7a2..99f179847874c 100644 --- a/shell/browser/ui/accelerator_util_unittests.cc +++ b/shell/browser/ui/accelerator_util_unittests.cc @@ -9,7 +9,21 @@ namespace accelerator_util { TEST(AcceleratorUtilTest, StringToAccelerator) { - EXPECT_FALSE(false); + struct { + const std::string& description; + bool expected_success; + } keys[] = { + {"♫♫♫♫♫♫♫", false}, {"Cmd+Plus", true}, {"Ctrl+Space", true}, + {"CmdOrCtrl", false}, {"Alt+Tab", true}, {"AltGr+Backspace", true}, + {"Super+Esc", true}, {"Super+X", true}, {"Shift+1", true}, + }; + + for (const auto& key : keys) { + // Initialize empty-but-not-null accelerator + ui::Accelerator out = ui::Accelerator(ui::VKEY_UNKNOWN, ui::EF_NONE); + bool success = StringToAccelerator(key.description, &out); + EXPECT_EQ(success, key.expected_success); + } } } // namespace accelerator_util From 1bf788a4e4325a33ef42bdb71877f5f69655ec95 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 23 Sep 2019 18:33:17 -0700 Subject: [PATCH 4/7] build unittests on windows --- .circleci/config.yml | 13 ++++++++++--- BUILD.gn | 9 +++++++-- appveyor.yml | 2 ++ vsts-arm-test-steps.yml | 9 +++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ea62ae7e6f238..0ff74d0fb2326 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -331,7 +331,7 @@ step-electron-build: &step-electron-build cd src ninja -C out/Default electron -j $NUMBER_OF_NINJA_PROCESSES -step-build-native-test-targets: &step-build-native-test-targets +step-native-unittests-build: &step-native-unittests-build run: name: Build native test targets no_output_timeout: 30m @@ -410,6 +410,11 @@ step-nodejs-headers-store: &step-nodejs-headers-store path: src/out/Default/gen/node_headers.tar.gz destination: node_headers.tar.gz +step-native-unittests-store: &step-native-unittests-store + store_artifacts: + path: src/out/Default/shell_browser_ui_unittests + destination: shell_browser_ui_unittests + step-electron-publish: &step-electron-publish run: name: Publish Electron Dist @@ -832,7 +837,8 @@ steps-electron-build: &steps-electron-build - *step-ninja-summary # Native test targets - - *step-build-native-test-targets + - *step-native-unittests-build + - *step-native-unittests-store # Node.js headers - *step-nodejs-headers-build @@ -905,7 +911,8 @@ steps-electron-build-with-inline-checkout-for-tests: &steps-electron-build-with- - *step-ninja-summary # Native test targets - - *step-build-native-test-targets + - *step-native-unittests-build + - *step-native-unittests-store # Node.js headers - *step-nodejs-headers-build diff --git a/BUILD.gn b/BUILD.gn index 3a526f45ab2bc..a5ab075a98510 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1217,11 +1217,16 @@ test("shell_browser_ui_unittests") { ] if (is_mac) { - # TODO(codebytere): Why do we only need to load these two?? libs = [ + "AVFoundation.framework", "Carbon.framework", - "StoreKit.framework", + "LocalAuthentication.framework", + "QuartzCore.framework", + "Quartz.framework", + "Security.framework", "SecurityInterface.framework", + "ServiceManagement.framework", + "StoreKit.framework", ] # Resolve paths owing to different test executable locations diff --git a/appveyor.yml b/appveyor.yml index 8d35d3ed22537..6d521aef252a0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -83,10 +83,12 @@ build_script: - gn gen out/ffmpeg "--args=import(\"//electron/build/args/ffmpeg.gn\") %GN_EXTRA_ARGS%" - ninja -C out/ffmpeg electron:electron_ffmpeg_zip - ninja -C out/Default electron:electron_dist_zip + - ninja -C out/Default shell_browser_ui_unittests - ninja -C out/Default electron:electron_mksnapshot_zip - ninja -C out/Default electron:electron_chromedriver_zip - ninja -C out/Default third_party/electron_node:headers - appveyor PushArtifact out/Default/dist.zip + - appveyor PushArtifact out/Default/shell_browser_ui_unittests.exe - appveyor PushArtifact out/Default/chromedriver.zip - appveyor PushArtifact out/ffmpeg/ffmpeg.zip - 7z a node_headers.zip out\Default\gen\node_headers diff --git a/vsts-arm-test-steps.yml b/vsts-arm-test-steps.yml index d083f3179f25a..b29ac5cca42c0 100644 --- a/vsts-arm-test-steps.yml +++ b/vsts-arm-test-steps.yml @@ -53,6 +53,15 @@ steps: env: CIRCLE_TOKEN: $(CIRCLECI_TOKEN) +- bash: | + export NATIVE_UNITTESTS=$PWD/src/out/Default/shell_browser_ui_unittests + mkdir -p $NATIVE_UNITTESTS + cd src/electron + node script/download-circleci-artifacts.js --buildNum=$CIRCLE_BUILD_NUM --name=shell_browser_ui_unittests --dest=$NATIVE_UNITTESTS + displayName: 'Download native unittest executables' + env: + CIRCLE_TOKEN: $(CIRCLECI_TOKEN) + - bash: | sh -e /etc/init.d/xvfb start displayName: Setup for headless testing From 7ef4f870f189636a1658c36fae1505250fb07d5e Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 24 Sep 2019 20:58:16 +0200 Subject: [PATCH 5/7] fix unittest artifacts for woa & arm64 --- azure-pipelines-woa.yml | 8 ++++++++ script/spec-runner.js | 3 ++- vsts-arm-test-steps.yml | 6 +++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/azure-pipelines-woa.yml b/azure-pipelines-woa.yml index 352123cd04130..4dde4afb0304c 100644 --- a/azure-pipelines-woa.yml +++ b/azure-pipelines-woa.yml @@ -18,6 +18,14 @@ steps: env: APPVEYOR_TOKEN: $(APPVEYOR_TOKEN) +- powershell: | + $localArtifactPath = "$pwd\src\out\Default\shell_browser_ui_unittests.exe" + $serverArtifactPath = "$env:APPVEYOR_URL/buildjobs/$env:APPVEYOR_JOB_ID/artifacts/shell_browser_ui_unittests.exe" + Invoke-RestMethod -Method Get -Uri $serverArtifactPath -OutFile $localArtifactPath -Headers @{ "Authorization" = "Bearer $env:APPVEYOR_TOKEN" } + displayName: 'Download and extract native test executables for test' + env: + APPVEYOR_TOKEN: $(APPVEYOR_TOKEN) + - powershell: | $localArtifactPath = "$pwd\ffmpeg.zip" $serverArtifactPath = "$env:APPVEYOR_URL/buildjobs/$env:APPVEYOR_JOB_ID/artifacts/ffmpeg.zip" diff --git a/script/spec-runner.js b/script/spec-runner.js index db8ef7c130b3c..b1e66945d433e 100755 --- a/script/spec-runner.js +++ b/script/spec-runner.js @@ -187,13 +187,14 @@ async function runNativeElectronTests () { // Run test targets const failures = [] for (const target of TEST_TARGETS) { + console.info(`Running ./${outDir}/${target}`) const testRun = childProcess.spawnSync(`./${outDir}/${target}`, { cwd: path.resolve(__dirname, '../..'), stdio: 'inherit' }) // Collect failures and log at end - if (testRun.status !== 0) failures.push(target) + if (testRun.status !== 0) failures.push({ target }) } // Exit if any failures diff --git a/vsts-arm-test-steps.yml b/vsts-arm-test-steps.yml index b29ac5cca42c0..29c4a54500145 100644 --- a/vsts-arm-test-steps.yml +++ b/vsts-arm-test-steps.yml @@ -54,10 +54,10 @@ steps: CIRCLE_TOKEN: $(CIRCLECI_TOKEN) - bash: | - export NATIVE_UNITTESTS=$PWD/src/out/Default/shell_browser_ui_unittests - mkdir -p $NATIVE_UNITTESTS + export NATIVE_UNITTESTS_DEST=$PWD/src/out/Default cd src/electron - node script/download-circleci-artifacts.js --buildNum=$CIRCLE_BUILD_NUM --name=shell_browser_ui_unittests --dest=$NATIVE_UNITTESTS + node script/download-circleci-artifacts.js --buildNum=$CIRCLE_BUILD_NUM --name=shell_browser_ui_unittests --dest=$NATIVE_UNITTESTS_DEST + chmod +x $NATIVE_UNITTESTS_DEST/shell_browser_ui_unittests displayName: 'Download native unittest executables' env: CIRCLE_TOKEN: $(CIRCLECI_TOKEN) From 0adfe59b077d5f7d9d7103a73978d309666ff4ea Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Fri, 27 Sep 2019 16:22:49 +0200 Subject: [PATCH 6/7] dry out spec-runner for native tests --- script/spec-runner.js | 49 ++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/script/spec-runner.js b/script/spec-runner.js index b1e66945d433e..e4bcde4a9e588 100755 --- a/script/spec-runner.js +++ b/script/spec-runner.js @@ -50,7 +50,7 @@ if (args.runners) { } console.log('Only running:', runnersToRun) } else { - console.log(`Triggering ${[...runners.keys()].join(' and ')} runners`) + console.log(`Triggering runners: ${[...runners.keys()].join(', ')}`) } async function main () { @@ -144,18 +144,18 @@ async function runRemoteBasedElectronTests () { } async function runNativeElectronTests () { - const TEST_TARGETS = require('./native-test-targets.json') + let testTargets = require('./native-test-targets.json') const outDir = `out/${utils.getOutDir(false)}` // If native tests are being run, only one arg would be relevant - if (args.target && !TEST_TARGETS.includes(args.target)) { - console.log(`${fail} ${args.target} must be a subset of [${[TEST_TARGETS].join(', ')}]`) + if (args.target && !testTargets.includes(args.target)) { + console.log(`${fail} ${args.target} must be a subset of [${[testTargets].join(', ')}]`) process.exit(1) } // Optionally build all native test targets if (args.buildNativeTests) { - for (const target of TEST_TARGETS) { + for (const target of testTargets) { const build = childProcess.spawnSync('ninja', ['-C', outDir, target], { cwd: path.resolve(__dirname, '../..'), stdio: 'inherit' @@ -170,38 +170,25 @@ async function runNativeElectronTests () { } // If a specific target was passed, only build and run that target - if (args.target) { - console.info('\nRunning native test for target:', args.target) + if (args.target) testTargets = [args.target] - // Run single test target - const run = childProcess.spawnSync(`./${outDir}/${args.target}`, { + // Run test targets + const failures = [] + for (const target of testTargets) { + console.info('\nRunning native test for target:', target) + const testRun = childProcess.spawnSync(`./${outDir}/${target}`, { cwd: path.resolve(__dirname, '../..'), stdio: 'inherit' }) - if (run.status !== 0) { - console.log(`${fail} ${args.target} test failed.`) - process.exit(1) - } - } else { - // Run test targets - const failures = [] - for (const target of TEST_TARGETS) { - console.info(`Running ./${outDir}/${target}`) - const testRun = childProcess.spawnSync(`./${outDir}/${target}`, { - cwd: path.resolve(__dirname, '../..'), - stdio: 'inherit' - }) - - // Collect failures and log at end - if (testRun.status !== 0) failures.push({ target }) - } + // Collect failures and log at end + if (testRun.status !== 0) failures.push({ target }) + } - // Exit if any failures - if (failures.length > 0) { - console.log(`${fail} Electron native tests failed for the following targets: `, failures) - process.exit(1) - } + // Exit if any failures + if (failures.length > 0) { + console.log(`${fail} Electron native tests failed for the following targets: `, failures) + process.exit(1) } console.log(`${pass} Electron native tests passed.`) From 0ee351e434237b7c3542f4fbbf76ea47083e456b Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Fri, 27 Sep 2019 16:23:11 +0200 Subject: [PATCH 7/7] move macOS frameworks to electron_lib --- BUILD.gn | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index a5ab075a98510..ec505f2f3b4bc 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -483,6 +483,19 @@ source_set("electron_lib") { "//content/common:mac_helpers", "//ui/accelerated_widget_mac", ] + + libs = [ + "AVFoundation.framework", + "Carbon.framework", + "LocalAuthentication.framework", + "QuartzCore.framework", + "Quartz.framework", + "Security.framework", + "SecurityInterface.framework", + "ServiceManagement.framework", + "StoreKit.framework", + ] + sources += [ "shell/browser/ui/views/autofill_popup_view.cc", "shell/browser/ui/views/autofill_popup_view.h", @@ -804,18 +817,6 @@ if (is_mac) { include_dirs = [ "." ] sources = filenames.framework_sources - libs = [ - "AVFoundation.framework", - "Carbon.framework", - "LocalAuthentication.framework", - "QuartzCore.framework", - "Quartz.framework", - "Security.framework", - "SecurityInterface.framework", - "ServiceManagement.framework", - "StoreKit.framework", - ] - if (enable_osr) { libs += [ "IOSurface.framework" ] } @@ -1217,18 +1218,6 @@ test("shell_browser_ui_unittests") { ] if (is_mac) { - libs = [ - "AVFoundation.framework", - "Carbon.framework", - "LocalAuthentication.framework", - "QuartzCore.framework", - "Quartz.framework", - "Security.framework", - "SecurityInterface.framework", - "ServiceManagement.framework", - "StoreKit.framework", - ] - # Resolve paths owing to different test executable locations ldflags = [ "-F", @@ -1236,7 +1225,7 @@ test("shell_browser_ui_unittests") { "-rpath", "@loader_path", "-rpath", - "@executable_path/Electron.app/Contents/Frameworks", + "@executable_path/" + rebase_path("external_binaries", root_build_dir), ] } }