mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-23 22:25:26 +00:00
Make web tests no longer mutate original files
This commit is contained in:
7
server/Cargo.lock
generated
7
server/Cargo.lock
generated
@@ -647,7 +647,8 @@ dependencies = [
|
|||||||
"serde 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_derive 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_derive 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_json 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_json 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"tempfile 3.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"tempfile 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"walkdir 2.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -758,7 +759,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tempfile"
|
name = "tempfile"
|
||||||
version = "3.0.1"
|
version = "3.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -1075,7 +1076,7 @@ dependencies = [
|
|||||||
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
|
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
|
||||||
"checksum syn 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)" = "61b8f1b737f929c6516ba46a3133fd6d5215ad8a62f66760f851f7048aebedfb"
|
"checksum syn 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)" = "61b8f1b737f929c6516ba46a3133fd6d5215ad8a62f66760f851f7048aebedfb"
|
||||||
"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
|
"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
|
||||||
"checksum tempfile 3.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8cddbd26c5686ece823b507f304c8f188daef548b4cb753512d929ce478a093c"
|
"checksum tempfile 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "47776f63b85777d984a50ce49d6b9e58826b6a3766a449fc95bc66cd5663c15b"
|
||||||
"checksum term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "f2077e54d38055cf1ca0fd7933a2e00cd3ec8f6fed352b2a377f06dcdaaf3281"
|
"checksum term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "f2077e54d38055cf1ca0fd7933a2e00cd3ec8f6fed352b2a377f06dcdaaf3281"
|
||||||
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
|
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
|
||||||
"checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693"
|
"checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693"
|
||||||
|
|||||||
@@ -15,15 +15,16 @@ name = "rojo"
|
|||||||
path = "src/bin.rs"
|
path = "src/bin.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "2.27.1"
|
clap = "2.27"
|
||||||
rouille = "2.1"
|
rouille = "2.1"
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
serde_derive = "1.0"
|
serde_derive = "1.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
notify = "4.0.0"
|
notify = "4.0"
|
||||||
rand = "0.4"
|
rand = "0.4"
|
||||||
regex = "1.0"
|
regex = "1.0"
|
||||||
lazy_static = "1.0"
|
lazy_static = "1.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = "3"
|
tempfile = "3.0"
|
||||||
|
walkdir = "2.1"
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
|
use std::fs::{create_dir, copy};
|
||||||
|
use std::path::Path;
|
||||||
|
use std::io;
|
||||||
|
|
||||||
use rouille::Request;
|
use rouille::Request;
|
||||||
|
|
||||||
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
use librojo::web::Server;
|
use librojo::web::Server;
|
||||||
|
|
||||||
pub trait HttpTestUtil {
|
pub trait HttpTestUtil {
|
||||||
@@ -20,3 +26,29 @@ impl HttpTestUtil for Server {
|
|||||||
body
|
body
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn copy_recursive(from: &Path, to: &Path) -> io::Result<()> {
|
||||||
|
for entry in WalkDir::new(from) {
|
||||||
|
let entry = entry?;
|
||||||
|
let path = entry.path();
|
||||||
|
let new_path = to.join(path.strip_prefix(from).unwrap());
|
||||||
|
|
||||||
|
let file_type = entry.file_type();
|
||||||
|
|
||||||
|
if file_type.is_dir() {
|
||||||
|
match create_dir(new_path) {
|
||||||
|
Ok(_) => {},
|
||||||
|
Err(err) => match err.kind() {
|
||||||
|
io::ErrorKind::AlreadyExists => {},
|
||||||
|
_ => panic!(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if file_type.is_file() {
|
||||||
|
copy(path, new_path)?;
|
||||||
|
} else {
|
||||||
|
unimplemented!("no symlinks please");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
extern crate rouille;
|
extern crate rouille;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
extern crate serde;
|
extern crate serde;
|
||||||
|
extern crate tempfile;
|
||||||
|
extern crate walkdir;
|
||||||
|
|
||||||
extern crate librojo;
|
extern crate librojo;
|
||||||
|
|
||||||
@@ -21,12 +23,17 @@ use librojo::{
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn empty() {
|
fn empty() {
|
||||||
let project_path = {
|
let original_project_path = {
|
||||||
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||||
path.push("test-projects/empty");
|
path.push("test-projects/empty");
|
||||||
path
|
path
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let project_tempdir = tempfile::tempdir().unwrap();
|
||||||
|
let project_path = project_tempdir.path();
|
||||||
|
|
||||||
|
copy_recursive(&original_project_path, &project_path).unwrap();
|
||||||
|
|
||||||
let project = Project::load(&project_path).unwrap();
|
let project = Project::load(&project_path).unwrap();
|
||||||
let mut session = Session::new(project.clone());
|
let mut session = Session::new(project.clone());
|
||||||
session.start();
|
session.start();
|
||||||
@@ -64,12 +71,17 @@ fn empty() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn one_partition() {
|
fn one_partition() {
|
||||||
let project_path = {
|
let original_project_path = {
|
||||||
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||||
path.push("test-projects/one-partition");
|
path.push("test-projects/one-partition");
|
||||||
path
|
path
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let project_tempdir = tempfile::tempdir().unwrap();
|
||||||
|
let project_path = project_tempdir.path();
|
||||||
|
|
||||||
|
copy_recursive(&original_project_path, &project_path).unwrap();
|
||||||
|
|
||||||
let project = Project::load(&project_path).unwrap();
|
let project = Project::load(&project_path).unwrap();
|
||||||
let mut session = Session::new(project.clone());
|
let mut session = Session::new(project.clone());
|
||||||
session.start();
|
session.start();
|
||||||
@@ -202,11 +214,7 @@ fn one_partition() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
let temp_name = {
|
let temp_name = project_path.join("lib/c.client.lua");
|
||||||
let mut path = project_path.clone();
|
|
||||||
path.push("lib/c.client.lua");
|
|
||||||
path
|
|
||||||
};
|
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut file = File::create(&temp_name).unwrap();
|
let mut file = File::create(&temp_name).unwrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user