Skip to content

Commit d5d212b

Browse files
committed
use ant.bat on windows, use correct separator in test
1 parent bea01b1 commit d5d212b

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

tmc-langs-java/src/ant.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ impl AntPlugin {
3232
Ok(Self { jvm })
3333
}
3434

35+
fn get_ant_executable(&self) -> &'static str {
36+
if cfg!(windows) {
37+
"ant.bat"
38+
} else {
39+
"ant"
40+
}
41+
}
42+
3543
fn copy_tmc_junit_runner(&self, path: &Path) -> Result<(), JavaError> {
3644
log::debug!("Copying TMC Junit runner");
3745

@@ -106,13 +114,14 @@ impl LanguagePlugin for AntPlugin {
106114
let stderr =
107115
File::create(&stderr_path).map_err(|e| JavaError::File(stderr_path.clone(), e))?;
108116

109-
let output = Command::new("ant")
117+
let ant_exec = self.get_ant_executable();
118+
let output = Command::new(ant_exec)
110119
.arg("clean")
111120
.stdout(stdout)
112121
.stderr(stderr)
113122
.current_dir(path)
114123
.output()
115-
.map_err(|e| JavaError::FailedToRun("ant".to_string(), e))?;
124+
.map_err(|e| JavaError::FailedToRun(ant_exec.to_string(), e))?;
116125

117126
if output.status.success() {
118127
fs::remove_file(stdout_path)?;
@@ -175,13 +184,14 @@ impl JavaPlugin for AntPlugin {
175184
File::create(&stderr_path).map_err(|e| JavaError::File(stderr_path.clone(), e))?;
176185

177186
// TODO: don't require ant in path?
178-
let output = Command::new("ant")
187+
let ant_exec = self.get_ant_executable();
188+
let output = Command::new(ant_exec)
179189
.arg("compile-test")
180190
.current_dir(project_root_path)
181191
.output()
182-
.map_err(|e| JavaError::FailedToRun("ant".to_string(), e))?;
192+
.map_err(|e| JavaError::FailedToRun(ant_exec.to_string(), e))?;
183193

184-
log::trace!("stdout: {}", String::from_utf8_lossy(&output.stdout));
194+
log::debug!("stdout: {}", String::from_utf8_lossy(&output.stdout));
185195
log::debug!("stderr: {}", String::from_utf8_lossy(&output.stderr));
186196
stdout
187197
.write_all(&output.stdout)

tmc-langs-java/src/maven.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@ mod test {
283283
let test_path = temp_dir.path();
284284
let plugin = MavenPlugin::new().unwrap();
285285
let class_path = plugin.get_project_class_path(test_path).unwrap();
286-
assert!(class_path.contains("/junit/"));
286+
println!("{}", class_path);
287+
let expected = format!("{0}junit{0}", std::path::MAIN_SEPARATOR);
288+
assert!(class_path.contains(&expected));
287289
}
288290

289291
#[test]

0 commit comments

Comments
 (0)