Building test targets in Chromium

Generally, we use 'gn gen out/Debug' and 'ninja -C out/Debug chrome' to build the chromium. Sometimes we need some unit tests to be built and run to test those changes. Mostly the unit test targets had already generated by gn gen command. So all we have to do is look for the target name and invoke it from command line.

  1. Look for the ninja build file that containing the unit test source you want to build. For example, the ninja build file containing  'base/files/file_path_unittest.cc' is 'obj/base/base_unittests.ninja', which is driven by 'build.ninja' by a line 'build base$:base_unittests: phony ./base_unittests'.
  2. So, run 'ninja -C out/Debug base:base_unittests' to build the base_unittests executable file.
  3. That’s all.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.