mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Add git metadata handling and integration tests for sync direction defaults
- Introduced new tests for git-based sync direction defaults, verifying the presence of git metadata and correct mappings of changed files to instance references. - Enhanced the `compute_git_metadata` function to include canonical paths for repository roots. - Added multiple test cases to ensure accurate behavior of `changedIds` and `scriptCommittedHashes` based on git status. - Created a new project structure for testing, including various script and model files to facilitate comprehensive testing of git integration. These changes improve the robustness of the git synchronization features and ensure reliable behavior in various scenarios.
This commit is contained in:
parent
7ba04f7f6a
commit
6c0098d839
12 changed files with 1707 additions and 1 deletions
|
|
@ -130,6 +130,70 @@ impl TestServeSession {
|
|||
}
|
||||
}
|
||||
|
||||
/// Creates a test session with a git repo initialized in the project dir.
|
||||
/// The `setup` callback runs after the fixture is copied and git is initialized
|
||||
/// but BEFORE the serve process starts. Use it to commit initial files and
|
||||
/// make modifications that should appear as git changes.
|
||||
pub fn new_with_git(name: &str, setup: impl FnOnce(&Path)) -> Self {
|
||||
let working_dir = get_working_dir_path();
|
||||
|
||||
let source_path = Path::new(SERVE_TESTS_PATH).join(name);
|
||||
let dir = tempdir().expect("Couldn't create temporary directory");
|
||||
let project_path = dir
|
||||
.path()
|
||||
.canonicalize()
|
||||
.expect("Couldn't canonicalize temporary directory path")
|
||||
.join(name);
|
||||
|
||||
fs::create_dir(&project_path).expect("Couldn't create temporary project subdirectory");
|
||||
copy_recursive(&source_path, &project_path)
|
||||
.expect("Couldn't copy project to temporary directory");
|
||||
|
||||
// Initialize git repo and run setup callback
|
||||
Command::new("git")
|
||||
.args(["init"])
|
||||
.current_dir(&project_path)
|
||||
.output()
|
||||
.expect("git init failed");
|
||||
Command::new("git")
|
||||
.args(["config", "user.email", "test@test.com"])
|
||||
.current_dir(&project_path)
|
||||
.output()
|
||||
.unwrap();
|
||||
Command::new("git")
|
||||
.args(["config", "user.name", "Test"])
|
||||
.current_dir(&project_path)
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
setup(&project_path);
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
std::thread::sleep(Duration::from_millis(100));
|
||||
|
||||
let port = get_port_number();
|
||||
let port_string = port.to_string();
|
||||
|
||||
let rojo_process = Command::new(ROJO_PATH)
|
||||
.args([
|
||||
"serve",
|
||||
project_path.to_str().unwrap(),
|
||||
"--port",
|
||||
port_string.as_str(),
|
||||
])
|
||||
.current_dir(working_dir)
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()
|
||||
.expect("Couldn't start Rojo");
|
||||
|
||||
TestServeSession {
|
||||
rojo_process: KillOnDrop(rojo_process),
|
||||
_dir: dir,
|
||||
port,
|
||||
project_path,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn path(&self) -> &Path {
|
||||
&self.project_path
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue