Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugins/csharp/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl LanguagePlugin for CSharpPlugin {

// run command
let bootstrap_path = Self::get_bootstrap_path()?;
let _output = TmcCommand::new_with_file_io("dotnet")?
let _output = TmcCommand::piped("dotnet")
.with(|e| {
e.cwd(path)
.arg(bootstrap_path)
Expand Down Expand Up @@ -261,7 +261,7 @@ impl LanguagePlugin for CSharpPlugin {

// run command
let bootstrap_path = Self::get_bootstrap_path()?;
let command = TmcCommand::new_with_file_io("dotnet")?
let command = TmcCommand::piped("dotnet")
.with(|e| e.cwd(path).arg(bootstrap_path).arg("--run-tests"));
let output = if let Some(timeout) = timeout {
command.output_with_timeout(timeout)
Expand Down
13 changes: 6 additions & 7 deletions plugins/java/src/ant_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ impl AntPlugin {

fn get_ant_executable(&self) -> &'static str {
if cfg!(windows) {
if let Ok(command) = TmcCommand::new_with_file_io("ant") {
if let Ok(status) = command.with(|e| e.arg("-version")).status() {
if status.success() {
return "ant";
}
let command = TmcCommand::piped("ant");
if let Ok(status) = command.with(|e| e.arg("-version")).status() {
if status.success() {
return "ant";
}
}
// if ant not found on windows, try ant.bat
Expand Down Expand Up @@ -188,7 +187,7 @@ impl JavaPlugin for AntPlugin {
log::info!("building project at {}", project_root_path.display());

let ant_exec = self.get_ant_executable();
let output = TmcCommand::new_with_file_io(ant_exec)?
let output = TmcCommand::piped(ant_exec)
.with(|e| e.arg("compile-test").cwd(project_root_path))
.output()?;

Expand Down Expand Up @@ -263,7 +262,7 @@ impl JavaPlugin for AntPlugin {
}

log::debug!("java args '{}' in {}", arguments.join(" "), path.display());
let command = TmcCommand::new_with_file_io("java")?.with(|e| e.cwd(path).args(&arguments));
let command = TmcCommand::piped("java").with(|e| e.cwd(path).args(&arguments));
let output = if let Some(timeout) = timeout {
command.output_with_timeout(timeout)?
} else {
Expand Down
2 changes: 1 addition & 1 deletion plugins/java/src/java_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub(crate) trait JavaPlugin: LanguagePlugin {

/// Tries to find the java.home property.
fn get_java_home() -> Result<PathBuf, JavaError> {
let output = TmcCommand::new_with_file_io("java")?
let output = TmcCommand::piped("java")
.with(|e| e.arg("-XshowSettings:properties").arg("-version"))
.output()?;

Expand Down
10 changes: 5 additions & 5 deletions plugins/java/src/maven_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl MavenPlugin {
// the executable used from within the extracted maven differs per platform
fn get_mvn_command() -> Result<OsString, JavaError> {
// check if mvn is in PATH
if let Ok(status) = TmcCommand::new_with_file_io("mvn")?
if let Ok(status) = TmcCommand::piped("mvn")
.with(|e| e.arg("--batch-mode").arg("--version"))
.status()
{
Expand Down Expand Up @@ -118,7 +118,7 @@ impl LanguagePlugin for MavenPlugin {
log::info!("Cleaning maven project at {}", path.display());

let mvn_command = Self::get_mvn_command()?;
let _output = TmcCommand::new_with_file_io(mvn_command)?
let _output = TmcCommand::piped(mvn_command)
.with(|e| e.cwd(path).arg("--batch-mode").arg("clean"))
.output_checked()?;

Expand Down Expand Up @@ -153,7 +153,7 @@ impl JavaPlugin for MavenPlugin {

let output_arg = format!("-Dmdep.outputFile={}", class_path_file.display());
let mvn_path = Self::get_mvn_command()?;
let _output = TmcCommand::new_with_file_io(mvn_path)?
let _output = TmcCommand::piped(mvn_path)
.with(|e| {
e.cwd(path)
.arg("--batch-mode")
Expand Down Expand Up @@ -182,7 +182,7 @@ impl JavaPlugin for MavenPlugin {
log::info!("Building maven project at {}", project_root_path.display());

let mvn_path = Self::get_mvn_command()?;
let output = TmcCommand::new_with_file_io(mvn_path)?
let output = TmcCommand::piped(mvn_path)
.with(|e| {
e.cwd(project_root_path)
.arg("--batch-mode")
Expand All @@ -209,7 +209,7 @@ impl JavaPlugin for MavenPlugin {
log::info!("Running tests for maven project at {}", path.display());

let mvn_path = Self::get_mvn_command()?;
let command = TmcCommand::new_with_file_io(mvn_path)?.with(|e| {
let command = TmcCommand::piped(mvn_path).with(|e| {
e.cwd(path)
.arg("--batch-mode")
.arg("fi.helsinki.cs.tmc:tmc-maven-plugin:1.12:test")
Expand Down
6 changes: 3 additions & 3 deletions plugins/make/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl MakePlugin {
};
log::info!("Running make {}", arg);

let output = TmcCommand::new_with_file_io("make")?
let output = TmcCommand::piped("make")
.with(|e| e.cwd(path).arg(arg))
.output()?;

Expand All @@ -112,7 +112,7 @@ impl MakePlugin {
/// the process finished successfully or not.
fn build(&self, dir: &Path) -> Result<Output, MakeError> {
log::debug!("building {}", dir.display());
let output = TmcCommand::new_with_file_io("make")?
let output = TmcCommand::piped("make")
.with(|e| e.cwd(dir).arg("test"))
.output()?;

Expand Down Expand Up @@ -327,7 +327,7 @@ impl LanguagePlugin for MakePlugin {

// does not check for success
fn clean(&self, path: &Path) -> Result<(), TmcError> {
let output = TmcCommand::new_with_file_io("make")?
let output = TmcCommand::piped("make")
.with(|e| e.cwd(path).arg("clean"))
.output()?;

Expand Down
21 changes: 10 additions & 11 deletions plugins/python3/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Python3Plugin {
Self {}
}

fn get_local_python_command() -> Result<TmcCommand, PythonError> {
fn get_local_python_command() -> TmcCommand {
lazy_static! {
// the correct python command is platform-dependent
static ref LOCAL_PY: LocalPy = {
Expand Down Expand Up @@ -62,17 +62,16 @@ impl Python3Plugin {
Custom { python_exec: String },
}

let command = match &*LOCAL_PY {
LocalPy::Unix => TmcCommand::new_with_file_io("python3")?,
LocalPy::Windows => TmcCommand::new_with_file_io("py")?.with(|e| e.arg("-3")),
LocalPy::WindowsConda { conda_path } => TmcCommand::new_with_file_io(conda_path)?,
LocalPy::Custom { python_exec } => TmcCommand::new_with_file_io(python_exec)?,
};
Ok(command)
match &*LOCAL_PY {
LocalPy::Unix => TmcCommand::piped("python3"),
LocalPy::Windows => TmcCommand::piped("py").with(|e| e.arg("-3")),
LocalPy::WindowsConda { conda_path } => TmcCommand::piped(conda_path),
LocalPy::Custom { python_exec } => TmcCommand::piped(python_exec),
}
}

fn get_local_python_ver() -> Result<(usize, usize, usize), PythonError> {
let output = Self::get_local_python_command()?
let output = Self::get_local_python_command()
.with(|e| e.args(&["-c", "import sys; print(sys.version_info.major); print(sys.version_info.minor); print(sys.version_info.micro);"]))
.output_checked()?;
let stdout = String::from_utf8_lossy(&output.stdout);
Expand Down Expand Up @@ -139,7 +138,7 @@ impl Python3Plugin {
log::debug!("running tmc command at {}", path.display());
let common_args = ["-m", "tmc"];

let command = Self::get_local_python_command()?;
let command = Self::get_local_python_command();
let command = command.with(|e| e.args(&common_args).args(extra_args).cwd(path));
let output = if let Some(timeout) = timeout {
command.output_with_timeout(timeout)?
Expand Down Expand Up @@ -446,7 +445,7 @@ mod test {
fn gets_local_python_command() {
init();

let _cmd = Python3Plugin::get_local_python_command().unwrap();
let _cmd = Python3Plugin::get_local_python_command();
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions plugins/r/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl LanguagePlugin for RPlugin {
} else {
&["-e", "library(tmcRtestrunner);run_available_points()"]
};
let _output = TmcCommand::new_with_file_io("Rscript")?
let _output = TmcCommand::piped("Rscript")
.with(|e| e.cwd(path).args(args))
.output_checked()?;

Expand Down Expand Up @@ -85,11 +85,11 @@ impl LanguagePlugin for RPlugin {
};

if let Some(timeout) = timeout {
let _command = TmcCommand::new_with_file_io("Rscript")?
let _command = TmcCommand::piped("Rscript")
.with(|e| e.cwd(path).args(args))
.output_with_timeout_checked(timeout)?;
} else {
let _command = TmcCommand::new_with_file_io("Rscript")?
let _command = TmcCommand::piped("Rscript")
.with(|e| e.cwd(path).args(args))
.output_checked()?;
}
Expand Down
Loading