This source file includes following definitions.
- TEST
#include "testing/gtest/include/gtest/gtest.h"
#include "tools/gn/build_settings.h"
#include "tools/gn/scope_per_file_provider.h"
#include "tools/gn/settings.h"
#include "tools/gn/test_with_scope.h"
#include "tools/gn/toolchain.h"
#include "tools/gn/variables.h"
TEST(ScopePerFileProvider, Expected) {
TestWithScope test;
#define GPV(val) provider.GetProgrammaticValue(val)->string_value()
{
Scope scope(test.settings());
scope.set_source_dir(SourceDir("//source/"));
ScopePerFileProvider provider(&scope);
EXPECT_EQ("//toolchain:default", GPV(variables::kCurrentToolchain));
EXPECT_EQ("//out/Debug", GPV(variables::kRootBuildDir));
EXPECT_EQ("//out/Debug/gen", GPV(variables::kRootGenDir));
EXPECT_EQ("//out/Debug", GPV(variables::kRootOutDir));
EXPECT_EQ("//out/Debug/gen/source", GPV(variables::kTargetGenDir));
EXPECT_EQ("//out/Debug/obj/source", GPV(variables::kTargetOutDir));
}
{
Settings settings(test.build_settings(), "tc");
Toolchain toolchain(&settings, Label(SourceDir("//toolchain/"), "tc"));
settings.set_toolchain_label(toolchain.label());
Scope scope(&settings);
scope.set_source_dir(SourceDir("//source/"));
ScopePerFileProvider provider(&scope);
EXPECT_EQ("//toolchain:tc", GPV(variables::kCurrentToolchain));
EXPECT_EQ("//out/Debug", GPV(variables::kRootBuildDir));
EXPECT_EQ("//out/Debug/tc/gen", GPV(variables::kRootGenDir));
EXPECT_EQ("//out/Debug/tc", GPV(variables::kRootOutDir));
EXPECT_EQ("//out/Debug/tc/gen/source", GPV(variables::kTargetGenDir));
EXPECT_EQ("//out/Debug/tc/obj/source", GPV(variables::kTargetOutDir));
}
}