Skip to content

Commit

Permalink
Remove different behaviour when single input
Browse files Browse the repository at this point in the history
  • Loading branch information
olorin37 committed May 1, 2024
1 parent c09b4ca commit 59e6c28
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 23 deletions.
1 change: 0 additions & 1 deletion cli/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ impl<C: clap::Args + Customize> Prepare for InputOptions<C> {
fn prepare(&self, global: &GlobalOptions) -> CliResult<Program<CBNCache>> {
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()),
}?;

Expand Down
18 changes: 0 additions & 18 deletions core/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,24 +230,6 @@ impl<EC: EvalCache> Program<EC> {
})
}

pub fn new_from_file(
path: impl Into<OsString>,
trace: impl Write + 'static,
) -> std::io::Result<Self> {
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<T, S>(
source: T,
Expand Down
2 changes: 1 addition & 1 deletion core/tests/examples/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn check_example_file(path: &str) {
read_annotated_test_case(path).expect("Failed to parse annotated program");

// `test_resources` uses paths relative to the workspace manifesty
let mut p = TestProgram::new_from_file(project_root().join(path), std::io::stderr())
let mut p = TestProgram::new_from_files(vec![project_root().join(path)], std::io::stderr())
.expect("Failed to load program from file");

match test.annotation {
Expand Down
10 changes: 7 additions & 3 deletions utils/src/test_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ pub fn typecheck_fixture(f: &str) -> Result<(), Error> {
}

fn program_from_test_fixture(f: &str) -> Program<CacheImpl> {
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))
}

0 comments on commit 59e6c28

Please sign in to comment.