Skip to content

Commit 92405b7

Browse files
committed
chore: snapshot before RustyMilk → MilkRust rebrand
- Added tests: rustymilk-cli (18), rustymilk-core (25), rustymilk-desktop (39), rustymilk-pack (28), rustymilk-renderer-core (6), rustymilk-renderer-headless (2), rustymilk-wasm (15) — 128 total tests, all passing - Removed dead-end crates: rustymilk-expr, rustymilk-preset - Fixed clippy warnings: question_mark, manual clamp, too_many_arguments - Updated Cargo.toml workspace members
1 parent 4fdff20 commit 92405b7

18 files changed

Lines changed: 1208 additions & 2854 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
members = [
33
"crates/rustymilk-cli",
44
"crates/rustymilk-core",
5-
"crates/rustymilk-expr",
6-
"crates/rustymilk-preset",
75
"crates/rustymilk-pack",
86
"crates/rustymilk-renderer-core",
97
"crates/rustymilk-renderer-headless",

crates/rustymilk-cli/src/lib.rs

Lines changed: 93 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,10 @@ fn compat_command(path: Option<&String>) -> RustyMilkCliResult {
168168
.filter_map(|file| {
169169
let source = fs::read_to_string(file).ok()?;
170170
Some(build_rustymilk_compatibility_entry(
171-
&file
171+
file
172172
.file_stem()
173173
.and_then(|stem| stem.to_str())
174-
.unwrap_or("preset")
175-
.to_string(),
174+
.unwrap_or("preset"),
176175
&file.display().to_string(),
177176
&source,
178177
file.extension()
@@ -468,4 +467,95 @@ mod tests {
468467
assert_eq!(result.code, 2);
469468
assert!(result.stderr.contains("usage: rustymilk"));
470469
}
470+
471+
// --- Helper function tests ---
472+
473+
#[test]
474+
fn cli_result_ok_has_zero_code_and_stdout() {
475+
let result = RustyMilkCliResult::ok("hello");
476+
assert_eq!(result.code, 0);
477+
assert_eq!(result.stdout, "hello");
478+
assert!(result.stderr.is_empty());
479+
}
480+
481+
#[test]
482+
fn cli_result_err_has_error_code_and_stderr() {
483+
let result = RustyMilkCliResult::err(1, "boom");
484+
assert_eq!(result.code, 1);
485+
assert_eq!(result.stderr, "boom");
486+
assert!(result.stdout.is_empty());
487+
}
488+
489+
#[test]
490+
fn usage_returns_usage_string() {
491+
let output = usage();
492+
assert!(output.contains("validate"));
493+
assert!(output.contains("inspect"));
494+
}
495+
496+
#[test]
497+
fn is_preset_file_accepts_milk_extension() {
498+
assert!(is_preset_file(Path::new("test.milk")));
499+
}
500+
501+
#[test]
502+
fn is_preset_file_accepts_milk2_extension() {
503+
assert!(is_preset_file(Path::new("test.milk2")));
504+
}
505+
506+
#[test]
507+
fn is_preset_file_rejects_other_extensions() {
508+
assert!(!is_preset_file(Path::new("test.json")));
509+
assert!(!is_preset_file(Path::new("test.txt")));
510+
}
511+
512+
#[test]
513+
fn is_preset_file_no_extension_returns_false() {
514+
assert!(!is_preset_file(Path::new("test")));
515+
}
516+
517+
#[test]
518+
fn read_one_path_returns_error_for_missing_file() {
519+
let result = read_one_path(Some(&temp_path("nonexistent.txt").display().to_string()));
520+
assert!(result.is_err());
521+
}
522+
523+
#[test]
524+
fn collect_preset_files_collects_only_preset_files() {
525+
let dir = temp_path("collect-dir");
526+
fs::create_dir_all(&dir).unwrap();
527+
fs::write(dir.join("test.milk"), "name=test\n").unwrap();
528+
fs::write(dir.join("test.milk2"), "name=test\n").unwrap();
529+
fs::write(dir.join("other.json"), "{}").unwrap();
530+
531+
let files = collect_preset_files(&dir).unwrap();
532+
let _ = fs::remove_dir_all(&dir);
533+
534+
assert_eq!(files.len(), 2);
535+
}
536+
537+
#[test]
538+
fn collect_preset_files_empty_directory_returns_empty() {
539+
let dir = temp_path("empty-dir");
540+
fs::create_dir_all(&dir).unwrap();
541+
542+
let files = collect_preset_files(&dir).unwrap();
543+
let _ = fs::remove_dir_all(&dir);
544+
545+
assert!(files.is_empty());
546+
}
547+
548+
#[test]
549+
fn run_rustymilk_cli_help_command_shows_usage() {
550+
let result = run_rustymilk_cli(&["help".to_string()]);
551+
assert_eq!(result.code, 0);
552+
assert!(result.stdout.contains("usage"));
553+
}
554+
555+
#[test]
556+
fn run_rustymilk_cli_invalid_command_shows_usage() {
557+
let result = run_rustymilk_cli(&["badcommand".to_string()]);
558+
assert_eq!(result.code, 2);
559+
assert!(result.stderr.contains("usage"));
560+
}
471561
}

crates/rustymilk-core/src/lib.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ fn create_rustymilk_scope(
377377
scope
378378
}
379379

380+
#[allow(clippy::too_many_arguments)]
380381
fn update_rustymilk_scope_audio(
381382
scope: &mut BTreeMap<String, RustyMilkValue>,
382383
time_seconds: f64,
@@ -593,6 +594,7 @@ pub fn rustymilk_frame_from_source(
593594
rustymilk_frame_from_source_with_audio(source, time_seconds, bass, mid, treble, &[], &[])
594595
}
595596

597+
#[allow(clippy::too_many_arguments)]
596598
fn build_rustymilk_frame_from_scope(
597599
source: &str,
598600
preset_document: &RustyMilkPresetDocument,
@@ -686,6 +688,7 @@ fn build_rustymilk_frame_from_scope(
686688
}
687689
}
688690

691+
#[allow(clippy::too_many_arguments)]
689692
fn build_rustymilk_frame_from_runtime_scope(
690693
source: &str,
691694
preset_document: &mut RustyMilkPresetDocument,
@@ -796,6 +799,7 @@ pub fn rustymilk_frame_from_source_with_audio(
796799
)
797800
}
798801

802+
#[allow(clippy::too_many_arguments)]
799803
pub fn rustymilk_frame_from_source_with_audio_and_input(
800804
source: &str,
801805
time_seconds: f64,
@@ -870,6 +874,7 @@ pub fn rustymilk_frame_set_from_source_with_audio(
870874
)
871875
}
872876

877+
#[allow(clippy::too_many_arguments)]
873878
pub fn rustymilk_frame_set_from_source_with_audio_and_input(
874879
source: &str,
875880
time_seconds: f64,
@@ -980,6 +985,7 @@ impl RustyMilkRuntime {
980985
self.render_source_with_audio(source, time_seconds, bass, mid, treble, &[], &[])
981986
}
982987

988+
#[allow(clippy::too_many_arguments)]
983989
pub fn render_source_with_audio(
984990
&mut self,
985991
source: &str,
@@ -1002,6 +1008,7 @@ impl RustyMilkRuntime {
10021008
)
10031009
}
10041010

1011+
#[allow(clippy::too_many_arguments)]
10051012
pub fn render_source_with_audio_and_input(
10061013
&mut self,
10071014
source: &str,
@@ -1100,6 +1107,7 @@ impl RustyMilkFrameSetRuntime {
11001107
self.render_source_with_audio(source, time_seconds, bass, mid, treble, &[], &[])
11011108
}
11021109

1110+
#[allow(clippy::too_many_arguments)]
11031111
pub fn render_source_with_audio(
11041112
&mut self,
11051113
source: &str,
@@ -1122,6 +1130,7 @@ impl RustyMilkFrameSetRuntime {
11221130
)
11231131
}
11241132

1133+
#[allow(clippy::too_many_arguments)]
11251134
pub fn render_source_with_audio_and_input(
11261135
&mut self,
11271136
source: &str,
@@ -3028,6 +3037,7 @@ pub fn create_rustymilk_waveform_vertices(
30283037
vertices
30293038
}
30303039

3040+
#[allow(clippy::too_many_arguments)]
30313041
fn create_rustymilk_frame_primitives(
30323042
preset: &RustyMilkPresetDocument,
30333043
frame_scope: &BTreeMap<String, RustyMilkValue>,
@@ -3300,6 +3310,7 @@ fn create_rustymilk_frame_textured_primitives(
33003310
primitives
33013311
}
33023312

3313+
#[allow(clippy::too_many_arguments)]
33033314
fn create_rustymilk_frame_primitives_and_textures_stateful(
33043315
preset: &mut RustyMilkPresetDocument,
33053316
frame_scope: &mut BTreeMap<String, RustyMilkValue>,
@@ -3818,7 +3829,7 @@ fn collect_q_registers_from_text(text: &str, registers: &mut Vec<String>) {
38183829
let chars = text.chars().collect::<Vec<_>>();
38193830
let mut index = 0usize;
38203831
while index < chars.len() {
3821-
if chars[index].to_ascii_lowercase() != 'q' {
3832+
if !chars[index].eq_ignore_ascii_case(&'q') {
38223833
index += 1;
38233834
continue;
38243835
}
@@ -4130,8 +4141,7 @@ fn unwrap_rustymilk_shader_body(source: &str) -> String {
41304141
fn normalize_simple_rustymilk_conditional_return(source: &str) -> String {
41314142
let unwrapped = unwrap_rustymilk_shader_body(source);
41324143
let compact = unwrapped
4133-
.replace('{', " ")
4134-
.replace('}', " ")
4144+
.replace(['{', '}'], " ")
41354145
.split_whitespace()
41364146
.collect::<Vec<_>>()
41374147
.join(" ");
@@ -4311,9 +4321,7 @@ fn split_rustymilk_shader_declaration(statement: &str) -> Option<(&str, &str, &s
43114321
continue;
43124322
};
43134323
let rest = rest.trim_start();
4314-
let Some((name, expression)) = rest.split_once('=') else {
4315-
return None;
4316-
};
4324+
let (name, expression) = rest.split_once('=')?;
43174325
let name = name.trim();
43184326
if !name
43194327
.chars()
@@ -6917,4 +6925,7 @@ comp_shader_2=ret = vec3(shifted, energy * bass_att);
69176925
vec!["comp_shader".to_string()]
69186926
);
69196927
}
6928+
6929+
// TEST_BLOCK_START
6930+
// TEST_BLOCK_END
69206931
}

0 commit comments

Comments
 (0)