|
|
@@ -240,6 +240,10 @@ pub fn run(
|
|
|
list: bool,
|
|
|
jobs: Option<usize>,
|
|
|
) -> Result<()> {
|
|
|
+ // Dumped shaders and validator reports are game-derived (rule #1).
|
|
|
+ if let Some(dir) = std::env::var_os("VICTORY_EMIT_DUMP") {
|
|
|
+ victory_core::ensure_outside_repo(Path::new(&dir))?;
|
|
|
+ }
|
|
|
let paths = crate::default_paths(paths)?;
|
|
|
// `VICTORY_HOST_MAX_WAVE=32`: translate as for a host whose waves have
|
|
|
// at most 32 lanes (as the runtime does on such a card).
|
|
|
@@ -931,3 +935,24 @@ fn tally_structured(program: &ir::Program, s: &structure::Structured, t: &mut Ta
|
|
|
fn lock<T>(m: &Mutex<T>) -> std::sync::MutexGuard<'_, T> {
|
|
|
m.lock().unwrap_or_else(|e| e.into_inner())
|
|
|
}
|
|
|
+
|
|
|
+#[cfg(test)]
|
|
|
+mod tests {
|
|
|
+ /// Shader dumps are game-derived, so a dump directory in the repo is refused.
|
|
|
+ #[test]
|
|
|
+ fn emit_dump_inside_repo_is_refused() {
|
|
|
+ // SAFETY: no other test in this binary touches the environment.
|
|
|
+ unsafe { std::env::set_var("VICTORY_EMIT_DUMP", env!("CARGO_MANIFEST_DIR")) };
|
|
|
+ let missing = std::env::temp_dir().join("victory-translate-no-such-dir");
|
|
|
+ let err = super::run(vec![missing], false, false, false, Some(1)).unwrap_err();
|
|
|
+ // SAFETY: as above; unset so a later test's `run` is not refused.
|
|
|
+ unsafe { std::env::remove_var("VICTORY_EMIT_DUMP") };
|
|
|
+ assert!(
|
|
|
+ matches!(
|
|
|
+ err.downcast_ref(),
|
|
|
+ Some(victory_core::PolicyError::InsideRepo { .. })
|
|
|
+ ),
|
|
|
+ "{err}"
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|