Something went wrong. Try again.
HEXWORK - A Lantern in the Deep: 3D ASCII terminal roguelike RPG in Rust.
Entirely designed and built by Muse Spark 1.3 to evaluate if I like the model.
Something went wrong. Try again.
3.6 kB · 134 lines
Rust
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135//! Independent color-aware VT evidence. Human normal-brightness AC10 is separate.#![cfg(any(target_os = "linux", target_os = "macos"))]pub mod support;
use std::path::Path;use std::process::Command;use support::Harness;
#[test]fn independent_vt_handwritten_fixtures() { let output = Command::new("python3") .env("PYTHONDONTWRITEBYTECODE", "1") .arg("-m") .arg("unittest") .arg("discover") .arg("-s") .arg(Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/pty")) .args(["-p", "test_vt.py", "-v"]) .output() .expect("python3 VT fixtures"); assert!( output.status.success(), "{}", String::from_utf8_lossy(&output.stderr) );}
fn physical(style: &str, color: &str) { let harness = Harness::new(&format!("interface-{style}-{color}")); physical_in(&harness, style, color, 223, false);}
fn physical_in(harness: &Harness, style: &str, color: &str, seed: u64, ascii: bool) { let output = Harness::run({ let mut command = Command::new("python3"); command .current_dir(&harness.cwd) .env("HOME", &harness.home) .env("XDG_DATA_HOME", harness.home.join("xdg")) .env("HEXWORK_PTY_SEED", seed.to_string()) .env("HEXWORK_PTY_ASCII", if ascii { "1" } else { "0" }) .env("PYTHONDONTWRITEBYTECODE", "1") .arg(Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/pty/player_interface.py")) .arg(env!("CARGO_BIN_EXE_hexwork")) .arg(&harness.data) .arg(&harness.content) .arg(style) .arg(color); command }); assert!( output.status.success(), "stdout={} stderr={}", String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stderr) ); let evidence: serde_json::Value = serde_json::from_slice(&output.stdout).unwrap(); assert_eq!(evidence["exit"], 0); assert_eq!(evidence["style"], style); assert_eq!(evidence["color"], color); assert_eq!( evidence["stages"].as_array().unwrap().len(), if style == "legacy" { 5 } else if style == "controls" { 11 } else if style == "resume" { 6 } else { 18 } );}
#[test]fn physical_story_truecolor() { physical("story", "truecolor");}#[test]fn physical_story_indexed() { physical("story", "indexed");}#[test]fn physical_story_no_color() { physical("story", "none");}#[test]fn physical_classic_no_color() { physical("classic", "none");}#[test]fn physical_frozen_legacy_collisions() { physical("legacy", "none");}#[test]fn physical_mouse_focus_camera_movement() { physical("controls", "none");}#[test]fn physical_extra_seed0_story_truecolor() { physical_in( &Harness::new("interface-seed0"), "story", "truecolor", 0, false, );}#[test]fn physical_extra_seed140_story_no_color() { physical_in( &Harness::new("interface-seed140"), "story", "none", 140, false, );}#[test]fn physical_extra_ascii_truecolor() { physical_in( &Harness::new("interface-ascii-tc"), "story", "truecolor", 223, true, );}#[test]fn physical_extra_resumed_story() { let harness = Harness::new("interface-resume"); physical_in(&harness, "story", "truecolor", 223, false); physical_in(&harness, "resume", "truecolor", 223, false);}