MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / push_tests

Method push_tests

crates/test/src/lib.rs:785–839  ·  view source on GitHub ↗

For the `test` provided, and the selected `runner`, determines all permutations of tests from `components` and pushes them on to `to_run`.

(
        &self,
        test: &Test,
        components: &[(Component, PathBuf)],
        runner: &(Component, PathBuf),
        to_run: &mut Vec<(String, (Component, PathBuf), Vec<(Component, PathBu

Source from the content-addressed store, hash-verified

783 /// For the `test` provided, and the selected `runner`, determines all
784 /// permutations of tests from `components` and pushes them on to `to_run`.
785 fn push_tests(
786 &self,
787 test: &Test,
788 components: &[(Component, PathBuf)],
789 runner: &(Component, PathBuf),
790 to_run: &mut Vec<(String, (Component, PathBuf), Vec<(Component, PathBuf)>)>,
791 ) -> Result<()> {
792 /// Recursive function which walks over `worlds`, the list of worlds
793 /// that `test` expects, one by one. For each world it finds a matching
794 /// component in `components` and then recurses for the next item in the
795 /// `worlds` list.
796 ///
797 /// Once `worlds` is empty the `test` list, a temporary vector, is
798 /// cloned and pushed into `commit`.
799 fn push(
800 worlds: &[String],
801 components: &[(Component, PathBuf)],
802 test: &mut Vec<(Component, PathBuf)>,
803 commit: &mut dyn FnMut(Vec<(Component, PathBuf)>),
804 ) -> Result<()> {
805 match worlds.split_first() {
806 Some((world, rest)) => {
807 let mut any = false;
808 for (component, path) in components {
809 if component.bindgen.world == *world {
810 any = true;
811 test.push((component.clone(), path.clone()));
812 push(rest, components, test, commit)?;
813 test.pop();
814 }
815 }
816 if !any {
817 bail!("no components found for `{world}`");
818 }
819 }
820
821 // No more `worlds`? Then `test` is our set of test components.
822 None => commit(test.clone()),
823 }
824 Ok(())
825 }
826
827 push(
828 &test.config.dependency_worlds(),
829 components,
830 &mut Vec::new(),
831 &mut |test_components| {
832 to_run.push((
833 test.name.clone(),
834 (runner.0.clone(), runner.1.clone()),
835 test_components,
836 ));
837 },
838 )
839 }
840
841 /// Compiles the `component` specified to wasm for the `test` given.
842 ///

Callers 1

run_runtime_testsMethod · 0.80

Calls 3

newFunction · 0.85
dependency_worldsMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected