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

Side by Side Diff: tools/gn/config_values_extractors_unittest.cc

Issue 524623005: Add testonly flag to GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 unified diff | Download patch
« no previous file with comments | « tools/gn/command_gen.cc ('k') | tools/gn/item.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <sstream> 5 #include <sstream>
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "tools/gn/config.h" 8 #include "tools/gn/config.h"
9 #include "tools/gn/config_values_extractors.h" 9 #include "tools/gn/config_values_extractors.h"
10 #include "tools/gn/target.h" 10 #include "tools/gn/target.h"
(...skipping 10 matching lines...) Expand all
21 struct IncludeWriter { 21 struct IncludeWriter {
22 void operator()(const SourceDir& dir, std::ostream& out) const { 22 void operator()(const SourceDir& dir, std::ostream& out) const {
23 out << dir.value() << " "; 23 out << dir.value() << " ";
24 } 24 }
25 }; 25 };
26 26
27 } // namespace 27 } // namespace
28 28
29 TEST(ConfigValuesExtractors, IncludeOrdering) { 29 TEST(ConfigValuesExtractors, IncludeOrdering) {
30 TestWithScope setup; 30 TestWithScope setup;
31 Err err;
31 32
32 // Construct a chain of dependencies: target -> dep1 -> dep2 33 // Construct a chain of dependencies: target -> dep1 -> dep2
33 // Add representative values: cflags (opaque, always copied) and include_dirs 34 // Add representative values: cflags (opaque, always copied) and include_dirs
34 // (uniquified) to each one so we can check what comes out the other end. 35 // (uniquified) to each one so we can check what comes out the other end.
35 36
36 // Set up dep2, direct and all dependent configs. 37 // Set up dep2, direct and all dependent configs.
37 Config dep2_all(setup.settings(), Label(SourceDir("//dep2/"), "all")); 38 Config dep2_all(setup.settings(), Label(SourceDir("//dep2/"), "all"));
38 dep2_all.config_values().cflags().push_back("--dep2-all"); 39 dep2_all.config_values().cflags().push_back("--dep2-all");
39 dep2_all.config_values().include_dirs().push_back(SourceDir("//dep2/all/")); 40 dep2_all.config_values().include_dirs().push_back(SourceDir("//dep2/all/"));
40 41
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 target.configs().push_back(LabelConfigPair(&target_config)); 94 target.configs().push_back(LabelConfigPair(&target_config));
94 target.deps().push_back(LabelTargetPair(&dep1)); 95 target.deps().push_back(LabelTargetPair(&dep1));
95 96
96 97
97 // Additionally add some values directly on "target". 98 // Additionally add some values directly on "target".
98 target.config_values().cflags().push_back("--target"); 99 target.config_values().cflags().push_back("--target");
99 target.config_values().include_dirs().push_back( 100 target.config_values().include_dirs().push_back(
100 SourceDir("//target/")); 101 SourceDir("//target/"));
101 102
102 // Mark targets resolved. This should push dependent configs. 103 // Mark targets resolved. This should push dependent configs.
103 dep2.OnResolved(); 104 ASSERT_TRUE(dep2.OnResolved(&err));
104 dep1.OnResolved(); 105 ASSERT_TRUE(dep1.OnResolved(&err));
105 target.OnResolved(); 106 ASSERT_TRUE(target.OnResolved(&err));
106 107
107 // Verify cflags by serializing. 108 // Verify cflags by serializing.
108 std::ostringstream flag_out; 109 std::ostringstream flag_out;
109 FlagWriter flag_writer; 110 FlagWriter flag_writer;
110 RecursiveTargetConfigToStream<std::string, FlagWriter>( 111 RecursiveTargetConfigToStream<std::string, FlagWriter>(
111 &target, &ConfigValues::cflags, flag_writer, flag_out); 112 &target, &ConfigValues::cflags, flag_writer, flag_out);
112 EXPECT_EQ(flag_out.str(), 113 EXPECT_EQ(flag_out.str(),
113 "--target --target-config --target-all --target-direct " 114 "--target --target-config --target-all --target-direct "
114 "--dep1-all --dep2-all --dep1-direct "); 115 "--dep1-all --dep2-all --dep1-direct ");
115 116
116 // Verify include dirs by serializing. 117 // Verify include dirs by serializing.
117 std::ostringstream include_out; 118 std::ostringstream include_out;
118 IncludeWriter include_writer; 119 IncludeWriter include_writer;
119 RecursiveTargetConfigToStream<SourceDir, IncludeWriter>( 120 RecursiveTargetConfigToStream<SourceDir, IncludeWriter>(
120 &target, &ConfigValues::include_dirs, include_writer, include_out); 121 &target, &ConfigValues::include_dirs, include_writer, include_out);
121 EXPECT_EQ(include_out.str(), 122 EXPECT_EQ(include_out.str(),
122 "//target/ //target/config/ //target/all/ //target/direct/ " 123 "//target/ //target/config/ //target/all/ //target/direct/ "
123 "//dep1/all/ //dep2/all/ //dep1/direct/ "); 124 "//dep1/all/ //dep2/all/ //dep1/direct/ ");
124 } 125 }
OLDNEW
« no previous file with comments | « tools/gn/command_gen.cc ('k') | tools/gn/item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698