Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / tools / gn / ninja_action_target_writer_unittest.cc
index c1aa6f4..7254b48 100644 (file)
@@ -119,10 +119,11 @@ TEST(NinjaActionTargetWriter, ActionWithSources) {
         "rule __foo_bar___rule\n"
         "  command = /usr/bin/python ../../foo/script.py\n"
         "  description = ACTION //foo:bar()\n"
-        "  restat = 1"
-        "\n"
+        "  restat = 1\n"
+        "build obj/foo/bar.inputdeps.stamp: "
+            "stamp ../../foo/included.txt ../../foo/source.txt\n"
         "\n"
-        "build foo.out: __foo_bar___rule | ../../foo/included.txt ../../foo/source.txt\n"
+        "build foo.out: __foo_bar___rule | obj/foo/bar.inputdeps.stamp\n"
         "\n"
         "build obj/foo/bar.stamp: stamp foo.out\n";
     std::string out_str = out.str();
@@ -148,13 +149,15 @@ TEST(NinjaActionTargetWriter, ActionWithSources) {
     // depending if we're on actual Windows or Linux pretending to be Windows.
     const char expected_win[] =
         "rule __foo_bar___rule\n"
-        "  command = C:/python/python.exe gyp-win-tool action-wrapper environment.x86 __foo_bar___rule.$unique_name.rsp\n"
+        "  command = C$:/python/python.exe gyp-win-tool action-wrapper environment.x86 __foo_bar___rule.$unique_name.rsp\n"
         "  description = ACTION //foo:bar()\n"
         "  restat = 1\n"
         "  rspfile = __foo_bar___rule.$unique_name.rsp\n"
-        "  rspfile_content = C:/python/python.exe ../../foo/script.py\n"
+        "  rspfile_content = C$:/python/python.exe ../../foo/script.py\n"
+        "build obj/foo/bar.inputdeps.stamp: "
+            "stamp ../../foo/included.txt ../../foo/source.txt\n"
         "\n"
-        "build foo.out: __foo_bar___rule | ../../foo/included.txt ../../foo/source.txt\n"
+        "build foo.out: __foo_bar___rule | obj/foo/bar.inputdeps.stamp\n"
         "\n"
         "build obj/foo/bar.stamp: stamp foo.out\n";
     std::string out_str = out.str();
@@ -168,8 +171,20 @@ TEST(NinjaActionTargetWriter, ActionWithSources) {
 TEST(NinjaActionTargetWriter, ForEach) {
   TestWithScope setup;
   setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/"));
+
+  // Some dependencies that the action can depend on. Use actions for these
+  // so they have a nice platform-independent stamp file that can appear in the
+  // output (rather than having to worry about how the current platform names
+  // binaries).
+  Target dep(setup.settings(), Label(SourceDir("//foo/"), "dep"));
+  dep.set_output_type(Target::ACTION);
+  Target datadep(setup.settings(), Label(SourceDir("//foo/"), "datadep"));
+  datadep.set_output_type(Target::ACTION);
+
   Target target(setup.settings(), Label(SourceDir("//foo/"), "bar"));
   target.set_output_type(Target::ACTION_FOREACH);
+  target.deps().push_back(LabelTargetPair(&dep));
+  target.datadeps().push_back(LabelTargetPair(&datadep));
 
   target.sources().push_back(SourceFile("//foo/input1.txt"));
   target.sources().push_back(SourceFile("//foo/input2.txt"));
@@ -202,17 +217,20 @@ TEST(NinjaActionTargetWriter, ForEach) {
             "\"--out=foo$ bar${source_name_part}.o\"\n"
         "  description = ACTION //foo:bar()\n"
         "  restat = 1\n"
+        "build obj/foo/bar.inputdeps.stamp: "
+            "stamp ../../foo/included.txt obj/foo/dep.stamp\n"
         "\n"
         "build input1.out: __foo_bar___rule ../../foo/input1.txt | "
-            "../../foo/included.txt\n"
+            "obj/foo/bar.inputdeps.stamp\n"
         "  source = ../../foo/input1.txt\n"
         "  source_name_part = input1\n"
         "build input2.out: __foo_bar___rule ../../foo/input2.txt | "
-            "../../foo/included.txt\n"
+            "obj/foo/bar.inputdeps.stamp\n"
         "  source = ../../foo/input2.txt\n"
         "  source_name_part = input2\n"
         "\n"
-        "build obj/foo/bar.stamp: stamp input1.out input2.out\n";
+        "build obj/foo/bar.stamp: "
+            "stamp input1.out input2.out obj/foo/datadep.stamp\n";
 
     std::string out_str = out.str();
 #if defined(OS_WIN)
@@ -237,26 +255,29 @@ TEST(NinjaActionTargetWriter, ForEach) {
     // depending if we're on actual Windows or Linux pretending to be Windows.
     const char expected_win[] =
         "rule __foo_bar___rule\n"
-        "  command = C:/python/python.exe gyp-win-tool action-wrapper "
+        "  command = C$:/python/python.exe gyp-win-tool action-wrapper "
             "environment.x86 __foo_bar___rule.$unique_name.rsp\n"
         "  description = ACTION //foo:bar()\n"
         "  restat = 1\n"
         "  rspfile = __foo_bar___rule.$unique_name.rsp\n"
-        "  rspfile_content = C:/python/python.exe ../../foo/script.py -i "
+        "  rspfile_content = C$:/python/python.exe ../../foo/script.py -i "
             "${source} \"--out=foo$ bar${source_name_part}.o\"\n"
+        "build obj/foo/bar.inputdeps.stamp: "
+            "stamp ../../foo/included.txt obj/foo/dep.stamp\n"
         "\n"
         "build input1.out: __foo_bar___rule ../../foo/input1.txt | "
-            "../../foo/included.txt\n"
+            "obj/foo/bar.inputdeps.stamp\n"
         "  unique_name = 0\n"
         "  source = ../../foo/input1.txt\n"
         "  source_name_part = input1\n"
         "build input2.out: __foo_bar___rule ../../foo/input2.txt | "
-            "../../foo/included.txt\n"
+            "obj/foo/bar.inputdeps.stamp\n"
         "  unique_name = 1\n"
         "  source = ../../foo/input2.txt\n"
         "  source_name_part = input2\n"
         "\n"
-        "build obj/foo/bar.stamp: stamp input1.out input2.out\n";
+        "build obj/foo/bar.stamp: "
+            "stamp input1.out input2.out obj/foo/datadep.stamp\n";
     std::string out_str = out.str();
 #if defined(OS_WIN)
     std::replace(out_str.begin(), out_str.end(), '\\', '/');
@@ -304,14 +325,15 @@ TEST(NinjaActionTargetWriter, ForEachWithDepfile) {
             "\"--out=foo$ bar${source_name_part}.o\"\n"
         "  description = ACTION //foo:bar()\n"
         "  restat = 1\n"
+        "build obj/foo/bar.inputdeps.stamp: stamp ../../foo/included.txt\n"
         "\n"
         "build gen/input1.d input1.out: __foo_bar___rule ../../foo/input1.txt"
-            " | ../../foo/included.txt\n"
+            " | obj/foo/bar.inputdeps.stamp\n"
         "  source = ../../foo/input1.txt\n"
         "  source_name_part = input1\n"
         "  depfile = gen/input1.d\n"
         "build gen/input2.d input2.out: __foo_bar___rule ../../foo/input2.txt"
-            " | ../../foo/included.txt\n"
+            " | obj/foo/bar.inputdeps.stamp\n"
         "  source = ../../foo/input2.txt\n"
         "  source_name_part = input2\n"
         "  depfile = gen/input2.d\n"
@@ -341,22 +363,23 @@ TEST(NinjaActionTargetWriter, ForEachWithDepfile) {
     // depending if we're on actual Windows or Linux pretending to be Windows.
     const char expected_win[] =
         "rule __foo_bar___rule\n"
-        "  command = C:/python/python.exe gyp-win-tool action-wrapper "
+        "  command = C$:/python/python.exe gyp-win-tool action-wrapper "
             "environment.x86 __foo_bar___rule.$unique_name.rsp\n"
         "  description = ACTION //foo:bar()\n"
         "  restat = 1\n"
         "  rspfile = __foo_bar___rule.$unique_name.rsp\n"
-        "  rspfile_content = C:/python/python.exe ../../foo/script.py -i "
+        "  rspfile_content = C$:/python/python.exe ../../foo/script.py -i "
             "${source} \"--out=foo$ bar${source_name_part}.o\"\n"
+        "build obj/foo/bar.inputdeps.stamp: stamp ../../foo/included.txt\n"
         "\n"
         "build gen/input1.d input1.out: __foo_bar___rule ../../foo/input1.txt"
-            " | ../../foo/included.txt\n"
+            " | obj/foo/bar.inputdeps.stamp\n"
         "  unique_name = 0\n"
         "  source = ../../foo/input1.txt\n"
         "  source_name_part = input1\n"
         "  depfile = gen/input1.d\n"
         "build gen/input2.d input2.out: __foo_bar___rule ../../foo/input2.txt"
-            " | ../../foo/included.txt\n"
+            " | obj/foo/bar.inputdeps.stamp\n"
         "  unique_name = 1\n"
         "  source = ../../foo/input2.txt\n"
         "  source_name_part = input2\n"