Skip to content

Commit

Permalink
Rename currentprocess to process
Browse files Browse the repository at this point in the history
Co-authored-by: rami3l <[email protected]>
  • Loading branch information
djc and rami3l committed Jul 12, 2024
1 parent d327554 commit f256759
Show file tree
Hide file tree
Showing 35 changed files with 51 additions and 51 deletions.
4 changes: 2 additions & 2 deletions doc/dev-guide/src/coding-standards.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ order. Any file that is not grouped like this can be rearranged whenever the
file is touched - we're not precious about having it done in a separate commit,
though that is helpful.

## No direct use of process state outside rustup::currentprocess
## No direct use of process state outside rustup::process

The `rustup::currentprocess` module abstracts the global state that is
The `rustup::process` module abstracts the global state that is
`std::env::args`, `std::env::vars`, `std::io::std*`, `std::process::id`,
`std::env::current_dir` and `std::process::exit` permitting threaded tests of
the CLI logic; use `process()` rather than those APIs directly.
Expand Down
2 changes: 1 addition & 1 deletion src/bin/rustup-init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ use rustup::cli::rustup_mode;
#[cfg(windows)]
use rustup::cli::self_update;
use rustup::cli::setup_mode;
use rustup::currentprocess::Process;
use rustup::env_var::RUST_RECURSION_COUNT_MAX;
use rustup::errors::RustupError;
use rustup::is_proxyable_tools;
use rustup::process::Process;
use rustup::utils::utils;

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion src/cli/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ use tracing::{debug, error, info, trace, warn};

use super::self_update;
use crate::cli::download_tracker::DownloadTracker;
use crate::currentprocess::{terminalsource, Process};
use crate::dist::{
manifest::ComponentStatus, notifications as dist_notifications, TargetTriple, ToolchainDesc,
};
use crate::install::UpdateStatus;
use crate::process::{terminalsource, Process};
use crate::toolchain::{DistributableToolchain, LocalToolchainName, Toolchain, ToolchainName};
use crate::utils::notifications as util_notifications;
use crate::utils::notify::NotificationLevel;
Expand Down
2 changes: 1 addition & 1 deletion src/cli/download_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use std::fmt;
use std::io::Write;
use std::time::{Duration, Instant};

use crate::currentprocess::{terminalsource, Process};
use crate::dist::Notification as In;
use crate::notifications::Notification;
use crate::process::{terminalsource, Process};
use crate::utils::units::{Size, Unit, UnitMode};
use crate::utils::Notification as Un;

Expand Down
2 changes: 1 addition & 1 deletion src/cli/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use tracing_subscriber::{
reload, EnvFilter, Layer, Registry,
};

use crate::{currentprocess::Process, utils::notify::NotificationLevel};
use crate::{process::Process, utils::notify::NotificationLevel};

