diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-08 19:15:20 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-08 19:15:20 +0000 |
commit | 1e3fbf7bbe7b9a4a4e702c576b5d8dc5ad652da0 (patch) | |
tree | cf29d07d6543c29d11e7daf14f1f10891000ce21 /tools/gn/functions.cc | |
parent | 1cc2ba63a44776e8ebd9d5ed9b3179f06a34651b (diff) | |
download | chromium_src-1e3fbf7bbe7b9a4a4e702c576b5d8dc5ad652da0.zip chromium_src-1e3fbf7bbe7b9a4a4e702c576b5d8dc5ad652da0.tar.gz chromium_src-1e3fbf7bbe7b9a4a4e702c576b5d8dc5ad652da0.tar.bz2 |
Add unit tests for template invocation.
Adds tests for basic functionality of templates, and athrowing errors for unused variables of various types.
Adds some helpers to set up a test invocation of some GN code.
Adds the ability to capture the output from print() calls in a test.
BUG=
Review URL: https://codereview.chromium.org/228123002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262468 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/gn/functions.cc')
-rw-r--r-- | tools/gn/functions.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/gn/functions.cc b/tools/gn/functions.cc index ac1c294..618855b 100644 --- a/tools/gn/functions.cc +++ b/tools/gn/functions.cc @@ -532,12 +532,21 @@ Value RunPrint(Scope* scope, const FunctionCallNode* function, const std::vector<Value>& args, Err* err) { + std::string output; for (size_t i = 0; i < args.size(); i++) { if (i != 0) - std::cout << " "; - std::cout << args[i].ToString(false); + output.push_back(' '); + output.append(args[i].ToString(false)); } - std::cout << std::endl; + output.push_back('\n'); + + const BuildSettings::PrintCallback& cb = + scope->settings()->build_settings()->print_callback(); + if (cb.is_null()) + printf("%s", output.c_str()); + else + cb.Run(output); + return Value(); } |