Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Unified Diff: tools/gn/config_values_extractors_unittest.cc

Issue 1342183003: Allow GN configs to have sub-configs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/config_values_extractors.h ('k') | tools/gn/functions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/config_values_extractors_unittest.cc
diff --git a/tools/gn/config_values_extractors_unittest.cc b/tools/gn/config_values_extractors_unittest.cc
index fa0d0700a29e743a4d31d001b575d21d35fb44f5..b8875eafa854385c7a4ad6a43b8a34e49c8b4991 100644
--- a/tools/gn/config_values_extractors_unittest.cc
+++ b/tools/gn/config_values_extractors_unittest.cc
@@ -36,13 +36,15 @@ TEST(ConfigValuesExtractors, IncludeOrdering) {
// Set up dep2, direct and all dependent configs.
Config dep2_all(setup.settings(), Label(SourceDir("//dep2/"), "all"));
- dep2_all.config_values().cflags().push_back("--dep2-all");
- dep2_all.config_values().include_dirs().push_back(SourceDir("//dep2/all/"));
+ dep2_all.own_values().cflags().push_back("--dep2-all");
+ dep2_all.own_values().include_dirs().push_back(SourceDir("//dep2/all/"));
+ ASSERT_TRUE(dep2_all.OnResolved(&err));
Config dep2_direct(setup.settings(), Label(SourceDir("//dep2/"), "direct"));
- dep2_direct.config_values().cflags().push_back("--dep2-direct");
- dep2_direct.config_values().include_dirs().push_back(
+ dep2_direct.own_values().cflags().push_back("--dep2-direct");
+ dep2_direct.own_values().include_dirs().push_back(
SourceDir("//dep2/direct/"));
+ ASSERT_TRUE(dep2_direct.OnResolved(&err));
Target dep2(setup.settings(), Label(SourceDir("//dep2/"), "dep2"));
dep2.set_output_type(Target::SOURCE_SET);
@@ -51,15 +53,23 @@ TEST(ConfigValuesExtractors, IncludeOrdering) {
dep2.all_dependent_configs().push_back(LabelConfigPair(&dep2_all));
dep2.public_configs().push_back(LabelConfigPair(&dep2_direct));
- // Set up dep1, direct and all dependent configs.
+ // Set up dep1, direct and all dependent configs. Also set up a subconfig
+ // on "dep1_all" to test sub configs.
+ Config dep1_all_sub(setup.settings(), Label(SourceDir("//dep1"), "allch"));
+ dep1_all_sub.own_values().cflags().push_back("--dep1-all-sub");
+ ASSERT_TRUE(dep1_all_sub.OnResolved(&err));
+
Config dep1_all(setup.settings(), Label(SourceDir("//dep1/"), "all"));
- dep1_all.config_values().cflags().push_back("--dep1-all");
- dep1_all.config_values().include_dirs().push_back(SourceDir("//dep1/all/"));
+ dep1_all.own_values().cflags().push_back("--dep1-all");
+ dep1_all.own_values().include_dirs().push_back(SourceDir("//dep1/all/"));
+ dep1_all.configs().push_back(LabelConfigPair(&dep1_all_sub));
+ ASSERT_TRUE(dep1_all.OnResolved(&err));
Config dep1_direct(setup.settings(), Label(SourceDir("//dep1/"), "direct"));
- dep1_direct.config_values().cflags().push_back("--dep1-direct");
- dep1_direct.config_values().include_dirs().push_back(
+ dep1_direct.own_values().cflags().push_back("--dep1-direct");
+ dep1_direct.own_values().include_dirs().push_back(
SourceDir("//dep1/direct/"));
+ ASSERT_TRUE(dep1_direct.OnResolved(&err));
Target dep1(setup.settings(), Label(SourceDir("//dep1/"), "dep1"));
dep1.set_output_type(Target::SOURCE_SET);
@@ -71,22 +81,24 @@ TEST(ConfigValuesExtractors, IncludeOrdering) {
// Set up target, direct and all dependent configs.
Config target_all(setup.settings(), Label(SourceDir("//target/"), "all"));
- target_all.config_values().cflags().push_back("--target-all");
- target_all.config_values().include_dirs().push_back(
- SourceDir("//target/all/"));
+ target_all.own_values().cflags().push_back("--target-all");
+ target_all.own_values().include_dirs().push_back(SourceDir("//target/all/"));
+ ASSERT_TRUE(target_all.OnResolved(&err));
Config target_direct(setup.settings(),
Label(SourceDir("//target/"), "direct"));
- target_direct.config_values().cflags().push_back("--target-direct");
- target_direct.config_values().include_dirs().push_back(
+ target_direct.own_values().cflags().push_back("--target-direct");
+ target_direct.own_values().include_dirs().push_back(
SourceDir("//target/direct/"));
+ ASSERT_TRUE(target_direct.OnResolved(&err));
// This config is applied directly to target.
Config target_config(setup.settings(),
Label(SourceDir("//target/"), "config"));
- target_config.config_values().cflags().push_back("--target-config");
- target_config.config_values().include_dirs().push_back(
+ target_config.own_values().cflags().push_back("--target-config");
+ target_config.own_values().include_dirs().push_back(
SourceDir("//target/config/"));
+ ASSERT_TRUE(target_config.OnResolved(&err));
Target target(setup.settings(), Label(SourceDir("//target/"), "target"));
target.set_output_type(Target::SOURCE_SET);
@@ -96,7 +108,6 @@ TEST(ConfigValuesExtractors, IncludeOrdering) {
target.configs().push_back(LabelConfigPair(&target_config));
target.private_deps().push_back(LabelTargetPair(&dep1));
-
// Additionally add some values directly on "target".
target.config_values().cflags().push_back("--target");
target.config_values().include_dirs().push_back(
@@ -114,7 +125,7 @@ TEST(ConfigValuesExtractors, IncludeOrdering) {
&target, &ConfigValues::cflags, flag_writer, flag_out);
EXPECT_EQ(flag_out.str(),
"--target --target-config --target-all --target-direct "
- "--dep1-all --dep2-all --dep1-direct ");
+ "--dep1-all --dep1-all-sub --dep2-all --dep1-direct ");
// Verify include dirs by serializing.
std::ostringstream include_out;
« no previous file with comments | « tools/gn/config_values_extractors.h ('k') | tools/gn/functions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698