mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-27 10:31:16 +00:00
I've migrated the toolchain autoupdate scripts here, I just need a little more time to do the explorer side (which I need to check performance, that may require multithreading as we do in the current script). However, this felt substantial enough to share and it means I can handle autoupdate in more of the toolchain, including preparatory work for autoupdate on multi-file tests. Once explorer is done I'll remove the old script.
47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#ifndef CARBON_TESTING_FILE_TEST_LINE_H_
|
|
#define CARBON_TESTING_FILE_TEST_LINE_H_
|
|
|
|
#include "common/ostream.h"
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
namespace Carbon::Testing {
|
|
|
|
// Interface for lines.
|
|
class FileTestLineBase {
|
|
public:
|
|
explicit FileTestLineBase(int line_number) : line_number_(line_number) {}
|
|
virtual ~FileTestLineBase() {}
|
|
|
|
// Prints the autoupdated line.
|
|
virtual auto Print(llvm::raw_ostream& out) const -> void = 0;
|
|
|
|
auto line_number() const -> int { return line_number_; }
|
|
|
|
private:
|
|
int line_number_;
|
|
};
|
|
|
|
// A line in the original file test.
|
|
class FileTestLine : public FileTestLineBase {
|
|
public:
|
|
explicit FileTestLine(int line_number, llvm::StringRef line)
|
|
: FileTestLineBase(line_number), line_(line) {}
|
|
|
|
auto Print(llvm::raw_ostream& out) const -> void override { out << line_; }
|
|
|
|
auto indent() const -> llvm::StringRef {
|
|
return line_.substr(0, line_.find_first_not_of(" \n"));
|
|
}
|
|
|
|
private:
|
|
llvm::StringRef line_;
|
|
};
|
|
|
|
} // namespace Carbon::Testing
|
|
|
|
#endif // CARBON_TESTING_FILE_TEST_LINE_H_
|