mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add support for testing with stdin (#4819)
In order to write language-server tests, we need some way to pass stdin input. This adds support for a split "// --- STDIN" which will be provided as a temp file for testing. Note this does more stdin -> input_stream style renaming, this is just bugging me more since I know shadowing works but it can be subtle to read, particularly since I'm now making direct use of stdin in a handful of spots.
This commit is contained in:
@@ -29,7 +29,8 @@ class ExplorerFileTest : public FileTestBase {
|
||||
|
||||
auto Run(const llvm::SmallVector<llvm::StringRef>& test_args,
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem>& fs,
|
||||
llvm::raw_pwrite_stream& stdout, llvm::raw_pwrite_stream& stderr)
|
||||
FILE* /*input_stream*/, llvm::raw_pwrite_stream& output_stream,
|
||||
llvm::raw_pwrite_stream& error_stream)
|
||||
-> ErrorOr<RunResult> override {
|
||||
// Add the prelude.
|
||||
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> prelude =
|
||||
@@ -52,9 +53,10 @@ class ExplorerFileTest : public FileTestBase {
|
||||
args.push_back(arg.data());
|
||||
}
|
||||
|
||||
int exit_code = ExplorerMain(
|
||||
args.size(), args.data(), /*install_path=*/"", PreludePath, stdout,
|
||||
stderr, check_trace_output() ? stdout : trace_stream_, *fs);
|
||||
int exit_code =
|
||||
ExplorerMain(args.size(), args.data(), /*install_path=*/"", PreludePath,
|
||||
output_stream, error_stream,
|
||||
check_trace_output() ? output_stream : trace_stream_, *fs);
|
||||
|
||||
return {{.success = exit_code == EXIT_SUCCESS}};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user