Merge pull request 'fix: raven test' (#2) from AdrianLong/raven:master into master
Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
16
README.md
16
README.md
@@ -32,6 +32,22 @@ cd demo
|
|||||||
raven run main.Main
|
raven run main.Main
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Raven commands
|
||||||
|
Usage: raven <COMMAND>
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
new Create a new raven project
|
||||||
|
init Create a new raven project in an existing directory
|
||||||
|
build Compile the current project
|
||||||
|
run Run the current project
|
||||||
|
test !!! BORKED !!! Run the tests
|
||||||
|
clean Remove the target directory and caching
|
||||||
|
help Print this message or the help of the given subcommand(s)
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help Print help
|
||||||
|
-V, --version Print version
|
||||||
|
|
||||||
## Future plans
|
## Future plans
|
||||||
|
|
||||||
- [ ] Make `raven run` fall back to an entry point specified in Nest.toml, when
|
- [ ] Make `raven run` fall back to an entry point specified in Nest.toml, when
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
package main;
|
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
package test;
|
|
||||||
|
|
||||||
public class Main {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
testAdd();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void testAdd() {
|
|
||||||
assert main.Main.add(2, 2) == 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
22
src/java.rs
22
src/java.rs
@@ -85,8 +85,19 @@ impl JVM {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.flat_map(|f| Into::<Vec<String>>::into(f)),
|
.flat_map(|f| Into::<Vec<String>>::into(f)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
for part in &cmd {
|
||||||
|
println!("{}", part);
|
||||||
|
}
|
||||||
|
cmd.push("-cp".to_string());
|
||||||
cmd.push(entry_point.as_ref().display().to_string());
|
cmd.push(entry_point.as_ref().display().to_string());
|
||||||
|
|
||||||
|
// Jave needs a class path and a file name to run.
|
||||||
|
cmd.push("Test".to_string());
|
||||||
|
|
||||||
|
println!("{:?}", cmd.as_slice());
|
||||||
|
|
||||||
|
|
||||||
let result = crate::io::run_process(cmd.as_slice());
|
let result = crate::io::run_process(cmd.as_slice());
|
||||||
|
|
||||||
if self.monitor
|
if self.monitor
|
||||||
@@ -118,12 +129,7 @@ pub enum VMFlag {
|
|||||||
|
|
||||||
impl Into<Vec<String>> for VMFlag {
|
impl Into<Vec<String>> for VMFlag {
|
||||||
fn into(self) -> Vec<String> {
|
fn into(self) -> Vec<String> {
|
||||||
match self {
|
vec![self.to_string()]
|
||||||
Self::EnableAssert => vec![String::from("-ea")],
|
|
||||||
Self::HeapMax { size } => vec![format!("Xmx{}", size)],
|
|
||||||
Self::HeapMin { size } => vec![format!("Xms{}", size)],
|
|
||||||
Self::Version => vec![String::from("--version")],
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,8 +142,8 @@ impl fmt::Display for VMFlag {
|
|||||||
"-{}",
|
"-{}",
|
||||||
match self {
|
match self {
|
||||||
Self::EnableAssert => String::from("ea"),
|
Self::EnableAssert => String::from("ea"),
|
||||||
Self::HeapMax { size } => format!("Xmx{}", size),
|
Self::HeapMax { size } => format!("Xmx{}", size.as_u64()),
|
||||||
Self::HeapMin { size } => format!("Xms{}", size),
|
Self::HeapMin { size } => format!("Xms{}", size.as_u64()),
|
||||||
Self::Version => String::from("-version"), // --version
|
Self::Version => String::from("-version"), // --version
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -140,14 +140,14 @@ fn init() -> anyhow::Result<()> {
|
|||||||
f.write_all(include_bytes!("../assets/src/main/Main.java"))?;
|
f.write_all(include_bytes!("../assets/src/main/Main.java"))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make src/test/Main.java
|
// Make src/test/Test.java
|
||||||
if let Result::Ok(mut f) = OpenOptions::new().write(true).create_new(is_empty).open(
|
if let Result::Ok(mut f) = OpenOptions::new().write(true).create_new(is_empty).open(
|
||||||
DIR_TEST
|
DIR_TEST
|
||||||
.clone()
|
.clone()
|
||||||
.join("Main")
|
.join("Test")
|
||||||
.with_extension(JAVA_EXT_SOURCE),
|
.with_extension(JAVA_EXT_SOURCE),
|
||||||
) {
|
) {
|
||||||
f.write_all(include_bytes!("../assets/src/test/Main.java"))?;
|
f.write_all(include_bytes!("../assets/src/test/Test.java"))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// git init .
|
// git init .
|
||||||
@@ -263,7 +263,7 @@ fn test(assertions: bool) -> anyhow::Result<(Option<String>, Option<String>)> {
|
|||||||
.ram_max(ByteSize::mib(512))
|
.ram_max(ByteSize::mib(512))
|
||||||
.monitor(true)
|
.monitor(true)
|
||||||
.build()
|
.build()
|
||||||
.run(DIR_TEST.as_path())
|
.run(DIR_TARGET.as_path())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clean() {
|
fn clean() {
|
||||||
|
|||||||
Reference in New Issue
Block a user