pub fn try_from_opts(test_opts: TestOptions) -> Result<Self, Error> {
        let TestOptions {
            node,
            mode,
            headless,
            release,
            chrome,
            chromedriver,
            firefox,
            geckodriver,
            safari,
            safaridriver,
            mut path_and_extra_options,
        } = test_opts;

        let first_arg_is_path = path_and_extra_options
            .get(0)
            .map(|first_arg| !first_arg.starts_with("-"))
            .unwrap_or(false);

        let (path, extra_options) = if first_arg_is_path {
            let path = PathBuf::from_str(&path_and_extra_options.remove(0))?;
            let extra_options = path_and_extra_options;

            (Some(path), extra_options)
        } else {
            (None, path_and_extra_options)
        };

        let crate_path = get_crate_path(path)?;
        let crate_data = manifest::CrateData::new(&crate_path, None)?;
        let any_browser = chrome || firefox || safari;

        if !node && !any_browser {
            bail!("Must specify at least one of `--node`, `--chrome`, `--firefox`, or `--safari`")
        }

        if headless && !any_browser {
            bail!(
                "The `--headless` flag only applies to browser tests. Node does not provide a UI, \
                 so it doesn't make sense to talk about a headless version of Node tests."
            )
        }

        Ok(Test {
            cache: cache::get_wasm_pack_cache()?,
            crate_path,
            crate_data,
            node,
            mode,
            chrome,
            chromedriver,
            firefox,
            geckodriver,
            safari,
            safaridriver,
            headless,
            release,
            test_runner_path: None,
            extra_options,
        })
    }
/// Construct a test command from the given options.
Construct a test command from the given options.
Construct a test command from the given options .
pub fn try_from_opts(test_opts: TestOptions) -> Result<Self, Error> {
        let TestOptions {
            node,
            mode,
            headless,
            release,
            chrome,
            chromedriver,
            firefox,
            geckodriver,
            safari,
            safaridriver,
            mut path_and_extra_options,
        } = test_opts;
        let first_arg_is_path = path_and_extra_options
            .get(0)
            .map(|first_arg| !first_arg.starts_with("-"))
            .unwrap_or(false);
        let (path, extra_options) = if first_arg_is_path {
            let path = PathBuf::from_str(&path_and_extra_options.remove(0))?;
            let extra_options = path_and_extra_options;
            (Some(path), extra_options)
        } else {
            (None, path_and_extra_options)
        };
        let crate_path = get_crate_path(path)?;
        let crate_data = manifest::CrateData::new(&crate_path, None)?;
        let any_browser = chrome || firefox || safari;
        if !node && !any_browser {
            bail!("Must specify at least one of `--node`, `--chrome`, `--firefox`, or `--safari`")
        }
        if headless && !any_browser {
            bail!(
                "The `--headless` flag only applies to browser tests. Node does not provide a UI, \
                 so it doesn't make sense to talk about a headless version of Node tests."
            )
        }
        Ok(Test {
            cache: cache::get_wasm_pack_cache()?,
            crate_path,
            crate_data,
            node,
            mode,
            chrome,
            chromedriver,
            firefox,
            geckodriver,
            safari,
            safaridriver,
            headless,
            release,
            test_runner_path: None,
            extra_options,
        })
    }
pub fn try_from_opts ( test_opts : TestOptions ) -> Result < Self , Error > { let TestOptions { node , mode , headless , release , chrome , chromedriver , firefox , geckodriver , safari , safaridriver , mut path_and_extra_options , } = test_opts ; let first_arg_is_path = path_and_extra_options . get ( 0 ) . map ( | first_arg | ! first_arg . starts_with ( " " ) ) . unwrap_or ( false ) ; let ( path , extra_options ) = if first_arg_is_path { let path = PathBuf :: from_str ( & path_and_extra_options . remove ( 0 ) ) ? ; let extra_options = path_and_extra_options ; ( Some ( path ) , extra_options ) } else { ( None , path_and_extra_options ) } ; let crate_path = get_crate_path ( path ) ? ; let crate_data = manifest :: CrateData :: new ( & crate_path , None ) ? ; let any_browser = chrome || firefox || safari ; if ! node && ! any_browser { bail ! ( " " ) } if headless && ! any_browser { bail ! ( " \
 " ) } Ok ( Test { cache : cache :: get_wasm_pack_cache ( ) ? , crate_path , crate_data , node , mode , chrome , chromedriver , firefox , geckodriver , safari , safaridriver , headless , release , test_runner_path : None , extra_options , } ) }
Construct a test command from the given options.
Construct a test command from the given options .
test_opts
TestOptions