/// new creates a new isolated environment for ffx to run in, including a
/// user level configuration that isolates the ascendd socket into a temporary
/// directory. If $FUCHSIA_TEST_OUTDIR is set, then it is used as the log
/// directory. The isolated environment is torn down when the Isolate is
/// dropped, which will attempt to terminate any running daemon and then
/// remove all isolate files.
new creates a new isolated environment for ffx to run in, including a
user level configuration that isolates the ascendd socket into a temporary
directory. If $FUCHSIA_TEST_OUTDIR is set, then it is used as the log
directory. The isolated environment is torn down when the Isolate is
dropped, which will attempt to terminate any running daemon and then
remove all isolate files.
new creates a new isolated environment for ffx to run in including a user level configuration that isolates the ascendd socket into a temporary directory . If $FUCHSIA_TEST_OUTDIR is set then it is used as the log directory . The isolated environment is torn down when the Isolate is dropped which will attempt to terminate any running daemon and then remove all isolate files .
pub async fn new(name: &str) -> Result<Isolate> {
        let tmpdir = tempfile::Builder::new().prefix(name).tempdir()?;
        let home_dir = tmpdir.path().join("user-home");
        let tmp_dir = tmpdir.path().join("tmp");
        let log_dir = if let Ok(d) = std::env::var("FUCHSIA_TEST_OUTDIR") {
            PathBuf::from(d)
        } else {
            tmpdir.path().join("log")
        };
        for dir in [&home_dir, &tmp_dir, &log_dir].iter() {
            std::fs::create_dir_all(dir)?;
        }
        let ascendd_path = tmp_dir.join("ascendd");
        let metrics_path = home_dir.join(".fuchsia/metrics");
        std::fs::create_dir_all(&metrics_path)?;
        // Mark that analytics are disabled
        std::fs::write(metrics_path.join("analytics-status"), "0")?;
        // Mark that the notice has been given
        std::fs::write(metrics_path.join("ffx"), "1")?;
        let xdg_config_home = if cfg!(target_os = "macos") {
            home_dir.join("Library/Preferences")
        } else {
            home_dir.join(".local/share")
        };
        let user_config_dir = xdg_config_home.join("Fuchsia/ffx/config");
        std::fs::create_dir_all(&user_config_dir)?;
        std::fs::write(
            user_config_dir.join("config.json"),
            serde_json::to_string(&UserConfig::for_test(
                log_dir.to_string_lossy(),
                ascendd_path.to_string_lossy(),
            ))?,
        )?;
        std::fs::write(
            user_config_dir.join(".ffx_env"),
            serde_json::to_string(&FfxEnvConfig::for_test(
                user_config_dir.join("config.json").to_string_lossy(),
            ))?,
        )?;
        let ssh_key = ffx_config::get::<String, _>("ssh.priv").await?.into();
        let own_path = Isolate::get_own_path();
        Ok(Isolate { _tmpdir: tmpdir, own_path, home_dir, xdg_config_home, ascendd_path, ssh_key })
    }
pub async fn new ( name : & str ) -> Result < Isolate > { let tmpdir = tempfile :: Builder :: new ( ) . prefix ( name ) . tempdir ( ) ? ; let home_dir = tmpdir . path ( ) . join ( " " ) ; let tmp_dir = tmpdir . path ( ) . join ( " " ) ; let log_dir = if let Ok ( d ) = std :: env :: var ( " " ) { PathBuf :: from ( d ) } else { tmpdir . path ( ) . join ( " " ) } ; for dir in [ & home_dir , & tmp_dir , & log_dir ] . iter ( ) { std :: fs :: create_dir_all ( dir ) ? ; } let ascendd_path = tmp_dir . join ( " " ) ; let metrics_path = home_dir . join ( " " ) ; std :: fs :: create_dir_all ( & metrics_path ) ? ; // Mark that analytics are disabled std :: fs :: write ( metrics_path . join ( " " ) , " " ) ? ; // Mark that the notice has been given std :: fs :: write ( metrics_path . join ( " " ) , " " ) ? ; let xdg_config_home = if cfg ! ( target_os " " ) { home_dir . join ( " " ) } else { home_dir . join ( " " ) } ; let user_config_dir = xdg_config_home . join ( " " ) ; std :: fs :: create_dir_all ( & user_config_dir ) ? ; std :: fs :: write ( user_config_dir . join ( " " ) , serde_json :: to_string ( & UserConfig :: for_test ( log_dir . to_string_lossy ( ) , ascendd_path . to_string_lossy ( ) , ) ) ? , ) ? ; std :: fs :: write ( user_config_dir . join ( " " ) , serde_json :: to_string ( & FfxEnvConfig :: for_test ( user_config_dir . join ( " " ) . to_string_lossy ( ) , ) ) ? , ) ? ; let ssh_key = ffx_config :: get :: < String , _ > ( " " ) . await ? . into ( ) ; let own_path = Isolate :: get_own_path ( ) ; Ok ( Isolate { _tmpdir : tmpdir , own_path , home_dir , xdg_config_home , ascendd_path , ssh_key } ) }
new creates a new isolated environment for ffx to run in, including a
user level configuration that isolates the ascendd socket into a temporary
directory.
new creates a new isolated environment for ffx to run in including a user level configuration that isolates the ascendd socket into a temporary directory .
name
&str