From 18ca2eda588aab7d2df7469c7defefa036726c45 Mon Sep 17 00:00:00 2001 From: "Jakub A. Gramsz" Date: Tue, 30 Apr 2024 11:40:05 +0200 Subject: [PATCH] Remove different behaviour when single input --- cli/src/input.rs | 1 - core/src/program.rs | 18 ------------------ utils/src/test_program.rs | 10 +++++++--- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/cli/src/input.rs b/cli/src/input.rs index 502d275a1f..939e8c9b69 100644 --- a/cli/src/input.rs +++ b/cli/src/input.rs @@ -35,7 +35,6 @@ impl Prepare for InputOptions { fn prepare(&self, global: &GlobalOptions) -> CliResult> { let mut program = match self.files.as_slice() { [] => Program::new_from_stdin(std::io::stderr()), - [p] => Program::new_from_file(p, std::io::stderr()), files => Program::new_from_files(files, std::io::stderr()), }?; diff --git a/core/src/program.rs b/core/src/program.rs index dd185ff846..da8806e895 100644 --- a/core/src/program.rs +++ b/core/src/program.rs @@ -230,24 +230,6 @@ impl Program { }) } - pub fn new_from_file( - path: impl Into, - trace: impl Write + 'static, - ) -> std::io::Result { - increment!("Program::new"); - - let mut cache = Cache::new(ErrorTolerance::Strict); - let main_id = cache.add_file(path)?; - let vm = VirtualMachine::new(cache, trace); - Ok(Self { - main_id, - vm, - color_opt: clap::ColorChoice::Auto.into(), - overrides: Vec::new(), - field: FieldPath::new(), - }) - } - /// Create a program by reading it from a generic source. pub fn new_from_source( source: T, diff --git a/utils/src/test_program.rs b/utils/src/test_program.rs index 60a9287df7..5afbd07d05 100644 --- a/utils/src/test_program.rs +++ b/utils/src/test_program.rs @@ -49,7 +49,11 @@ pub fn typecheck_fixture(f: &str) -> Result<(), Error> { } fn program_from_test_fixture(f: &str) -> Program { - let path = format!("{}/../tests/integration/{}", env!("CARGO_MANIFEST_DIR"), f); - Program::new_from_file(&path, std::io::stderr()) - .unwrap_or_else(|e| panic!("Could not create program from `{}`\n {}", path, e)) + let paths = vec![format!( + "{}/../tests/integration/{}", + env!("CARGO_MANIFEST_DIR"), + f + )]; + Program::new_from_files(&paths, std::io::stderr()) + .unwrap_or_else(|e| panic!("Could not create program from `{}`\n {}", paths[0], e)) }