forked from Cutieguwu/raven
Refactored assets to use propper java syntax. Found error in the raven test command. Impropper formating when passing arguments to the java command.
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
18
src/java.rs
18
src/java.rs
@@ -79,14 +79,32 @@ impl JVM {
|
|||||||
) -> anyhow::Result<(Option<String>, Option<String>)> {
|
) -> anyhow::Result<(Option<String>, Option<String>)> {
|
||||||
let mut cmd = vec![JAVA_VM.to_string()];
|
let mut cmd = vec![JAVA_VM.to_string()];
|
||||||
|
|
||||||
|
println!("Fence 4");
|
||||||
|
|
||||||
|
// proper format
|
||||||
|
// java -Xms128m -Xmx512m -cp PROJECT_ROOT/src/text \test.Test
|
||||||
|
// current format
|
||||||
|
// java Xms128.0 MiB Xmx512.0 MiB /home/viffx/Coding/Rust/raven/src/Test1/src/test/
|
||||||
cmd.extend(
|
cmd.extend(
|
||||||
self.flags
|
self.flags
|
||||||
.clone()
|
.clone()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flat_map(|f| Into::<Vec<String>>::into(f)),
|
.flat_map(|f| Into::<Vec<String>>::into(f)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
println!("Fence 5");
|
||||||
|
for part in &cmd {
|
||||||
|
println!("{}", part);
|
||||||
|
}
|
||||||
cmd.push(entry_point.as_ref().display().to_string());
|
cmd.push(entry_point.as_ref().display().to_string());
|
||||||
|
|
||||||
|
println!("Fence 6");
|
||||||
|
for part in &cmd {
|
||||||
|
println!("{}", part);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
println!("Fence 7");
|
||||||
let result = crate::io::run_process(cmd.as_slice());
|
let result = crate::io::run_process(cmd.as_slice());
|
||||||
|
|
||||||
if self.monitor
|
if self.monitor
|
||||||
|
|||||||
@@ -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 .
|
||||||
@@ -248,15 +248,18 @@ fn run<P: AsRef<Path>>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn test(assertions: bool) -> anyhow::Result<(Option<String>, Option<String>)> {
|
fn test(assertions: bool) -> anyhow::Result<(Option<String>, Option<String>)> {
|
||||||
|
println!("Fence 1");
|
||||||
java::CompilerBuilder::new()
|
java::CompilerBuilder::new()
|
||||||
.class_path(DIR_TARGET.as_path())
|
.class_path(DIR_TARGET.as_path())
|
||||||
.destination(DIR_TARGET.as_path())
|
.destination(DIR_TARGET.as_path())
|
||||||
.build()
|
.build()
|
||||||
.compile(DIR_TEST.as_path())?;
|
.compile(DIR_TEST.as_path())?;
|
||||||
|
|
||||||
|
println!("Fence 2");
|
||||||
// Change cwd to avoid Java pathing issues.
|
// Change cwd to avoid Java pathing issues.
|
||||||
crate::env::set_cwd(DIR_TARGET.as_path())?;
|
crate::env::set_cwd(DIR_TARGET.as_path())?;
|
||||||
|
|
||||||
|
println!("Fence 3");
|
||||||
java::JVMBuilder::new()
|
java::JVMBuilder::new()
|
||||||
.assertions(assertions)
|
.assertions(assertions)
|
||||||
.ram_min(ByteSize::mib(128))
|
.ram_min(ByteSize::mib(128))
|
||||||
|
|||||||
Reference in New Issue
Block a user