Refactor logging configuration and streamline command execution in tests

- Updated the main function to conditionally disable file logging based on the `ATLAS_NO_FILE_LOG` environment variable, enhancing flexibility in logging behavior.
- Introduced a new `atlas_command` function to encapsulate command creation for tests, ensuring consistent command execution across various test files.
- Replaced direct usage of `ROJO_PATH` with `atlas_command` in multiple test utilities, improving code clarity and maintainability.

These changes aim to enhance the logging setup and simplify command handling in the test suite.
This commit is contained in:
Joe 2026-03-01 14:41:51 -06:00
parent c0f5a01e17
commit 380041dc2a
7 changed files with 35 additions and 27 deletions

View file

@ -2,12 +2,18 @@ use std::{
fs,
io::{self, Read},
path::{Path, PathBuf},
process::Child,
process::{Child, Command},
};
use walkdir::WalkDir;
pub static ROJO_PATH: &str = env!("CARGO_BIN_EXE_atlas");
pub fn atlas_command() -> Command {
let mut cmd = Command::new(ROJO_PATH);
cmd.env("ATLAS_NO_FILE_LOG", "1");
cmd
}
pub static BUILD_TESTS_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/rojo-test/build-tests");
pub static SERVE_TESTS_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/rojo-test/serve-tests");
pub static SYNCBACK_TESTS_PATH: &str =

View file

@ -10,12 +10,11 @@ use std::{
collections::{HashMap, HashSet},
fs,
path::{Path, PathBuf},
process::Command,
};
use tempfile::TempDir;
use super::io_util::ROJO_PATH;
use super::io_util::atlas_command;
/// Run `rojo build` on a project and return the output file path.
///
@ -25,7 +24,7 @@ pub fn run_rojo_build(project_path: &Path, output_name: &str) -> (TempDir, PathB
let output_dir = tempfile::tempdir().expect("Failed to create temp dir for build output");
let output_path = output_dir.path().join(output_name);
let output = Command::new(ROJO_PATH)
let output = atlas_command()
.args([
"build",
project_path.to_str().unwrap(),
@ -57,7 +56,7 @@ pub fn run_rojo_syncback_clean(project_path: &Path, input_path: &Path) -> bool {
return false;
}
let output = Command::new(ROJO_PATH)
let output = atlas_command()
.args([
"syncback",
project_path.to_str().unwrap(),

View file

@ -4,7 +4,7 @@ use std::{
fs,
io::Read as _,
path::{Path, PathBuf},
process::{Command, Stdio},
process::Stdio,
thread,
time::Duration,
};
@ -22,7 +22,7 @@ use librojo::web_api::{
use rojo_insta_ext::RedactionMap;
use crate::rojo_test::io_util::{
copy_recursive, get_working_dir_path, KillOnDrop, ROJO_PATH, SERVE_TESTS_PATH,
atlas_command, copy_recursive, get_working_dir_path, KillOnDrop, SERVE_TESTS_PATH,
};
/// Convenience method to run a `rojo serve` test.
@ -110,7 +110,7 @@ impl TestServeSession {
let port = get_port_number();
let port_string = port.to_string();
let rojo_process = Command::new(ROJO_PATH)
let rojo_process = atlas_command()
.args([
"serve",
project_path.to_str().unwrap(),
@ -163,7 +163,7 @@ impl TestServeSession {
let port = get_port_number();
let port_string = port.to_string();
let rojo_process = Command::new(ROJO_PATH)
let rojo_process = atlas_command()
.args([
"serve",
project_path.to_str().unwrap(),
@ -223,7 +223,7 @@ impl TestServeSession {
let port = get_port_number();
let port_string = port.to_string();
let rojo_process = Command::new(ROJO_PATH)
let rojo_process = atlas_command()
.args([
"serve",
project_path.to_str().unwrap(),
@ -257,7 +257,7 @@ impl TestServeSession {
let port_string = port.to_string();
let working_dir = get_working_dir_path();
let rojo_process = Command::new(ROJO_PATH)
let rojo_process = atlas_command()
.args([
"serve",
self.project_path.to_str().unwrap(),
@ -777,7 +777,7 @@ pub fn run_cli_syncback_on_chunks(
data: &[u8],
chunks: &[librojo::web_api::ServiceChunk],
) -> (TempDir, PathBuf) {
use crate::rojo_test::io_util::{copy_recursive, ROJO_PATH, SERVE_TESTS_PATH};
use crate::rojo_test::io_util::{atlas_command, copy_recursive, SERVE_TESTS_PATH};
let source_path = Path::new(SERVE_TESTS_PATH).join(fixture_name);
let dir = tempdir().expect("Couldn't create temp dir for CLI syncback");
@ -789,7 +789,7 @@ pub fn run_cli_syncback_on_chunks(
let rbxl_path = dir.path().join("input.rbxl");
fs::write(&rbxl_path, rbxl_data).expect("Failed to write rbxl");
let output = std::process::Command::new(ROJO_PATH)
let output = atlas_command()
.args([
"syncback",
project_path.to_str().unwrap(),
@ -984,7 +984,7 @@ pub fn fresh_rebuild_read(project_path: &Path) -> NormalizedInstance {
let port = get_port_number();
let port_string = port.to_string();
let process = Command::new(ROJO_PATH)
let process = atlas_command()
.args([
"serve",
project_file.to_str().unwrap(),

View file

@ -1,4 +1,4 @@
use std::{io::Write as _, path::Path, process::Command};
use std::{io::Write as _, path::Path};
use insta::{assert_snapshot, assert_yaml_snapshot};
use regex::Regex;
@ -6,7 +6,7 @@ use tempfile::tempdir;
use crate::rojo_test::io_util::SYNCBACK_TESTS_PATH;
use super::io_util::{copy_recursive, ROJO_PATH};
use super::io_util::{atlas_command, copy_recursive};
const INPUT_FILE_PROJECT: &str = "input-project";
const INPUT_FILE_PLACE: &str = "input.rbxl";
@ -82,7 +82,7 @@ fn run_syncback_test_impl(name: &str, incremental: bool, callback: impl FnOnce(&
args.push("--incremental");
}
let output = Command::new(ROJO_PATH)
let output = atlas_command()
// I don't really understand why setting the working directory breaks this, but it does.
// It's a bit concerning but I'm more interested in writing tests than debugging it right now.
// TODO: Figure out why and fix it.