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

Unified Diff: tools/gn/ninja_action_target_writer_unittest.cc

Issue 461153002: Fix GN action target writing with no sources list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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_action_target_writer.cc ('k') | tools/gn/substitution_writer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/ninja_action_target_writer_unittest.cc
diff --git a/tools/gn/ninja_action_target_writer_unittest.cc b/tools/gn/ninja_action_target_writer_unittest.cc
index 7e0572037f2d67dcce41c4852c27605c42d5d24c..b2b7f7f43d8a4979a1d527eb74f1340ab50d0ad6 100644
--- a/tools/gn/ninja_action_target_writer_unittest.cc
+++ b/tools/gn/ninja_action_target_writer_unittest.cc
@@ -28,6 +28,41 @@ TEST(NinjaActionTargetWriter, WriteOutputFilesForBuildLine) {
EXPECT_EQ(" gen/a$ bbar.h gen/bar.cc", out.str());
}
+// Tests an action with no sources.
+TEST(NinjaActionTargetWriter, ActionNoSources) {
+ TestWithScope setup;
+ setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
+ Target target(setup.settings(), Label(SourceDir("//foo/"), "bar"));
+ target.set_output_type(Target::ACTION);
+
+ target.action_values().set_script(SourceFile("//foo/script.py"));
+ target.inputs().push_back(SourceFile("//foo/included.txt"));
+
+ target.action_values().outputs() =
+ SubstitutionList::MakeForTest("//out/Debug/foo.out");
+
+ setup.settings()->set_target_os(Settings::LINUX);
+ setup.build_settings()->set_python_path(base::FilePath(FILE_PATH_LITERAL(
+ "/usr/bin/python")));
+
+ std::ostringstream out;
+ NinjaActionTargetWriter writer(&target, setup.toolchain(), out);
+ writer.Run();
+
+ const char expected[] =
+ "rule __foo_bar___rule\n"
+ " command = /usr/bin/python ../../foo/script.py\n"
+ " description = ACTION //foo:bar()\n"
+ " restat = 1\n"
+ "build obj/foo/bar.inputdeps.stamp: stamp ../../foo/script.py "
+ "../../foo/included.txt\n"
+ "\n"
+ "build foo.out: __foo_bar___rule | obj/foo/bar.inputdeps.stamp\n"
+ "\n"
+ "build obj/foo/bar.stamp: stamp foo.out\n";
+ EXPECT_EQ(expected, out.str());
+}
+
// Makes sure that we write sources as input dependencies for actions with
// both sources and inputs (ACTION_FOREACH treats the sources differently).
TEST(NinjaActionTargetWriter, ActionWithSources) {
« no previous file with comments | « tools/gn/ninja_action_target_writer.cc ('k') | tools/gn/substitution_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698