test(tvix/cli): Make the REPL testable
Juggle around the internals of the tvix-cli crate so that we expose the Repl as a public type with a `send` method, that sends a string to the repl and *captures all output* so that it can be subsequently asserted on in tests. Then, demonstrate that this works with a single (for now) REPL test using expect-test to assert on the output of a single command sent to the REPL. As the REPL gets more complicated, this will allow us to make tests that cover that complex behavior. Change-Id: I88175bd72d8760c79faade95ebb1d956f08a7b83 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11958 Autosubmit: aspen <root@gws.fyi> Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
This commit is contained in:
parent
3a79f93795
commit
0ad986169d
9 changed files with 522 additions and 346 deletions
72
tvix/cli/src/args.rs
Normal file
72
tvix/cli/src/args.rs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use clap::Parser;
|
||||
use tracing::Level;
|
||||
|
||||
#[derive(Parser, Clone)]
|
||||
pub struct Args {
|
||||
/// A global log level to use when printing logs.
|
||||
/// It's also possible to set `RUST_LOG` according to
|
||||
/// `tracing_subscriber::filter::EnvFilter`, which will always have
|
||||
/// priority.
|
||||
#[arg(long, default_value_t=Level::INFO)]
|
||||
pub log_level: Level,
|
||||
|
||||
/// Path to a script to evaluate
|
||||
pub script: Option<PathBuf>,
|
||||
|
||||
#[clap(long, short = 'E')]
|
||||
pub expr: Option<String>,
|
||||
|
||||
/// Dump the raw AST to stdout before interpreting
|
||||
#[clap(long, env = "TVIX_DISPLAY_AST")]
|
||||
pub display_ast: bool,
|
||||
|
||||
/// Dump the bytecode to stdout before evaluating
|
||||
#[clap(long, env = "TVIX_DUMP_BYTECODE")]
|
||||
pub dump_bytecode: bool,
|
||||
|
||||
/// Trace the runtime of the VM
|
||||
#[clap(long, env = "TVIX_TRACE_RUNTIME")]
|
||||
pub trace_runtime: bool,
|
||||
|
||||
/// Capture the time (relative to the start time of evaluation) of all events traced with
|
||||
/// `--trace-runtime`
|
||||
#[clap(long, env = "TVIX_TRACE_RUNTIME_TIMING", requires("trace_runtime"))]
|
||||
pub trace_runtime_timing: bool,
|
||||
|
||||
/// Only compile, but do not execute code. This will make Tvix act
|
||||
/// sort of like a linter.
|
||||
#[clap(long)]
|
||||
pub compile_only: bool,
|
||||
|
||||
/// Don't print warnings.
|
||||
#[clap(long)]
|
||||
pub no_warnings: bool,
|
||||
|
||||
/// A colon-separated list of directories to use to resolve `<...>`-style paths
|
||||
#[clap(long, short = 'I', env = "NIX_PATH")]
|
||||
pub nix_search_path: Option<String>,
|
||||
|
||||
/// Print "raw" (unquoted) output.
|
||||
#[clap(long)]
|
||||
pub raw: bool,
|
||||
|
||||
/// Strictly evaluate values, traversing them and forcing e.g.
|
||||
/// elements of lists and attribute sets before printing the
|
||||
/// return value.
|
||||
#[clap(long)]
|
||||
pub strict: bool,
|
||||
|
||||
#[arg(long, env, default_value = "memory://")]
|
||||
pub blob_service_addr: String,
|
||||
|
||||
#[arg(long, env, default_value = "memory://")]
|
||||
pub directory_service_addr: String,
|
||||
|
||||
#[arg(long, env, default_value = "memory://")]
|
||||
pub path_info_service_addr: String,
|
||||
|
||||
#[arg(long, env, default_value = "dummy://")]
|
||||
pub build_service_addr: String,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue