Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: tools/gn/functions_target_unittest.cc

Issue 420443003: GN foreach should mark the list identifier as used. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/functions_target.cc ('k') | tools/gn/gn.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/functions_target_unittest.cc
diff --git a/tools/gn/functions_target_unittest.cc b/tools/gn/functions_target_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c8f6176c3f5f87fffa79ed682f224d67449a7b20
--- /dev/null
+++ b/tools/gn/functions_target_unittest.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "tools/gn/scheduler.h"
+#include "tools/gn/scope.h"
+#include "tools/gn/test_with_scope.h"
+
+
+// Checks that we find unused identifiers in targets.
+TEST(FunctionsTarget, CheckUnused) {
+ Scheduler scheduler;
+ TestWithScope setup;
+
+ // The target generator needs a place to put the targets or it will fail.
+ Scope::ItemVector item_collector;
+ setup.scope()->set_item_collector(&item_collector);
+
+ // Test a good one first.
+ TestParseInput good_input(
+ "source_set(\"foo\") {\n"
+ "}\n");
+ ASSERT_FALSE(good_input.has_error());
+ Err err;
+ good_input.parsed()->Execute(setup.scope(), &err);
+ ASSERT_FALSE(err.has_error()) << err.message();
+
+ // Test a source set (this covers everything but component) with an unused
+ // variable.
+ TestParseInput source_set_input(
+ "source_set(\"foo\") {\n"
+ " unused = 5\n"
+ "}\n");
+ ASSERT_FALSE(source_set_input.has_error());
+ err = Err();
+ source_set_input.parsed()->Execute(setup.scope(), &err);
+ ASSERT_TRUE(err.has_error());
+
+ // Test a component, which is a different code path.
+ TestParseInput component_input(
+ "component_mode = \"static_library\"\n"
+ "component(\"bar\") {\n"
+ " unused = 5\n"
+ "}\n");
+ ASSERT_FALSE(component_input.has_error());
+ err = Err();
+ component_input.parsed()->Execute(setup.scope(), &err);
+ ASSERT_TRUE(err.has_error()) << err.message();
+}
« no previous file with comments | « tools/gn/functions_target.cc ('k') | tools/gn/gn.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698