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

Unified Diff: tools/gn/substitution_writer_unittest.cc

Issue 1887533003: Add an output_dir override to GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: const Created 4 years, 8 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/substitution_writer.cc ('k') | tools/gn/target.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/substitution_writer_unittest.cc
diff --git a/tools/gn/substitution_writer_unittest.cc b/tools/gn/substitution_writer_unittest.cc
index 77374f1a313b39e12aee65a548e2997af82338a6..d252c79f54cbd5d4cf250bbd4099a80bafbc529a 100644
--- a/tools/gn/substitution_writer_unittest.cc
+++ b/tools/gn/substitution_writer_unittest.cc
@@ -278,4 +278,46 @@ TEST(SubstitutionWriter, LinkerSubstitutions) {
EXPECT_EQ("",
SubstitutionWriter::GetLinkerSubstitution(
&target, tool, SUBSTITUTION_OUTPUT_EXTENSION));
+
+ // Output directory is tested in a separate test below.
+}
+
+TEST(SubstitutionWriter, OutputDir) {
+ TestWithScope setup;
+ Err err;
+
+ // This tool has an output directory pattern and uses that for the
+ // output name.
+ Tool tool;
+ SubstitutionPattern out_dir_pattern;
+ ASSERT_TRUE(out_dir_pattern.Parse("{{root_out_dir}}/{{target_output_name}}",
+ nullptr, &err));
+ tool.set_default_output_dir(out_dir_pattern);
+ tool.SetComplete();
+
+ // Default target with no output dir overrides.
+ Target target(setup.settings(), Label(SourceDir("//foo/"), "baz"));
+ target.set_output_type(Target::EXECUTABLE);
+ target.SetToolchain(setup.toolchain());
+ ASSERT_TRUE(target.OnResolved(&err));
+
+ // The output should expand the default from the patterns in the tool.
+ SubstitutionPattern output_name;
+ ASSERT_TRUE(output_name.Parse("{{output_dir}}/{{target_output_name}}.exe",
+ nullptr, &err));
+ EXPECT_EQ("./baz/baz.exe",
+ SubstitutionWriter::ApplyPatternToLinkerAsOutputFile(
+ &target, &tool, output_name).value());
+
+ // Override the output name to the root build dir.
+ target.set_output_dir(SourceDir("//out/Debug/"));
+ EXPECT_EQ("./baz.exe",
+ SubstitutionWriter::ApplyPatternToLinkerAsOutputFile(
+ &target, &tool, output_name).value());
+
+ // Override the output name to a new subdirectory.
+ target.set_output_dir(SourceDir("//out/Debug/foo/bar"));
+ EXPECT_EQ("foo/bar/baz.exe",
+ SubstitutionWriter::ApplyPatternToLinkerAsOutputFile(
+ &target, &tool, output_name).value());
}
« no previous file with comments | « tools/gn/substitution_writer.cc ('k') | tools/gn/target.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698