1// Copyright 2014 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/scheduler.h" 7#include "tools/gn/test_with_scope.h" 8 9// Tests that actions can't have output substitutions. 10TEST(ActionTargetGenerator, ActionOutputSubstitutions) { 11 Scheduler scheduler; 12 TestWithScope setup; 13 Scope::ItemVector items_; 14 setup.scope()->set_item_collector(&items_); 15 16 // First test one with no substitutions, this should be valid. 17 TestParseInput input_good( 18 "action(\"foo\") {\n" 19 " script = \"//foo.py\"\n" 20 " sources = [ \"//bar.txt\" ]\n" 21 " outputs = [ \"//out/Debug/one.txt\" ]\n" 22 "}"); 23 ASSERT_FALSE(input_good.has_error()); 24 25 // This should run fine. 26 Err err; 27 input_good.parsed()->Execute(setup.scope(), &err); 28 ASSERT_FALSE(err.has_error()) << err.message(); 29 30 // Same thing with a pattern in the output should fail. 31 TestParseInput input_bad( 32 "action(\"foo\") {\n" 33 " script = \"//foo.py\"\n" 34 " sources = [ \"//bar.txt\" ]\n" 35 " outputs = [ \"//out/Debug/{{source_name_part}}.txt\" ]\n" 36 "}"); 37 ASSERT_FALSE(input_bad.has_error()); 38 39 // This should run fine. 40 input_bad.parsed()->Execute(setup.scope(), &err); 41 ASSERT_TRUE(err.has_error()); 42} 43