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

Unified Diff: tools/gn/ninja_create_bundle_target_writer_unittest.cc

Issue 1892243002: Write a phony target for the top-level directory of a create_bundle target. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments 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/ninja_create_bundle_target_writer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/ninja_create_bundle_target_writer_unittest.cc
diff --git a/tools/gn/ninja_create_bundle_target_writer_unittest.cc b/tools/gn/ninja_create_bundle_target_writer_unittest.cc
index 88e6fbab34dd6336befb97e5d0df4f4497bf081b..44dd8941fc316840b966cdc511f89cd7db7278fb 100644
--- a/tools/gn/ninja_create_bundle_target_writer_unittest.cc
+++ b/tools/gn/ninja_create_bundle_target_writer_unittest.cc
@@ -55,7 +55,8 @@ TEST(NinjaCreateBundleTargetWriter, Run) {
"\n"
"build obj/baz/bar.stamp: stamp "
"bar.bundle/Resources/input1.txt "
- "bar.bundle/Resources/input2.txt\n";
+ "bar.bundle/Resources/input2.txt\n"
+ "build bar.bundle: phony obj/baz/bar.stamp\n";
std::string out_str = out.str();
EXPECT_EQ(expected, out_str);
}
@@ -97,7 +98,52 @@ TEST(NinjaCreateBundleTargetWriter, AssetCatalog) {
"../../foo/Foo.xcassets/foo.imageset/FooIcon-29@2x.png "
"../../foo/Foo.xcassets/foo.imageset/FooIcon-29@3x.png\n"
"\n"
- "build obj/baz/bar.stamp: stamp bar.bundle/Resources/Assets.car\n";
+ "build obj/baz/bar.stamp: stamp bar.bundle/Resources/Assets.car\n"
+ "build bar.bundle: phony obj/baz/bar.stamp\n";
+ std::string out_str = out.str();
+ EXPECT_EQ(expected, out_str);
+}
+
+// Tests that the phony target for the top-level bundle directory is generated
+// correctly.
+TEST(NinjaCreateBundleTargetWriter, BundleRootDirOutput) {
+ TestWithScope setup;
+ Err err;
+
+ setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
+ Target target(setup.settings(), Label(SourceDir("//baz/"), "bar"));
+ target.set_output_type(Target::CREATE_BUNDLE);
+
+ const std::string bundle_root_dir("//out/Debug/bar.bundle/Contents");
+ target.bundle_data().root_dir().assign(bundle_root_dir);
+ target.bundle_data().resources_dir().assign(bundle_root_dir + "/Resources");
+ target.bundle_data().executable_dir().assign(bundle_root_dir + "/MacOS");
+ target.bundle_data().plugins_dir().assign(bundle_root_dir + "/Plug Ins");
+
+ std::vector<SourceFile> sources;
+ sources.push_back(SourceFile("//foo/input1.txt"));
+ sources.push_back(SourceFile("//foo/input2.txt"));
+ target.bundle_data().file_rules().push_back(BundleFileRule(
+ sources, SubstitutionPattern::MakeForTest(
+ "{{bundle_resources_dir}}/{{source_file_part}}")));
+
+ target.SetToolchain(setup.toolchain());
+ ASSERT_TRUE(target.OnResolved(&err));
+
+ std::ostringstream out;
+ NinjaCreateBundleTargetWriter writer(&target, out);
+ writer.Run();
+
+ const char expected[] =
+ "build bar.bundle/Contents/Resources/input1.txt: copy_bundle_data "
+ "../../foo/input1.txt\n"
+ "build bar.bundle/Contents/Resources/input2.txt: copy_bundle_data "
+ "../../foo/input2.txt\n"
+ "\n"
+ "build obj/baz/bar.stamp: stamp "
+ "bar.bundle/Contents/Resources/input1.txt "
+ "bar.bundle/Contents/Resources/input2.txt\n"
+ "build bar.bundle: phony obj/baz/bar.stamp\n";
std::string out_str = out.str();
EXPECT_EQ(expected, out_str);
}
@@ -167,7 +213,8 @@ TEST(NinjaCreateBundleTargetWriter, OrderOnlyDeps) {
"bar.bundle/Resources/input1.txt "
"bar.bundle/Resources/input2.txt "
"bar.bundle/Info.plist "
- "bar.bundle/Resources/Assets.car\n";
+ "bar.bundle/Resources/Assets.car\n"
+ "build bar.bundle: phony obj/baz/bar.stamp\n";
std::string out_str = out.str();
EXPECT_EQ(expected, out_str);
}
« no previous file with comments | « tools/gn/ninja_create_bundle_target_writer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698