OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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/functions.h" |
| 7 #include "tools/gn/scheduler.h" |
| 8 #include "tools/gn/test_with_scope.h" |
| 9 |
| 10 TEST(FunctionToolchain, RuntimeOutputs) { |
| 11 Scheduler scheduler; |
| 12 TestWithScope setup; |
| 13 |
| 14 // These runtime outputs are a subset of the outputs so are OK. |
| 15 { |
| 16 TestParseInput input( |
| 17 "toolchain(\"good\") {\n" |
| 18 " tool(\"link\") {\n" |
| 19 " outputs = [ \"foo\" ]\n" |
| 20 " runtime_outputs = [ \"foo\" ]\n" |
| 21 " }\n" |
| 22 "}\n"); |
| 23 ASSERT_FALSE(input.has_error()); |
| 24 |
| 25 Err err; |
| 26 input.parsed()->Execute(setup.scope(), &err); |
| 27 ASSERT_FALSE(err.has_error()) << err.message(); |
| 28 |
| 29 // It should have generated a toolchain. |
| 30 ASSERT_EQ(1u, setup.items().size()); |
| 31 const Toolchain* toolchain = setup.items()[0]->AsToolchain(); |
| 32 ASSERT_TRUE(toolchain); |
| 33 |
| 34 // The toolchain should have a link tool with the two outputs. |
| 35 const Tool* link = toolchain->GetTool(Toolchain::TYPE_LINK); |
| 36 ASSERT_TRUE(link); |
| 37 ASSERT_EQ(1u, link->outputs().list().size()); |
| 38 EXPECT_EQ("foo", link->outputs().list()[0].AsString()); |
| 39 ASSERT_EQ(1u, link->runtime_outputs().list().size()); |
| 40 EXPECT_EQ("foo", link->runtime_outputs().list()[0].AsString()); |
| 41 } |
| 42 |
| 43 // This one is not a subset so should throw an error. |
| 44 { |
| 45 TestParseInput input( |
| 46 "toolchain(\"bad\") {\n" |
| 47 " tool(\"link\") {\n" |
| 48 " outputs = [ \"foo\" ]\n" |
| 49 " runtime_outputs = [ \"bar\" ]\n" |
| 50 " }\n" |
| 51 "}\n"); |
| 52 ASSERT_FALSE(input.has_error()); |
| 53 |
| 54 Err err; |
| 55 input.parsed()->Execute(setup.scope(), &err); |
| 56 ASSERT_TRUE(err.has_error()) << err.message(); |
| 57 } |
| 58 } |
OLD | NEW |