pub fn tracing_subscriber(
process: &Process,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::io::Write;

use pulldown_cmark::{Event, Tag, TagEnd};

use crate::currentprocess::terminalsource::{Attr, Color, ColorableTerminal};
use crate::process::terminalsource::{Attr, Color, ColorableTerminal};

// Handles the wrapping of text written to the console
struct LineWrapper<'a> {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/proxy_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use anyhow::Result;
use crate::{
cli::{common::set_globals, job, self_update},
command::run_command_for_dir,
currentprocess::Process,
process::Process,
toolchain::ResolvableLocalToolchainName,
};

Expand Down
8 changes: 4 additions & 4 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ use crate::{
},
command,
config::{ActiveReason, Cfg},
currentprocess::{
terminalsource::{self, ColorableTerminal},
Process,
},
dist::{
manifest::{Component, ComponentStatus},
PartialToolchainDesc, Profile, TargetTriple,
},
errors::RustupError,
install::{InstallMethod, UpdateStatus},
process::{
terminalsource::{self, ColorableTerminal},
Process,
},
toolchain::{
CustomToolchainName, DistributableToolchain, LocalToolchainName,
MaybeResolvableToolchainName, ResolvableLocalToolchainName, ResolvableToolchainName,
Expand Down
4 changes: 2 additions & 2 deletions src/cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ use crate::{
markdown::md,
},
config::Cfg,
currentprocess::{terminalsource, Process},
dist::{self, PartialToolchainDesc, Profile, TargetTriple, ToolchainDesc},
errors::RustupError,
install::UpdateStatus,
process::{terminalsource, Process},
toolchain::{
DistributableToolchain, MaybeOfficialToolchainName, ResolvableToolchainName, Toolchain,
ToolchainName,
Expand Down Expand Up @@ -1257,7 +1257,7 @@ mod tests {
use crate::cli::self_update::InstallOpts;
use crate::dist::{PartialToolchainDesc, Profile};
use crate::test::{test_dir, with_rustup_home, Env};
use crate::{currentprocess::TestProcess, for_host};
use crate::{for_host, process::TestProcess};

#[test]
fn default_toolchain_is_stable() {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/self_update/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use std::path::PathBuf;
use anyhow::{bail, Result};

use super::utils;
use crate::currentprocess::Process;
use crate::process::Process;

pub(crate) type Shell = Box<dyn UnixShell>;

Expand Down
2 changes: 1 addition & 1 deletion src/cli/self_update/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use tracing::{error, warn};

use super::install_bins;
use super::shell;
use crate::currentprocess::Process;
use crate::process::Process;
use crate::utils::utils;
use crate::utils::Notification;

Expand Down
4 changes: 2 additions & 2 deletions src/cli/self_update/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ use super::super::errors::*;
use super::common;
use super::{install_bins, report_error, InstallOpts};
use crate::cli::{download_tracker::DownloadTracker, markdown::md};
use crate::currentprocess::{terminalsource::ColorableTerminal, Process};
use crate::dist::TargetTriple;
use crate::process::{terminalsource::ColorableTerminal, Process};
use crate::utils::utils;
use crate::utils::Notification;

Expand Down Expand Up @@ -890,7 +890,7 @@ impl RegistryValueId {
#[cfg(test)]
mod tests {
use super::*;
use crate::currentprocess::TestProcess;
use crate::process::TestProcess;

fn wide(str: &str) -> Vec<u16> {
OsString::from(str).encode_wide().collect()
Expand Down
2 changes: 1 addition & 1 deletion src/cli/setup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use crate::{
common,
self_update::{self, InstallOpts},
},
currentprocess::Process,
dist::Profile,
process::Process,
toolchain::MaybeOfficialToolchainName,
utils::utils,
};
Expand Down
2 changes: 1 addition & 1 deletion src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) fn run_command_for_dir<S: AsRef<OsStr> + Debug>(

// FIXME rust-lang/rust#32254. It's not clear to me
// when and why this is needed.
// TODO: currentprocess support for mocked file descriptor inheritance here: until
// TODO: process support for mocked file descriptor inheritance here: until
// then tests that depend on rustups stdin being inherited won't work in-process.
cmd.stdin(process::Stdio::inherit());

Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ use tracing::trace;

use crate::{
cli::self_update::SelfUpdateMode,
currentprocess::Process,
dist::{self, download::DownloadCfg, temp, PartialToolchainDesc, Profile, ToolchainDesc},
errors::RustupError,
fallback_settings::FallbackSettings,
install::UpdateStatus,
notifications::*,
process::Process,
settings::{MetadataVersion, Settings, SettingsFile},
toolchain::{
CustomToolchainName, DistributableToolchain, LocalToolchainName, PathBasedToolchainName,
Expand Down
2 changes: 1 addition & 1 deletion src/diskio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ use std::{fmt::Debug, fs::OpenOptions};

use anyhow::{Context, Result};

use crate::currentprocess::Process;
use crate::process::Process;
use crate::utils::notifications::Notification;
use threaded::PoolReference;

Expand Down
2 changes: 1 addition & 1 deletion src/diskio/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::HashMap;
use anyhow::Result;

use super::{get_executor, Executor, Item, Kind};
use crate::currentprocess::TestProcess;
use crate::process::TestProcess;
use crate::test::test_dir;

impl Item {
Expand Down
2 changes: 1 addition & 1 deletion src/dist/component/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ use std::path::{Path, PathBuf};

use anyhow::{bail, Result};

use crate::currentprocess::Process;
use crate::dist::component::package::{INSTALLER_VERSION, VERSION_FILE};
use crate::dist::component::transaction::Transaction;
use crate::dist::prefix::InstallPrefix;
use crate::errors::RustupError;
use crate::process::Process;
use crate::utils::utils;

const COMPONENTS_FILE: &str = "components";
Expand Down
2 changes: 1 addition & 1 deletion src/dist/component/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ use anyhow::{anyhow, bail, Context, Result};
use tar::EntryType;
use tracing::warn;

use crate::currentprocess::Process;
use crate::diskio::{get_executor, CompletedIo, Executor, FileBuffer, Item, Kind, IO_CHUNK_SIZE};
use crate::dist::component::components::*;
use crate::dist::component::transaction::*;
use crate::dist::temp;
use crate::errors::*;
use crate::process::Process;
use crate::utils::notifications::Notification;
use crate::utils::utils;

Expand Down
2 changes: 1 addition & 1 deletion src/dist/component/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use std::fs;
use std::io::Write;
use std::path::PathBuf;

use crate::currentprocess::TestProcess;
use crate::dist::component::Transaction;
use crate::dist::prefix::InstallPrefix;
use crate::dist::temp;
use crate::dist::Notification;
use crate::dist::DEFAULT_DIST_SERVER;
use crate::errors::RustupError;
use crate::process::TestProcess;
use crate::utils::raw as utils_raw;
use crate::utils::utils;

Expand Down
2 changes: 1 addition & 1 deletion src/dist/component/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ use std::path::{Path, PathBuf};

use anyhow::{anyhow, Context, Result};

use crate::currentprocess::Process;
use crate::dist::notifications::*;
use crate::dist::prefix::InstallPrefix;
use crate::dist::temp;
use crate::errors::*;
use crate::process::Process;
use crate::utils::utils;

/// A Transaction tracks changes to the file system, allowing them to
Expand Down
2 changes: 1 addition & 1 deletion src/dist/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use anyhow::{anyhow, Context, Result};
use sha2::{Digest, Sha256};
use url::Url;

use crate::currentprocess::Process;
use crate::dist::notifications::*;
use crate::dist::temp;
use crate::errors::*;
use crate::process::Process;
use crate::utils::utils;

const UPDATE_HASH_LEN: usize = 20;
Expand Down
2 changes: 1 addition & 1 deletion src/dist/manifestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use std::path::Path;
use anyhow::{anyhow, bail, Context, Result};
use tokio_retry::{strategy::FixedInterval, RetryIf};

use crate::currentprocess::Process;
use crate::dist::component::{
Components, Package, TarGzPackage, TarXzPackage, TarZStdPackage, Transaction,
};
Expand All @@ -21,6 +20,7 @@ use crate::dist::prefix::InstallPrefix;
use crate::dist::temp;
use crate::dist::{Profile, TargetTriple, DEFAULT_DIST_SERVER};
use crate::errors::RustupError;
use crate::process::Process;
use crate::utils::utils;

pub(crate) const DIST_MANIFEST: &str = "multirust-channel-manifest.toml";
Expand Down
2 changes: 1 addition & 1 deletion src/dist/manifestation/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use anyhow::{anyhow, Result};
use url::Url;

use crate::{
currentprocess::TestProcess,
dist::{
download::DownloadCfg,
manifest::{Component, Manifest},
Expand All @@ -24,6 +23,7 @@ use crate::{
temp, Notification, Profile, TargetTriple, ToolchainDesc, DEFAULT_DIST_SERVER,
},
errors::RustupError,
process::TestProcess,
test::mock::{dist::*, MockComponentBuilder, MockFile, MockInstallerBuilder},
utils::{raw as utils_raw, utils},
};
Expand Down
2 changes: 1 addition & 1 deletion src/dist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use tracing::{info, warn};

use crate::{
config::{dist_root_server, Cfg},
currentprocess::Process,
errors::RustupError,
process::Process,
toolchain::ToolchainName,
utils::utils,
};
Expand Down
4 changes: 2 additions & 2 deletions src/env_var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::env;
use std::path::PathBuf;
use std::process::Command;

use crate::currentprocess::Process;
use crate::process::Process;

pub const RUST_RECURSION_COUNT_MAX: u32 = 20;

Expand Down Expand Up @@ -49,7 +49,7 @@ mod tests {
use super::*;
#[cfg(windows)]
use crate::cli::self_update::{RegistryGuard, USER_PATH};
use crate::currentprocess::TestProcess;
use crate::process::TestProcess;
use crate::test::Env;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ fn component_for_bin(binary: &str) -> Option<&'static str> {
pub mod cli;
mod command;
mod config;
pub mod currentprocess;
mod diskio;
pub mod dist;
pub mod env_var;
pub mod errors;
mod fallback_settings;
mod install;
pub mod notifications;
pub mod process;
mod settings;
#[cfg(feature = "test")]
pub mod test;
Expand Down
2 changes: 1 addition & 1 deletion src/currentprocess.rs → src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use tracing_subscriber::util::SubscriberInitExt;
pub mod filesource;
pub mod terminalsource;

/// Allows concrete types for the currentprocess abstraction.
/// Allows concrete types for the process abstraction.
#[derive(Clone, Debug)]
pub enum Process {
OSProcess(OSProcess),
Expand Down
10 changes: 5 additions & 5 deletions src/currentprocess/filesource.rs → src/process/filesource.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::io::{self, BufRead, Read, Write};

use super::terminalsource::{ColorableTerminal, StreamSelector};
use crate::currentprocess::Process;
use crate::process::Process;

/// Stand-in for std::io::Stdin
pub trait Stdin {
Expand Down Expand Up @@ -48,9 +48,9 @@ impl WriterLock for io::StdoutLock<'_> {}
impl Writer for io::Stdout {
fn is_a_tty(&self, process: &Process) -> bool {
match process {
crate::currentprocess::Process::OSProcess(p) => p.stdout_is_a_tty,
crate::process::Process::OSProcess(p) => p.stdout_is_a_tty,
#[cfg(feature = "test")]
crate::currentprocess::Process::TestProcess(_) => unreachable!(),
crate::process::Process::TestProcess(_) => unreachable!(),
}
}

Expand All @@ -68,9 +68,9 @@ impl WriterLock for io::StderrLock<'_> {}
impl Writer for io::Stderr {
fn is_a_tty(&self, process: &Process) -> bool {
match process {
crate::currentprocess::Process::OSProcess(p) => p.stderr_is_a_tty,
crate::process::Process::OSProcess(p) => p.stderr_is_a_tty,
#[cfg(feature = "test")]
crate::currentprocess::Process::TestProcess(_) => unreachable!(),
crate::process::Process::TestProcess(_) => unreachable!(),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ mod tests {
use std::collections::HashMap;

use super::*;
use crate::currentprocess::TestProcess;
use crate::process::TestProcess;
use crate::test::Env;

#[test]
Expand Down
Loading

0 comments on commit f256759

Please sign in to comment.