1use std::path::Path;
6use std::time::{Duration, Instant};
7
8use fallow_engine::mutation::{
9 MutationError, MutationOptions, Operator, SourceKind, export_containing,
10};
11use fallow_output::{
12 MutationReplayCall, MutationReplayInput, MutationReplayInputSource, MutationReplayOutput,
13 MutationReplayVerdict,
14};
15
16use super::mutation::{
17 DEFAULT_RUNNER_TIMEOUT, Planned, ProgrammaticResult, guard_cache_dir, init_options, millis,
18 mutation_error, plan_for, runtime_error,
19};
20use crate::mutation::companion::{COMPANION_FILES, install};
21use crate::mutation::discovery::discover_runtime;
22use crate::mutation::last_report::ignore_cache_dir;
23use crate::mutation::manifest::manifest;
24use crate::mutation::protocol::{
25 InitRequest, LinkFault, ReplayRequest, ReplayResult, Request, Response,
26};
27use crate::mutation::recorded_args;
28use crate::mutation::replay::{check_calls, output_outcome, output_side, verdict};
29use crate::mutation::run_dir::{RunFile, write_run_dir};
30use crate::mutation::runner_version::runner_version_help;
31use crate::mutation::transport::{CompanionLink, CompanionSpawner, ProcessSpawner, SpawnFailure};
32use crate::mutation::{
33 MutationReplayOptions, MutationRunOptions, MutationRunScope, RecordArgsMode,
34};
35
36const MAX_RECORDED_INPUTS: usize = 3;
38const CALLS_PER_SIDE: u32 = 3;
41const DEFAULT_CALL_TIMEOUT: Duration = Duration::from_secs(5);
43const MAX_CALL_TIMEOUT: Duration = Duration::from_mins(10);
45const REPLAY_CLOCK_MS: i64 = 1_767_225_600_000;
47const REPLAY_SEED: i64 = 1;
49const REPLAY_CALL_MARGIN: Duration = Duration::from_secs(20);
52const REPLAY_REQUEST_MARGIN: Duration = Duration::from_secs(30);
56
57fn wall_limit(call_timeout: Duration) -> Duration {
60 (call_timeout + REPLAY_CALL_MARGIN) * (2 * CALLS_PER_SIDE) + REPLAY_REQUEST_MARGIN
61}
62
63struct Target {
65 instrumented: String,
66 export: Result<String, String>,
67}
68
69fn replay_error(message: impl Into<String>) -> crate::ProgrammaticError {
70 mutation_error("FALLOW_MUTATION_REPLAY_FAILED", message).with_context("mutation.replay")
71}
72
73fn instrument_passes(operator: Option<Operator>, span: (u32, u32)) -> Vec<MutationOptions> {
79 let mut sets = Vec::new();
80 if let Some(operator) = operator {
81 sets.push(vec![operator]);
82 }
83 sets.push(Operator::ALL.to_vec());
84 sets.into_iter()
85 .flat_map(|operators| {
86 [None, Some(vec![span])].map(|ranges| MutationOptions {
87 operators: operators.clone(),
88 ranges,
89 record_exports: false,
90 })
91 })
92 .collect()
93}
94
95fn export_of(
97 source: &str,
98 kind: SourceKind,
99 options: &MutationReplayOptions,
100 function: Option<&fallow_engine::mutation::FunctionRef>,
101) -> Result<String, String> {
102 match (&options.export, function) {
103 (Some(export), _) => Ok(export.clone()),
104 (None, Some(function)) => export_containing(source, kind, function.span).ok_or_else(|| {
105 format!(
106 "no callable export holds the function {}; pass --export to call an export of the file that runs it",
107 function
108 .name
109 .as_deref()
110 .map_or_else(|| "of the mutant".to_owned(), |name| format!("`{name}`"))
111 )
112 }),
113 (None, None) => Err(
114 "the mutant is in top-level code; pass --export to call an export of the file that reads it"
115 .to_owned(),
116 ),
117 }
118}
119
120fn find_target(
123 source: &str,
124 options: &MutationReplayOptions,
125) -> ProgrammaticResult<Option<Target>> {
126 let file = options.file.as_str();
127 let Some(kind) = SourceKind::from_path(file) else {
128 return Ok(None);
129 };
130 for request in instrument_passes(options.operator, options.span) {
131 let instrumented = match fallow_engine::mutation::instrument_source(source, file, &request)
132 {
133 Some(Ok(instrumented)) => instrumented,
134 Some(Err(MutationError::Parse { messages })) => {
135 return Err(replay_error(format!(
136 "`{file}` does not parse: {}",
137 messages.join("; ")
138 )));
139 }
140 Some(Err(error)) => {
141 return Err(replay_error(format!(
142 "cannot instrument `{file}`: {error:?}"
143 )));
144 }
145 None => return Ok(None),
146 };
147 let Some(mutant) = instrumented
148 .mutants
149 .iter()
150 .find(|mutant| mutant.id.as_str() == options.mutant_id && mutant.span == options.span)
151 else {
152 continue;
153 };
154 let export = export_of(source, kind, options, mutant.enclosing_function.as_ref());
155 return Ok(Some(Target {
156 instrumented: instrumented.code,
157 export,
158 }));
159 }
160 Err(mutation_error(
161 "FALLOW_MUTATION_UNKNOWN_MUTANT",
162 format!(
163 "the current `{file}` gives no mutant `{}` at bytes {}..{}",
164 options.mutant_id, options.span.0, options.span.1
165 ),
166 )
167 .with_context("mutation.mutantId")
168 .with_help(
169 "a mutant id changes when its source changes; run `fallow mutation` again for new ids",
170 ))
171}
172
173fn without_calls(
175 input: &MutationReplayInput,
176 export: Option<String>,
177 verdict: MutationReplayVerdict,
178 reason: String,
179 call_timeout: Duration,
180) -> ProgrammaticResult<MutationReplayOutput> {
181 let manifest = manifest()
182 .map_err(|message| mutation_error("FALLOW_MUTATION_PROTOCOL_INVALID", message))?;
183 Ok(MutationReplayOutput {
184 contract_version: manifest.replay.contract_version,
185 verdict,
186 reason: Some(reason),
187 export,
188 input: input.clone(),
189 inputs_checked: 0,
190 calls_per_side: CALLS_PER_SIDE,
191 call_timeout_ms: millis(call_timeout),
192 clock_ms: REPLAY_CLOCK_MS,
193 seed: REPLAY_SEED,
194 calls: Vec::new(),
195 duration_ms: 0,
196 })
197}
198
199fn start(
201 link: &mut Box<dyn CompanionLink>,
202 init: InitRequest,
203 runner_name: &str,
204 timeout: Duration,
205) -> ProgrammaticResult<()> {
206 let manifest = manifest()
207 .map_err(|message| mutation_error("FALLOW_MUTATION_PROTOCOL_INVALID", message))?;
208 let range = manifest.runner(runner_name).ok_or_else(|| {
209 mutation_error(
210 "FALLOW_MUTATION_PROTOCOL_INVALID",
211 format!("the protocol manifest has no `{runner_name}` runner"),
212 )
213 })?;
214 let ready = match link.request(&Request::Init(init), timeout) {
215 Ok(Response::Ready(ready)) => ready,
216 Ok(_) => return Err(replay_error("the companion answered init with no ready")),
217 Err(fault) => return Err(link_error("init", &fault)),
218 };
219 if !range.contains(&ready.runner_version) {
220 return Err(mutation_error(
221 "FALLOW_MUTATION_RUNNER_UNSUPPORTED",
222 format!(
223 "{} {} is not supported; the supported range is >={} <{}",
224 range.package, ready.runner_version, range.min_version, range.max_version_exclusive
225 ),
226 )
227 .with_help(runner_version_help(range)));
228 }
229 if !ready.capabilities.replay {
230 return Err(mutation_error(
231 "FALLOW_MUTATION_REPLAY_UNSUPPORTED",
232 format!("the {runner_name} runner has no replay"),
233 )
234 .with_context("mutation.replay")
235 .with_help("replay supports the Vitest and node:test runners"));
236 }
237 Ok(())
238}
239
240fn link_error(stage: &str, fault: &LinkFault) -> crate::ProgrammaticError {
241 let error = replay_error(format!("the replay companion failed at {stage}: {fault}"));
242 match fault.stderr_tail() {
243 Some(tail) => error.with_help(format!("companion stderr:\n{}", tail.trim_end())),
244 None => error,
245 }
246}
247
248fn read_source(root: &Path, file: &str) -> ProgrammaticResult<String> {
250 let bytes = std::fs::read(root.join(file))
251 .map_err(|error| replay_error(format!("cannot read `{file}`: {error}")))?;
252 let text = String::from_utf8(bytes)
253 .map_err(|_| replay_error(format!("`{file}` is not UTF-8 text")))?;
254 Ok(text
255 .strip_prefix('\u{feff}')
256 .map_or_else(|| text.clone(), str::to_owned))
257}
258
259fn start_companion(
262 planned: &Planned,
263 options: &MutationReplayOptions,
264 instrumented: &str,
265) -> ProgrammaticResult<Box<dyn CompanionLink>> {
266 let manifest = manifest()
267 .map_err(|message| mutation_error("FALLOW_MUTATION_PROTOCOL_INVALID", message))?;
268 let runner = planned.runner;
269 let runtime = discover_runtime(options.runtime.as_deref(), runner.runtimes())
270 .map_err(|message| runtime_error(runner, message))?;
271 let cache_error =
272 |message: String| mutation_error("FALLOW_MUTATION_CACHE_WRITE_FAILED", message);
273 ignore_cache_dir(&planned.cache_dir).map_err(|error| cache_error(error.to_string()))?;
274 let mutation_cache = planned.cache_dir.join("mutation");
275 let companion = install(&mutation_cache, COMPANION_FILES)
276 .map_err(|message| mutation_error("FALLOW_MUTATION_COMPANION_INTEGRITY", message))?;
277 let files = [RunFile {
278 path: &options.file,
279 code: instrumented,
280 }];
281 let run_dir = write_run_dir(&mutation_cache, &files, Some(&companion)).map_err(cache_error)?;
282 let root = planned.resolved.root().to_path_buf();
283 let init = InitRequest {
284 root: root.to_string_lossy().into_owned(),
285 runner: runner.name().to_owned(),
286 config_path: planned.runner_config.clone(),
287 run_dir: run_dir.dir.to_string_lossy().into_owned(),
288 path_map: run_dir.path_map,
289 options: init_options(
290 runner,
291 &root,
292 &planned.plan.test_files,
293 &planned.runner_projects,
294 ),
295 };
296 let spawner = ProcessSpawner {
297 runtime: runtime.path,
298 companion,
299 root,
300 wire_version: manifest.wire_protocol_version,
301 session_token_env: manifest.session_token_env.clone(),
302 };
303 let mut link = spawner.spawn().map_err(|failure| match failure {
304 SpawnFailure::Integrity(message) => {
305 mutation_error("FALLOW_MUTATION_COMPANION_INTEGRITY", message)
306 }
307 SpawnFailure::Fault(fault) => link_error("start", &fault),
308 })?;
309 let runner_timeout = options.runner_timeout.unwrap_or(DEFAULT_RUNNER_TIMEOUT);
310 if let Err(error) = start(&mut link, init, runner.name(), runner_timeout) {
311 link.shutdown();
312 return Err(error);
313 }
314 Ok(link)
315}
316
317fn verdict_reason(verdict: MutationReplayVerdict, export: &str) -> Option<String> {
319 match verdict {
320 MutationReplayVerdict::NotCallable => Some(format!("the export `{export}` is not a function")),
321 MutationReplayVerdict::Timeout => {
322 Some("a call did not end before the call timeout".to_owned())
323 }
324 MutationReplayVerdict::Unstable => Some(
325 "the calls of one side gave different results; a value that the replay does not fix (for example crypto random values or the network) can cause this".to_owned(),
326 ),
327 _ => None,
328 }
329}
330
331fn completed(
333 input: &MutationReplayInput,
334 export: String,
335 result: ReplayResult,
336 call_timeout: Duration,
337) -> ProgrammaticResult<MutationReplayOutput> {
338 check_calls(&result.calls, CALLS_PER_SIDE).map_err(replay_error)?;
339 let verdict = verdict(&result.calls);
340 let mut output = without_calls(input, Some(export), verdict, String::new(), call_timeout)?;
341 output.reason = verdict_reason(verdict, output.export.as_deref().unwrap_or_default());
342 output.duration_ms = result.duration_ms;
343 output.calls = result
344 .calls
345 .into_iter()
346 .map(|call| MutationReplayCall {
347 side: output_side(call.side),
348 index: call.index,
349 outcome: output_outcome(call.outcome),
350 value: call.value,
351 text: call.text,
352 })
353 .collect();
354 Ok(output)
355}
356
357pub fn replay_mutation(
371 options: &MutationReplayOptions,
372) -> ProgrammaticResult<MutationReplayOutput> {
373 let call_timeout = options.call_timeout.unwrap_or(DEFAULT_CALL_TIMEOUT);
374 if call_timeout > MAX_CALL_TIMEOUT || call_timeout < Duration::from_millis(1) {
375 return Err(mutation_error(
376 "FALLOW_INVALID_MUTATION_OPTIONS",
377 "the replay call timeout must be from 1ms to 10m",
378 )
379 .with_context("mutation.replay.callTimeout"));
380 }
381 let run_options = MutationRunOptions {
382 analysis: options.analysis.clone(),
383 scope: MutationRunScope::Paths(vec![options.file.clone().into()]),
384 runtime: options.runtime.clone(),
385 runner_config: options.runner_config.clone(),
386 runner_projects: options.runner_projects.clone(),
387 allow_dirty: true,
388 ..MutationRunOptions::default()
389 };
390 let planned = plan_for(&run_options, guard_cache_dir)?;
391 let source = read_source(planned.resolved.root(), &options.file)?;
392 let unknown = MutationReplayInput {
393 source: if options.args.is_some() {
394 MutationReplayInputSource::Argument
395 } else {
396 MutationReplayInputSource::Recorded
397 },
398 input_id: None,
399 args: options.args.clone().unwrap_or_default(),
400 };
401 let not_replayable = |export: Option<String>, reason: String| {
402 without_calls(
403 &unknown,
404 export,
405 MutationReplayVerdict::NotReplayable,
406 reason,
407 call_timeout,
408 )
409 };
410 let Some(target) = find_target(&source, options)? else {
411 return not_replayable(
412 None,
413 "a component file has no module exports to call".to_owned(),
414 );
415 };
416 let export = match target.export {
417 Ok(export) => export,
418 Err(reason) => return not_replayable(None, reason),
419 };
420 let inputs = match input_list(&planned.cache_dir, options, &export) {
421 Ok(inputs) => inputs,
422 Err(reason) => return not_replayable(Some(export), reason),
423 };
424 let mut link = start_companion(&planned, options, &target.instrumented)?;
425 let replay_target = ReplayTarget {
426 file: &options.file,
427 mutant_id: &options.mutant_id,
428 export: &export,
429 };
430 let output = replay_inputs(&mut link, &replay_target, &inputs, call_timeout, None);
431 link.shutdown();
432 output
433}
434
435pub(super) fn replay_inputs(
439 link: &mut Box<dyn CompanionLink>,
440 target: &ReplayTarget<'_>,
441 inputs: &[MutationReplayInput],
442 call_timeout: Duration,
443 deadline: Option<Instant>,
444) -> ProgrammaticResult<MutationReplayOutput> {
445 let mut outputs = Vec::new();
446 for input in inputs {
447 if !outputs.is_empty() && deadline.is_some_and(|deadline| Instant::now() >= deadline) {
449 break;
450 }
451 let output = replay_one(link, target, input, call_timeout)?;
452 let stop = ends_search(output.verdict);
453 outputs.push(output);
454 if stop {
455 break;
456 }
457 }
458 let checked = u32::try_from(outputs.len()).unwrap_or(u32::MAX);
459 let mut output = pick_output(outputs).ok_or_else(|| replay_error("the replay has no input"))?;
460 output.inputs_checked = checked;
461 if output.verdict == MutationReplayVerdict::NoWitnessFound {
462 output.reason = Some(no_witness_reason(&output));
463 }
464 Ok(output)
465}
466
467const fn ends_search(verdict: MutationReplayVerdict) -> bool {
471 matches!(
472 verdict,
473 MutationReplayVerdict::Witness
474 | MutationReplayVerdict::Timeout
475 | MutationReplayVerdict::NotCallable
476 )
477}
478
479fn pick_output(outputs: Vec<MutationReplayOutput>) -> Option<MutationReplayOutput> {
483 let unstable = outputs
484 .iter()
485 .position(|output| output.verdict == MutationReplayVerdict::Unstable);
486 let last_is_plain = outputs
487 .last()
488 .is_some_and(|output| output.verdict == MutationReplayVerdict::NoWitnessFound);
489 match (unstable, last_is_plain) {
490 (Some(index), true) => outputs.into_iter().nth(index),
491 _ => outputs.into_iter().last(),
492 }
493}
494
495fn no_witness_reason(output: &MutationReplayOutput) -> String {
497 let inputs = output.inputs_checked;
498 let noun = if inputs == 1 { "input" } else { "inputs" };
499 let source = match output.input.source {
500 MutationReplayInputSource::Argument => "--args",
501 MutationReplayInputSource::Recorded => "recorded",
502 };
503 format!(
504 "no witness found ({inputs} {noun}, {source}, {} calls of each side)",
505 output.calls_per_side
506 )
507}
508
509fn input_list(
512 cache_dir: &Path,
513 options: &MutationReplayOptions,
514 export: &str,
515) -> Result<Vec<MutationReplayInput>, String> {
516 if let Some(args) = &options.args {
517 return Ok(vec![MutationReplayInput {
518 source: MutationReplayInputSource::Argument,
519 input_id: None,
520 args: args.clone(),
521 }]);
522 }
523 recorded_inputs(cache_dir, &options.file, export)
524}
525
526pub(super) fn recorded_inputs(
529 cache_dir: &Path,
530 file: &str,
531 export: &str,
532) -> Result<Vec<MutationReplayInput>, String> {
533 let key = format!("{file}#{export}");
534 let hint = "run `fallow mutation --record-args values` for this code, or pass --args";
535 let Some(stored) = recorded_args::load(cache_dir, &key, recorded_args::now_secs()) else {
536 return Err(format!(
537 "no recorded input of `{export}` in the last 7 days; {hint}"
538 ));
539 };
540 if stored.mode != RecordArgsMode::Values {
541 return Err(format!(
542 "the recording of `{export}` keeps argument types only; {hint}"
543 ));
544 }
545 let inputs: Vec<MutationReplayInput> = stored
546 .inputs
547 .into_iter()
548 .filter_map(|input| {
549 Some(MutationReplayInput {
550 source: MutationReplayInputSource::Recorded,
551 input_id: Some(input.input_id),
552 args: input.args?,
553 })
554 })
555 .take(MAX_RECORDED_INPUTS)
556 .collect();
557 if inputs.is_empty() {
558 let reasons: Vec<String> = stored
559 .not_replayable
560 .iter()
561 .map(|refusal| format!("{} ({})", refusal.reason, refusal.count))
562 .collect();
563 let detail = if reasons.is_empty() {
564 "no call of the dry run reached it".to_owned()
565 } else {
566 format!("the calls were not replayable: {}", reasons.join(", "))
567 };
568 return Err(format!(
569 "no recorded input of `{export}` can run: {detail}; {hint}"
570 ));
571 }
572 Ok(inputs)
573}
574
575pub(super) struct ReplayTarget<'a> {
577 pub file: &'a str,
578 pub mutant_id: &'a str,
579 pub export: &'a str,
580}
581
582fn replay_one(
585 link: &mut Box<dyn CompanionLink>,
586 target: &ReplayTarget<'_>,
587 input: &MutationReplayInput,
588 call_timeout: Duration,
589) -> ProgrammaticResult<MutationReplayOutput> {
590 let export = target.export;
591 let request = ReplayRequest {
592 file: target.file.to_owned(),
593 export: export.to_owned(),
594 mutant_id: target.mutant_id.to_owned(),
595 args: input.args.clone(),
596 calls: CALLS_PER_SIDE,
597 call_timeout_ms: millis(call_timeout),
598 clock_ms: REPLAY_CLOCK_MS,
599 seed: REPLAY_SEED,
600 };
601 let wall_limit = wall_limit(call_timeout);
602 let started = Instant::now();
603 match link.request(&Request::Replay(request), wall_limit) {
604 Ok(Response::Replay(result)) => completed(input, export.to_owned(), result, call_timeout),
605 Ok(_) => Err(replay_error(
606 "the companion answered replay with another response",
607 )),
608 Err(LinkFault::Timeout) => {
609 let mut output = without_calls(
610 input,
611 Some(export.to_owned()),
612 MutationReplayVerdict::Timeout,
613 format!(
614 "the replay did not end in its wall limit of {}s; the module load, the original or the mutant can block the worker, and a longer --call-timeout gives more time",
615 wall_limit.as_secs()
616 ),
617 call_timeout,
618 )?;
619 output.duration_ms = millis(started.elapsed());
620 Ok(output)
621 }
622 Err(fault) => Err(link_error("replay", &fault)),
623 }
624}
625
626#[cfg(test)]
627#[expect(clippy::expect_used, reason = "tests expect to keep the setup short")]
628mod tests {
629 use super::*;
630
631 const TWINS: &str =
632 "export const first = (a, b) => a + b;\nexport const second = (a, b) => a + b;\n";
633
634 fn span_of_nth(source: &str, needle: &str, nth: usize) -> (u32, u32) {
635 let start = source.match_indices(needle).nth(nth).expect("needle").0;
636 let start = u32::try_from(start).expect("small");
637 (start, start + u32::try_from(needle.len()).expect("small"))
638 }
639
640 fn scoped_id(span: (u32, u32)) -> String {
642 let options = MutationOptions {
643 operators: Operator::ALL.to_vec(),
644 ranges: Some(vec![span]),
645 record_exports: false,
646 };
647 let instrumented = fallow_engine::mutation::instrument_source(TWINS, "src/a.js", &options)
648 .expect("layout")
649 .expect("instrumented");
650 instrumented
651 .mutants
652 .iter()
653 .find(|mutant| mutant.span == span)
654 .expect("the scoped mutant")
655 .id
656 .to_string()
657 }
658
659 #[test]
660 fn a_mutant_id_that_a_twin_shares_replays_the_mutant_at_its_own_span() {
661 let second = span_of_nth(TWINS, "a + b", 1);
662 let options = MutationReplayOptions {
663 file: "src/a.js".to_owned(),
664 mutant_id: scoped_id(second),
665 span: second,
666 ..MutationReplayOptions::default()
667 };
668 let target = find_target(TWINS, &options)
669 .expect("no error")
670 .expect("a target");
671 assert_eq!(target.export.as_deref(), Ok("second"));
672 assert!(target.instrumented.contains(&options.mutant_id));
673 }
674
675 #[test]
676 fn the_wall_limit_leaves_room_for_the_per_call_limits_of_the_companion() {
677 const COMPANION_CALL_MARGIN: Duration = Duration::from_secs(10);
681 for call_timeout in [
682 Duration::from_millis(1),
683 DEFAULT_CALL_TIMEOUT,
684 MAX_CALL_TIMEOUT,
685 ] {
686 let calls = (call_timeout + COMPANION_CALL_MARGIN) * (2 * CALLS_PER_SIDE);
687 assert!(wall_limit(call_timeout) >= calls + Duration::from_secs(60));
688 }
689 }
690
691 fn output(verdict: MutationReplayVerdict, id: &str) -> MutationReplayOutput {
692 let input = MutationReplayInput {
693 source: MutationReplayInputSource::Recorded,
694 input_id: Some(id.to_owned()),
695 args: Vec::new(),
696 };
697 without_calls(
698 &input,
699 Some("f".to_owned()),
700 verdict,
701 String::new(),
702 DEFAULT_CALL_TIMEOUT,
703 )
704 .expect("output")
705 }
706
707 #[test]
708 fn an_unstable_input_does_not_end_the_search_and_stays_the_result_without_a_witness() {
709 use MutationReplayVerdict::{NoWitnessFound, Unstable, Witness};
710 assert!(!ends_search(Unstable));
711 assert!(!ends_search(NoWitnessFound));
712 assert!(ends_search(Witness));
713 let picked = pick_output(vec![output(Unstable, "a"), output(Witness, "b")]).expect("one");
714 assert_eq!(picked.verdict, Witness);
715 let picked =
716 pick_output(vec![output(Unstable, "a"), output(NoWitnessFound, "b")]).expect("one");
717 assert_eq!(picked.verdict, Unstable);
718 assert_eq!(picked.input.input_id.as_deref(), Some("a"));
719 }
720
721 #[test]
722 fn an_id_at_another_span_is_an_unknown_mutant() {
723 let second = span_of_nth(TWINS, "a + b", 1);
724 let options = MutationReplayOptions {
725 file: "src/a.js".to_owned(),
726 mutant_id: scoped_id(second),
727 span: (0, 1),
728 ..MutationReplayOptions::default()
729 };
730 let error = find_target(TWINS, &options).err().expect("an error");
731 assert_eq!(
732 error.code.as_deref(),
733 Some("FALLOW_MUTATION_UNKNOWN_MUTANT")
734 );
735 }
736}