| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "testing/gtest/include/gtest/gtest.h" | |
| 6 #include "tools/gn/builder_record.h" | |
| 7 #include "tools/gn/gyp_action_target_writer.h" | |
| 8 #include "tools/gn/test_with_scope.h" | |
| 9 | |
| 10 TEST(GypActionTargetWriter, Run) { | |
| 11 TestWithScope setup; | |
| 12 setup.build_settings()->SetBuildDir(SourceDir("//out/Debug/")); | |
| 13 scoped_ptr<Target> target( | |
| 14 new Target(setup.settings(), Label(SourceDir("//foo/"), "bar"))); | |
| 15 target->set_output_type(Target::ACTION); | |
| 16 | |
| 17 target->sources().push_back(SourceFile("//foo/input1.txt")); | |
| 18 target->sources().push_back(SourceFile("//foo/input2.txt")); | |
| 19 | |
| 20 target->action_values().outputs().push_back( | |
| 21 SourceFile("//out/Debug/{{source_file_part}}.out")); | |
| 22 | |
| 23 BuilderRecord record(BuilderRecord::ITEM_TARGET, target->label()); | |
| 24 record.set_item(target.PassAs<Item>()); | |
| 25 GypTargetWriter::TargetGroup group; | |
| 26 group.debug = &record; | |
| 27 | |
| 28 setup.settings()->set_target_os(Settings::WIN); | |
| 29 | |
| 30 std::ostringstream out; | |
| 31 GypActionTargetWriter writer(group, setup.toolchain(), | |
| 32 SourceDir("//out/gn_gyp/"), out); | |
| 33 writer.Run(); | |
| 34 | |
| 35 const char expected[] = | |
| 36 " {\n" | |
| 37 " 'target_name': 'bar',\n" | |
| 38 " 'type': 'none',\n" | |
| 39 " 'actions': [{\n" | |
| 40 " 'action_name': 'bar action',\n" | |
| 41 " 'action': [\n" | |
| 42 " 'ninja',\n" | |
| 43 " '-C', '../../out/Debug/obj/foo/bar_ninja',\n" | |
| 44 " 'bar',\n" | |
| 45 " ],\n" | |
| 46 " 'inputs': [\n" | |
| 47 " '../../foo/input1.txt',\n" | |
| 48 " '../../foo/input2.txt',\n" | |
| 49 " ],\n" | |
| 50 " 'outputs': [\n" | |
| 51 " '../../out/Debug/input1.txt.out',\n" | |
| 52 " '../../out/Debug/input2.txt.out',\n" | |
| 53 " ],\n" | |
| 54 " }],\n" | |
| 55 " },\n"; | |
| 56 std::string out_str = out.str(); | |
| 57 EXPECT_EQ(expected, out_str); | |
| 58 } | |
| OLD | NEW |