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

Side by Side Diff: tools/gn/scope_per_file_provider_unittest.cc

Issue 51693002: GN: toolchain threading cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/scope_per_file_provider.cc ('k') | tools/gn/settings.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 #include "tools/gn/build_settings.h" 6 #include "tools/gn/build_settings.h"
7 #include "tools/gn/scope_per_file_provider.h" 7 #include "tools/gn/scope_per_file_provider.h"
8 #include "tools/gn/settings.h" 8 #include "tools/gn/settings.h"
9 #include "tools/gn/test_with_scope.h"
9 #include "tools/gn/toolchain.h" 10 #include "tools/gn/toolchain.h"
10 #include "tools/gn/variables.h" 11 #include "tools/gn/variables.h"
11 12
12 TEST(ScopePerFileProvider, Expected) { 13 TEST(ScopePerFileProvider, Expected) {
13 Err err; 14 TestWithScope test;
14
15 BuildSettings build_settings;
16 build_settings.toolchain_manager().SetDefaultToolchainUnlocked(
17 Label(SourceDir("//toolchain/"), "default", SourceDir(), ""),
18 LocationRange(), &err);
19 EXPECT_FALSE(err.has_error());
20
21 build_settings.SetBuildDir(SourceDir("//out/Debug/"));
22 15
23 // Prevent horrible wrapping of calls below. 16 // Prevent horrible wrapping of calls below.
24 #define GPV(val) provider.GetProgrammaticValue(val)->string_value() 17 #define GPV(val) provider.GetProgrammaticValue(val)->string_value()
25 18
26 // Test the default toolchain. 19 // Test the default toolchain.
27 { 20 {
28 Toolchain toolchain(Label(SourceDir("//toolchain/"), "tc")); 21 Scope scope(test.settings());
29 Settings settings(&build_settings, &toolchain, std::string());
30
31 Scope scope(&settings);
32 scope.set_source_dir(SourceDir("//source/")); 22 scope.set_source_dir(SourceDir("//source/"));
33 ScopePerFileProvider provider(&scope); 23 ScopePerFileProvider provider(&scope);
34 24
35 EXPECT_EQ("//toolchain:tc", GPV(variables::kCurrentToolchain)); 25 EXPECT_EQ("//toolchain:default", GPV(variables::kCurrentToolchain));
36 EXPECT_EQ("//toolchain:default", GPV(variables::kDefaultToolchain)); 26 // TODO(brettw) this test harness does not set up the Toolchain manager
27 // which is the source of this value, so we can't test this yet.
28 //EXPECT_EQ("//toolchain:default", GPV(variables::kDefaultToolchain));
37 EXPECT_EQ("//out/Debug", GPV(variables::kRootBuildDir)); 29 EXPECT_EQ("//out/Debug", GPV(variables::kRootBuildDir));
38 EXPECT_EQ("//out/Debug/gen", GPV(variables::kRootGenDir)); 30 EXPECT_EQ("//out/Debug/gen", GPV(variables::kRootGenDir));
39 EXPECT_EQ("//out/Debug", GPV(variables::kRootOutDir)); 31 EXPECT_EQ("//out/Debug", GPV(variables::kRootOutDir));
40 EXPECT_EQ("//out/Debug/gen/source", GPV(variables::kTargetGenDir)); 32 EXPECT_EQ("//out/Debug/gen/source", GPV(variables::kTargetGenDir));
41 EXPECT_EQ("//out/Debug/obj/source", GPV(variables::kTargetOutDir)); 33 EXPECT_EQ("//out/Debug/obj/source", GPV(variables::kTargetOutDir));
42 } 34 }
43 35
44 // Test some with an alternate toolchain. 36 // Test some with an alternate toolchain.
45 { 37 {
46 Toolchain toolchain(Label(SourceDir("//toolchain/"), "tc")); 38 Settings settings(test.build_settings(), "tc");
47 Settings settings(&build_settings, &toolchain, "tc"); 39 Toolchain toolchain(&settings, Label(SourceDir("//toolchain/"), "tc"));
40 settings.set_toolchain_label(toolchain.label());
48 41
49 Scope scope(&settings); 42 Scope scope(&settings);
50 scope.set_source_dir(SourceDir("//source/")); 43 scope.set_source_dir(SourceDir("//source/"));
51 ScopePerFileProvider provider(&scope); 44 ScopePerFileProvider provider(&scope);
52 45
46 EXPECT_EQ("//toolchain:tc", GPV(variables::kCurrentToolchain));
47 // See above.
48 //EXPECT_EQ("//toolchain:default", GPV(variables::kDefaultToolchain));
53 EXPECT_EQ("//out/Debug", GPV(variables::kRootBuildDir)); 49 EXPECT_EQ("//out/Debug", GPV(variables::kRootBuildDir));
54 EXPECT_EQ("//out/Debug/tc/gen", GPV(variables::kRootGenDir)); 50 EXPECT_EQ("//out/Debug/tc/gen", GPV(variables::kRootGenDir));
55 EXPECT_EQ("//out/Debug/tc", GPV(variables::kRootOutDir)); 51 EXPECT_EQ("//out/Debug/tc", GPV(variables::kRootOutDir));
56 EXPECT_EQ("//out/Debug/tc/gen/source", GPV(variables::kTargetGenDir)); 52 EXPECT_EQ("//out/Debug/tc/gen/source", GPV(variables::kTargetGenDir));
57 EXPECT_EQ("//out/Debug/tc/obj/source", GPV(variables::kTargetOutDir)); 53 EXPECT_EQ("//out/Debug/tc/obj/source", GPV(variables::kTargetOutDir));
58 } 54 }
59 } 55 }
OLDNEW
« no previous file with comments | « tools/gn/scope_per_file_provider.cc ('k') | tools/gn/settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698