driver_file_test_base.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_TOOLCHAIN_DRIVER_DRIVER_FILE_TEST_BASE_H_
  5. #define CARBON_TOOLCHAIN_DRIVER_DRIVER_FILE_TEST_BASE_H_
  6. #include <cstdio>
  7. #include "llvm/ADT/SmallVector.h"
  8. #include "llvm/ADT/StringRef.h"
  9. #include "llvm/Support/VirtualFileSystem.h"
  10. #include "testing/file_test/file_test_base.h"
  11. #include "toolchain/driver/driver.h"
  12. namespace Carbon::Testing {
  13. // Provides common test support for the driver. This is used by file tests in
  14. // phase subdirectories.
  15. class DriverFileTestBase : public FileTestBase {
  16. public:
  17. using FileTestBase::FileTestBase;
  18. auto Run(const llvm::SmallVector<llvm::StringRef>& test_args,
  19. llvm::vfs::InMemoryFileSystem& fs, llvm::raw_pwrite_stream& stdout,
  20. llvm::raw_pwrite_stream& stderr) -> ErrorOr<bool> override {
  21. Driver driver(fs, stdout, stderr);
  22. return driver.RunCommand(test_args);
  23. }
  24. };
  25. } // namespace Carbon::Testing
  26. #endif // CARBON_TOOLCHAIN_DRIVER_DRIVER_FILE_TEST_BASE_H_