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_script_target_writer.h" |
| 8 #include "tools/gn/test_with_scope.h" |
| 9 |
| 10 TEST(GypScriptTargetWriter, 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::CUSTOM); |
| 16 |
| 17 target->sources().push_back(SourceFile("//foo/input1.txt")); |
| 18 target->sources().push_back(SourceFile("//foo/input2.txt")); |
| 19 |
| 20 target->script_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 GypScriptTargetWriter writer(group, SourceDir("//out/gn_gyp/"), out); |
| 32 writer.Run(); |
| 33 |
| 34 const char expected[] = |
| 35 " {\n" |
| 36 " 'target_name': 'bar',\n" |
| 37 " 'type': 'none',\n" |
| 38 " 'actions': [{\n" |
| 39 " 'action_name': 'bar action',\n" |
| 40 " 'action': [\n" |
| 41 " 'ninja',\n" |
| 42 " '-C', '../../out/Debug/obj/foo/bar_ninja',\n" |
| 43 " 'bar',\n" |
| 44 " ],\n" |
| 45 " 'inputs': [\n" |
| 46 " '../../foo/input1.txt',\n" |
| 47 " '../../foo/input2.txt',\n" |
| 48 " ],\n" |
| 49 " 'outputs': [\n" |
| 50 " '../../out/Debug/input1.txt.out',\n" |
| 51 " '../../out/Debug/input2.txt.out',\n" |
| 52 " ],\n" |
| 53 " }],\n" |
| 54 " },\n"; |
| 55 std::string out_str = out.str(); |
| 56 EXPECT_EQ(expected, out_str); |
| 57 } |
OLD | NEW |