MCPcopy Create free account
hub / github.com/base/base / run

Method run

acceptance/src/runner.rs:38–170  ·  view source on GitHub ↗

Runs a scenario, preserving every expected check and lifecycle failure.

(config: ScenarioConfig, options: AcceptanceOptions)

Source from the content-addressed store, hash-verified

36impl AcceptanceRunner {
37 /// Runs a scenario, preserving every expected check and lifecycle failure.
38 pub async fn run(config: ScenarioConfig, options: AcceptanceOptions) -> Result<ScenarioResult> {
39 config.validate()?;
40 if options.endpoints.is_some() && options.build {
41 bail!("attach mode cannot build images");
42 }
43 if let Some(endpoints) = &options.endpoints {
44 Self::validate_endpoints(&config, endpoints)?;
45 }
46 let started = Instant::now();
47 let mut result = ScenarioResult {
48 id: config.id.clone(),
49 status: Status::Error,
50 duration_ms: 0,
51 config: serde_json::to_value(&config)?,
52 stages: Vec::new(),
53 checks: config
54 .checks
55 .iter()
56 .map(|check| Self::blocked(check, "prerequisites not completed"))
57 .collect(),
58 samples: Vec::new(),
59 forks: Vec::new(),
60 diagnostics: Vec::new(),
61 reproduction: String::new(),
62 };
63 result.config["mode"] =
64 json!(if options.endpoints.is_some() { "attach" } else { "managed" });
65 let mut provisioner =
66 Provisioner::new(options.repo_root.clone(), options.output.clone(), &config.id);
67 // Cold image compilation has a separate bounded allowance; observation windows do not.
68 let deadline = started
69 + config.timeout.0
70 + if options.build { Duration::from_secs(3600) } else { Duration::ZERO };
71 let operation = tokio::select! {
72 execution = tokio::time::timeout_at(
73 deadline,
74 Self::execute(
75 &config,
76 &options,
77 &mut provisioner,
78 &mut result,
79 started,
80 deadline,
81 ),
82 ) => {
83 execution
84 .map_err(|_| eyre::eyre!("scenario deadline elapsed"))
85 .and_then(std::convert::identity)
86 }
87 () = Self::interrupted() => {
88 for check in &mut result.checks {
89 if check.status == Status::Blocked {
90 check.status = Status::Cancelled;
91 check.message = "execution interrupted".into();
92 }
93 }
94 result.stages.push(Self::stage(
95 "interruption",

Callers 1

executeMethod · 0.45

Calls 15

is_someMethod · 0.80
sumMethod · 0.80
collect_logsMethod · 0.80
errMethod · 0.80
newFunction · 0.50
validateMethod · 0.45
cloneMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
sanitizeMethod · 0.45
pushMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected