Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Chromium browser_tests working #8297

Closed
jonathanKingston opened this issue Feb 18, 2020 · 7 comments · Fixed by brave/brave-core#7953
Closed

Get Chromium browser_tests working #8297

jonathanKingston opened this issue Feb 18, 2020 · 7 comments · Fixed by brave/brave-core#7953

Comments

@jonathanKingston
Copy link

Running npm run test -- browser_tests currently ends in a compiler error preventing any of the tests to run.

This means I can't verify Chromium test are broken with other changes such as: #8184

@jonathanKingston
Copy link
Author

Also for the record, I see a lot of test failures already when running this locally. Stuff that likely could be causing issues. I have no idea what runs in CI however it's must not be running at least for a debug build.

@bsclifton
Copy link
Member

bsclifton commented Feb 19, 2020

@jonathanKingston do you have more information about this? ex: what error are you getting?

I wasn't aware that we're exposing a way to build the unit / browser tests for Chromium. Will take a look at this

@bsclifton
Copy link
Member

OK reproduced:

../../chrome/browser/apps/guest_view/web_view_browsertest.cc:187:64: error: no viable conversion from 'OnceCallback<MakeUnboundRunType<void ((anonymous namespace)::ContextMenuShownObserver::*)(BraveRenderViewContextMenu *), base::internal::UnretainedWrapper<(anonymous namespace)::ContextMenuShownObserver> >>' to 'OnceCallback<void (RenderViewContextMenu_Chromium *)>'
    RenderViewContextMenu::RegisterMenuShownCallbackForTesting(base::BindOnce(
                                                               ^~~~~~~~~~~~~~~
../../base/callback.h:64:3: note: candidate constructor not viable: no known conversion from 'OnceCallback<MakeUnboundRunType<void ((anonymous namespace)::ContextMenuShownObserver::*)(BraveRenderViewContextMenu *), base::internal::UnretainedWrapper<(anonymous namespace)::ContextMenuShownObserver> > >' (aka 'OnceCallback<void (BraveRenderViewContextMenu *)>') to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
  OnceCallback(std::nullptr_t) = delete;
  ^
../../base/callback.h:69:3: note: candidate constructor not viable: no known conversion from 'OnceCallback<MakeUnboundRunType<void ((anonymous namespace)::ContextMenuShownObserver::*)(BraveRenderViewContextMenu *), base::internal::UnretainedWrapper<(anonymous namespace)::ContextMenuShownObserver> > >' (aka 'OnceCallback<void (BraveRenderViewContextMenu *)>') to 'const base::OnceCallback<void (RenderViewContextMenu_Chromium *)> &' for 1st argument
  OnceCallback(const OnceCallback&) = delete;
  ^
../../base/callback.h:72:3: note: candidate constructor not viable: no known conversion from 'OnceCallback<MakeUnboundRunType<void ((anonymous namespace)::ContextMenuShownObserver::*)(BraveRenderViewContextMenu *), base::internal::UnretainedWrapper<(anonymous namespace)::ContextMenuShownObserver> > >' (aka 'OnceCallback<void (BraveRenderViewContextMenu *)>') to 'base::OnceCallback<void (RenderViewContextMenu_Chromium *)> &&' for 1st argument
  OnceCallback(OnceCallback&&) noexcept = default;
  ^
../../base/callback.h:75:3: note: candidate constructor not viable: no known conversion from 'OnceCallback<MakeUnboundRunType<void ((anonymous namespace)::ContextMenuShownObserver::*)(BraveRenderViewContextMenu *), base::internal::UnretainedWrapper<(anonymous namespace)::ContextMenuShownObserver> > >' (aka 'OnceCallback<void (BraveRenderViewContextMenu *)>') to 'RepeatingCallback<base::OnceCallback<void (RenderViewContextMenu_Chromium *)>::RunType>' (aka 'RepeatingCallback<void (RenderViewContextMenu_Chromium *)>') for 1st argument
  OnceCallback(RepeatingCallback<RunType> other)
  ^
../../brave/chromium_src/chrome/browser/renderer_context_menu/../../../../../chrome/browser/renderer_context_menu/render_view_context_menu.h:89:56: note: passing argument to parameter 'cb' here
      base::OnceCallback<void(RenderViewContextMenu*)> cb);
                                                       ^
../../chrome/browser/apps/guest_view/web_view_browsertest.cc:2366:7: error: no viable conversion from 'OnceCallback<MakeUnboundRunType<(lambda at ../../chrome/browser/apps/guest_view/web_view_browsertest.cc:2355:39) &, base::RepeatingCallback<void ()> >>' to 'OnceCallback<void (RenderViewContextMenu_Chromium *)>'
      base::BindOnce(close_menu_and_stop_run_loop, run_loop.QuitClosure()));
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../base/callback.h:64:3: note: candidate constructor not viable: no known conversion from 'OnceCallback<MakeUnboundRunType<(lambda at ../../chrome/browser/apps/guest_view/web_view_browsertest.cc:2355:39) &, base::RepeatingCallback<void ()> > >' (aka 'OnceCallback<void (BraveRenderViewContextMenu *)>') to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
  OnceCallback(std::nullptr_t) = delete;
  ^
../../base/callback.h:69:3: note: candidate constructor not viable: no known conversion from 'OnceCallback<MakeUnboundRunType<(lambda at ../../chrome/browser/apps/guest_view/web_view_browsertest.cc:2355:39) &, base::RepeatingCallback<void ()> > >' (aka 'OnceCallback<void (BraveRenderViewContextMenu *)>') to 'const base::OnceCallback<void (RenderViewContextMenu_Chromium *)> &' for 1st argument
  OnceCallback(const OnceCallback&) = delete;
  ^
../../base/callback.h:72:3: note: candidate constructor not viable: no known conversion from 'OnceCallback<MakeUnboundRunType<(lambda at ../../chrome/browser/apps/guest_view/web_view_browsertest.cc:2355:39) &, base::RepeatingCallback<void ()> > >' (aka 'OnceCallback<void (BraveRenderViewContextMenu *)>') to 'base::OnceCallback<void (RenderViewContextMenu_Chromium *)> &&' for 1st argument
  OnceCallback(OnceCallback&&) noexcept = default;
  ^
../../base/callback.h:75:3: note: candidate constructor not viable: no known conversion from 'OnceCallback<MakeUnboundRunType<(lambda at ../../chrome/browser/apps/guest_view/web_view_browsertest.cc:2355:39) &, base::RepeatingCallback<void ()> > >' (aka 'OnceCallback<void (BraveRenderViewContextMenu *)>') to 'RepeatingCallback<base::OnceCallback<void (RenderViewContextMenu_Chromium *)>::RunType>' (aka 'RepeatingCallback<void (RenderViewContextMenu_Chromium *)>') for 1st argument
  OnceCallback(RepeatingCallback<RunType> other)
  ^
../../brave/chromium_src/chrome/browser/renderer_context_menu/../../../../../chrome/browser/renderer_context_menu/render_view_context_menu.h:89:56: note: passing argument to parameter 'cb' here
      base::OnceCallback<void(RenderViewContextMenu*)> cb);
                                                       ^
2 errors generated.

Going to pull your branch down and give it a go 😄

@jonathanKingston
Copy link
Author

@bsclifton it's noisy certainly, however the --filter flag is useful for running certain tests. I ran the tests for roughly 4 hours. There are about 1k of tests that fail.

I'm hoping to chase down the following error lines:

[18421:18431:0219/015138.807643:ERROR:service_manager.cc(210)] Failed to resolve service name: bat_ledger
[18421:18431:0219/015138.807738:ERROR:service_manager.cc(210)] Failed to resolve service name: bat_ads

Which account for well over 1k of the console lines.

@bsclifton
Copy link
Member

bsclifton commented Feb 19, 2020

@jonathanKingston I think you'll need to modify brave-browser as well; for example, check out:

program
.command('test <suite>')
.option('--v [log_level]', 'set log level to [log_level]', parseInt, '0')
.option('--filter <filter>', 'set test filter')
.option('--output <output>', 'set test output (results) file path')
.option('--disable_brave_extension', 'disable loading the Brave extension')
.option('--single_process', 'uses a single process to run tests to help with debugging')
.option('--test_launcher_jobs <test_launcher_jobs>', 'Number of jobs to launch')
.option('--target_os <target_os>', 'target OS')
.option('--target_arch <target_arch>', 'target architecture')
.arguments('[build_config]')
.action(test)

and also:

util.run('ninja', ['-C', config.outputDir, suite], config.defaultOptions)

Although, I think it's working as expected (since it passes the suite name through, for which there is a browser_tests executable). Edit may only be needed for running Chromium unit tests

Definitely missing something- maybe the Chromium browser tests would need to be patched to include test files from Ads / Ledger (to register a stub for the service). But I did verify your patch gets it compiling 😄

@jonathanKingston
Copy link
Author

Definitely missing something- maybe the Chromium browser tests would need to be patched to include test files from Ads / Ledger (to register a stub for the service). But I did verify your patch gets it compiling 😄

Yeah I agree, however it seems to be test specific. The error isn't in every every test and the browser appears to have the code.
It could also be a linking error from the code differences in src/chrome/test/BUILD.gn and src/brave/test/BUILD.gn

@mariospr
Copy link
Contributor

Similar to what I mentioned in detail in #8376 (comment) for the case of getting unit_tests building, I've started looking into fixing the compilation errors for browser_test as well, which at the moment look very similar to the ones mentioned by @bsclifton in #8297 (comment).

And the good news is that I just got them building with a very small adjustment in the source overrides for //c/b/renderer_context_menu/render_view_context_menu.h:

 chromium_src/chrome/browser/renderer_context_menu/render_view_context_menu.cc | 13 +++++++++++++
 chromium_src/chrome/browser/renderer_context_menu/render_view_context_menu.h  |  9 ++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

And since it's just such a small change, I've repurposed #14001 so that it's not just about fixing the build for unit_tests but also for browser_tests and so we have already a small PR that should fix the build of both binaries, check it out here: brave/brave-core#7899

I'm going to look next into which browser_tests are failing and which ones we could easily skip in a similar fashion to how I did it for unit_tests in brave/brave-core#7901, but for the time being I thought a heads up was in order.

PTAL to brave/brave-core#7899 when you have a moment, thanks!

@mariospr mariospr self-assigned this Feb 12, 2021
mariospr added a commit to brave/brave-core that referenced this issue Feb 12, 2021
This patch excludes entire *_browsertest.cc files from being compiled
so that we avoid running any test that we know are going to fail due
to the many ways in which Brave is different than Chromium upstream.

Note that it's possible that this way of excluding tests is a bit too
agressive (i.e. it's likely that some browser tests inside the excluded
files would pass), but for now it's a good enough initial approach as
it enables us to considerably increase test coverage without having
to maintain patches in a too intrusive way.

As a reference, a this time of this patch's writing (on top of Brave
1.22.18 / Chromium 89.0.4389.40), these are the stats when running
upstream's browser tests on a Linux/Debug build, without this patch:

  * Total run: 13337 tests
  * Passed: 11429 tests
  * Not passed: 1908 tests
    - Failed: 871 tests
    - Crashed: 555 tests
    - Timed out: 482 tests

With this patch applied, the numbers look like this:

  * Total run: 6084 tests
  * Passed: 6084 tests
  * Not passed: 0 tests

That is, what we have with this patch applied looks as follows:

  * 6084/13337 -> 45.62% of ALL the original tests being run
  * 6084/11429 -> 53.23% of the PASSING TESTS still being run

In other words, we're increasing test coverage in 6084 browser tests
in a relatively clean way (i.e. no complex patching) while losing
46.77% of the browser tests that would run and pass if we were not
excluding them in such an agressive way. Not as good results as for
the case of unit tests, but still an improvement for test coverage.

Fix brave/brave-browser#8297
mariospr added a commit to brave/brave-core that referenced this issue Mar 12, 2021
This patch disables entire *_browsertest.cc files by making them empty
via chromium_src overrides, as well as all the JS tests via a patch to
include_js_tests.gni, so that we avoid running any test that we know
are going to fail because of the many ways in which Brave is different
than Chromium upstream.

Note that it's possible that this way of excluding tests is a bit too
agressive (i.e. it's likely that some browser tests inside the excluded
files would pass), but for now it's a good enough initial approach as
it enables us to considerably increase test coverage without having
to maintain patches in a too intrusive way.

As a reference, a this time of this patch's writing (on top of Brave
1.23.30 / Chromium 89.0.4389.86), this are the stats when running
upstream's unit tests on a Linux/Debug build, without this patch:

  * Total run: 13355 tests
  * Passed: 10427 tests
  * Not passed: 2928 tests
    - Failed: 870 tests
    - Crashed: 1593 tests
    - Timed out: 465 tests

With this patch applied, the numbers look like this:

  * Total run: 2957 tests
  * Passed: 2957 tests
  * Not passed: 0 tests

That is, what we have with this patch applied looks as follows:

  * 2957/13355 -> 22.14% of ALL the original tests being run
  * 2957/10427 -> 28.36% of the PASSING TESTS still being run

In other words, we're increasing test coverage in 2957 browser tests
in a relatively clean way (i.e. no complex patching) while losing
71.64% of the browser tests that would run and pass if we were not
excluding them in such an agressive way. Not as good results as for
the case of unit tests, but still an improvement for test coverage.

Fix brave/brave-browser#8297
mariospr added a commit to brave/brave-core that referenced this issue Mar 22, 2021
This patch disables entire *_browsertest.cc files by making them empty
via chromium_src overrides, as well as all the JS tests via a patch to
include_js_tests.gni, so that we avoid running any test that we know
are going to fail because of the many ways in which Brave is different
than Chromium upstream.

Note that it's possible that this way of excluding tests is a bit too
agressive (i.e. it's likely that some browser tests inside the excluded
files would pass), but for now it's a good enough initial approach as
it enables us to considerably increase test coverage without having
to maintain patches in a too intrusive way.

As a reference, a this time of this patch's writing (on top of Brave
1.23.30 / Chromium 89.0.4389.86), this are the stats when running
upstream's unit tests on a Linux/Debug build, without this patch:

  * Total run: 13355 tests
  * Passed: 10427 tests
  * Not passed: 2928 tests
    - Failed: 870 tests
    - Crashed: 1593 tests
    - Timed out: 465 tests

With this patch applied, the numbers look like this:

  * Total run: 2957 tests
  * Passed: 2957 tests
  * Not passed: 0 tests

That is, what we have with this patch applied looks as follows:

  * 2957/13355 -> 22.14% of ALL the original tests being run
  * 2957/10427 -> 28.36% of the PASSING TESTS still being run

In other words, we're increasing test coverage in 2957 browser tests
in a relatively clean way (i.e. no complex patching) while losing
71.64% of the browser tests that would run and pass if we were not
excluding them in such an agressive way. Not as good results as for
the case of unit tests, but still an improvement for test coverage.

Fix brave/brave-browser#8297
@mariospr mariospr added this to the 1.24.x - Nightly milestone Mar 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment