browser_tests is the only executable target to compile those tests so you need to use it in any case even if you perform a change in a single test. But you may want to try shared library compilation to improve the speed of your builds. For that just export GYP_DEFINES='component=shared_library'
and then ./build/gyp_chromium
before recompiling.
Build Chromium webui test without rebuilding all browser_tests
-
28-08-2022 - |
Pergunta
I added a simple JavaScript test to /src/chrome/test/data/webui/
and included the file in /src/chrome/chrome_tests.gypi
.
I built it like this: ninja -C out/Debug browser_tests
. That takes a while though. Is there a way to rebuild my test only, without also building all the other browser tests?
Solução
Outras dicas
NOTE: This answer is not applicable to webui tests (they do not depend on test_data_dir_
. Further, it is only relevant to Linux.
Some test files is not compiled into browser_tests
. For these cases, just set the CR_SOURCE_ROOT
environment variable to the Chromium source directory, e.g. (if your Chromium source files are located at ~/chromium/src
)
CR_SOURCE_ROOT=~/chromium/src/ ./out/Debug/browser_tests
I discovered this when I tried to figure out why the extension tests did not run. I started with looking up the error message in the source code:
Extension error: Could not load extension from ''. Manifest file is missing or unreadable.
After some debugging with gdb, I found that the test extension that is supposed to be loaded by ExtensionBrowserTest::LoadExtensionWithFlags
did not load because the path was invalid. path
was somehow set to "extensions/api_test/webrequest"
, and because this is not an absolute path, it was cleared in UnpackedInstaller::GetAbsolutePath
by extension_path_ = base::MakeAbsoluteFilePath(extension_path_);
.
Consequently, Chromium tries to load an extension from location "" (empty string), which obviously fails.
Ultimately, I tracked down the cause to test_data_dir_
, which is initialized at DIR_TEST_DATA
, which in turn is derived from DIR_SOURCE_ROOT
, which in turn is read from the CR_SOURCE_ROOT
environment variable. With the following command, my tests ran again, and I was able to update the extension tests without recompiling.
CR_SOURCE_ROOT=~/chromium/src/ ./out/Debug/browser_tests