#ifndef TOOLS_GN_TEST_WITH_SCOPE_H_
#define TOOLS_GN_TEST_WITH_SCOPE_H_
#include <string>
#include <vector>
#include "gn/build_settings.h"
#include "gn/c_tool.h"
#include "gn/err.h"
#include "gn/general_tool.h"
#include "gn/input_file.h"
#include "gn/parse_tree.h"
#include "gn/rust_tool.h"
#include "gn/scope.h"
#include "gn/scope_per_file_provider.h"
#include "gn/settings.h"
#include "gn/target.h"
#include "gn/token.h"
#include "gn/toolchain.h"
#include "gn/value.h"
class TestWithScope {
public:
TestWithScope();
~TestWithScope();
BuildSettings* build_settings() { return &build_settings_; }
Settings* settings() { return &settings_; }
const Settings* settings() const { return &settings_; }
Toolchain* toolchain() { return &toolchain_; }
const Toolchain* toolchain() const { return &toolchain_; }
Scope* scope() { return &scope_; }
const Scope::ItemVector& items() { return items_; }
std::string& print_output() { return print_output_; }
Label ParseLabel(const std::string& str) const;
bool ExecuteSnippet(const std::string& str, Err* err);
Value ExecuteExpression(const std::string& expr, Err* err);
static void SetupToolchain(Toolchain* toolchain, bool use_toc = false);
static void SetCommandForTool(const std::string& cmd, Tool* tool);
private:
void AppendPrintOutput(const std::string& str);
BuildSettings build_settings_;
Settings settings_;
Toolchain toolchain_;
Scope scope_;
Scope::ItemVector items_;
ScopePerFileProvider scope_progammatic_provider_;
std::string print_output_;
TestWithScope(const TestWithScope&) = delete;
TestWithScope& operator=(const TestWithScope&) = delete;
};
class TestParseInput {
public:
explicit TestParseInput(const std::string& input);
~TestParseInput();
bool has_error() const { return parse_err_.has_error(); }
const Err& parse_err() const { return parse_err_; }
const InputFile& input_file() const { return input_file_; }
const std::vector<Token>& tokens() const { return tokens_; }
const ParseNode* parsed() const { return parsed_.get(); }
private:
InputFile input_file_;
std::vector<Token> tokens_;
std::unique_ptr<ParseNode> parsed_;
Err parse_err_;
TestParseInput(const TestParseInput&) = delete;
TestParseInput& operator=(const TestParseInput&) = delete;
};
class TestTarget : public Target {
public:
TestTarget(const TestWithScope& setup,
const std::string& label_string,
Target::OutputType type);
~TestTarget() override;
};
#endif