main
rs 24 lines 894 Bytes
Raw
1 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4 //! Replays the grammar cases exported by the roundtrip tests through the real
5 //! XGrammar, so that parser-built output grammars are checked against the
6 //! engine's compiler and matcher.
7
8 use std::path::PathBuf;
9 use std::process::Command;
10
11 #[test]
12 fn xgrammar_accepts_roundtrip_generations() {
13 let script = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/grammar_replay.py");
14 let output = Command::new(&script)
15 .output()
16 .unwrap_or_else(|error| panic!("failed to execute {:?}: {error}", script));
17 assert!(
18 output.status.success(),
19 "grammar replay failed: status={:?}\nstdout:\n{}\nstderr:\n{}",
20 output.status.code(),
21 String::from_utf8_lossy(&output.stdout),
22 String::from_utf8_lossy(&output.stderr),
23 );
24 }