Repository: typst/typst
File: tests/src/run.rs (Rust)

Code before:
            }
        }
    }

    /// Evaluate document content, this is the target agnostic part of compilation.
    fn eval(&mut self) -> Option<Content> {
        let Warned { output, warnings } = eval::eval(&self.world);
        for warning in &warnings {
            self.check_diagnostic(NoteKind::Warning, warning, TestEval);
        }

        if let Err(errors) = &output {
            for error in errors.iter() {
                self.check_diagnostic(NoteKind::Error, error, TestEval);
            }
        }

        output.ok()
    }

    /// Compile a document with the specified target.
    fn compile<D: TestDocument>(&mut self) -> Option<D> {
        let Warned { output, warnings } = typst::compile::<D>(&self.world);
        for warning in &warnings {
            self.check_diagnostic(NoteKind::Warning, warning, D::TARGET);
        }

        if let Err(errors) = &output {
            for error in errors.iter() {
                self.check_diagnostic(NoteKind::Error, error, D::TARGET);
            }
        }

        output.ok()
    }

    /// Run test for an output format that produces a file reference.
    fn run_file_test<T: FileOutputType>(
        &mut self,
        doc: Option<&T::Doc>,
    ) -> Option<T::Live> {
        let live = self.run_test::<T>(doc);
        {
            let output = doc.zip(live.as_ref());
            let live_data = self.save_live::<T>(output);
            if self.test.should_check(T::OUTPUT) {
                let output = output.and_then(|(doc, live)| Some((doc, live, live_data?)));
                self.check_file_ref::<T>(output)
            }
        }
        live

Review comment (suggestion):
```suggestion
    /// Conceptually, this function takes the evaluated content as input and
```

Code after:
                log!(self, "consider changing the test to only {consistent_set}");
            }
        }
    }

    /// Evaluate document content, this is the target agnostic part of compilation.
    fn eval(&mut self) -> Warned<SourceResult<Content>> {
        let evaluated = eval::eval(&self.world);

        let Warned { output, warnings } = &evaluated;
        for warning in warnings {
            self.check_diagnostic(NoteKind::Warning, warning, TestEval);
        }

        if let Err(errors) = output {
            for error in errors.iter() {
                self.check_diagnostic(NoteKind::Error, error, TestEval);
            }
        }

        evaluated
    }

    /// Compile a document with the specified target.
    ///
    /// Conceptually, this functions takes the evaluated content as input and
    /// produces a document. In practice it also re-evaluates the sources and
    /// thus generates duplicate diagnostics for the eval stage, so we filter
    /// those out.
    fn compile<D: TestDocument>(
        &mut self,
        evaluated: Warned<SourceResult<Content>>,
    ) -> Option<D> {
        let Warned { output, warnings } = typst::compile::<D>(&self.world);

        let warnings = eval::deduplicate_with(warnings, &evaluated.warnings);
        for warning in warnings.iter() {
            self.check_diagnostic(NoteKind::Warning, warning, D::TARGET);
        }

        match output {
            Ok(output) => Some(output),
            Err(errors) => {
                let eval_errors = (evaluated.output.as_ref().err())
                    .map(|errors| errors.as_slice())
                    .unwrap_or(&[]);
                let errors = eval::deduplicate_with(errors, eval_errors);

                for error in errors.iter() {
                    self.check_diagnostic(NoteKind::Error, error, D::TARGET);
                }