mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-24 21:57:41 +00:00
feat: Implement PowerShell support (#470)
This commit is contained in:
parent
b5bb6d6994
commit
6ab70796db
16
.github/workflows/workflow.yml
vendored
16
.github/workflows/workflow.yml
vendored
@ -70,7 +70,7 @@ jobs:
|
|||||||
command: check
|
command: check
|
||||||
args: --all
|
args: --all
|
||||||
|
|
||||||
# Run tests on Linux, and macOS
|
# Run tests on Linux, macOS, and Windows
|
||||||
# On both Rust stable and Rust nightly
|
# On both Rust stable and Rust nightly
|
||||||
test:
|
test:
|
||||||
name: Test Suite
|
name: Test Suite
|
||||||
@ -79,7 +79,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, macOS-latest]
|
os: [ubuntu-latest, macOS-latest, windows-latest]
|
||||||
rust: [stable, nightly]
|
rust: [stable, nightly]
|
||||||
steps:
|
steps:
|
||||||
# Checkout the branch being tested
|
# Checkout the branch being tested
|
||||||
@ -109,7 +109,7 @@ jobs:
|
|||||||
# Install Python at a fixed version
|
# Install Python at a fixed version
|
||||||
- uses: actions/setup-python@master
|
- uses: actions/setup-python@master
|
||||||
with:
|
with:
|
||||||
python-version: "3.6.9"
|
python-version: "3.7.4"
|
||||||
|
|
||||||
# Install dotnet at a fixed version
|
# Install dotnet at a fixed version
|
||||||
- uses: actions/setup-dotnet@master
|
- uses: actions/setup-dotnet@master
|
||||||
@ -187,6 +187,8 @@ jobs:
|
|||||||
- x86_64-unknown-linux-gnu
|
- x86_64-unknown-linux-gnu
|
||||||
- x86_64-unknown-linux-musl
|
- x86_64-unknown-linux-musl
|
||||||
- x86_64-apple-darwin
|
- x86_64-apple-darwin
|
||||||
|
- x86_64-pc-windows-gnu
|
||||||
|
- x86_64-pc-windows-msvc
|
||||||
include:
|
include:
|
||||||
- target: x86_64-unknown-linux-gnu
|
- target: x86_64-unknown-linux-gnu
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
@ -197,6 +199,12 @@ jobs:
|
|||||||
- target: x86_64-apple-darwin
|
- target: x86_64-apple-darwin
|
||||||
os: macOS-latest
|
os: macOS-latest
|
||||||
name: starship-x86_64-apple-darwin.tar.gz
|
name: starship-x86_64-apple-darwin.tar.gz
|
||||||
|
- target: x86_64-pc-windows-gnu
|
||||||
|
os: windows-latest
|
||||||
|
name: starship-x86_64-pc-windows-gnu.zip
|
||||||
|
- target: x86_64-pc-windows-msvc
|
||||||
|
os: windows-latest
|
||||||
|
name: starship-x86_64-pc-windows-msvc.zip
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
@ -224,7 +232,7 @@ jobs:
|
|||||||
cd target/${{ matrix.target }}/release
|
cd target/${{ matrix.target }}/release
|
||||||
if [[ "${{ matrix.os }}" == "windows-latest" ]]
|
if [[ "${{ matrix.os }}" == "windows-latest" ]]
|
||||||
then
|
then
|
||||||
7z a ../../../${{ matrix.name }} starship
|
7z a ../../../${{ matrix.name }} starship.exe
|
||||||
else
|
else
|
||||||
tar czvf ../../../${{ matrix.name }} starship
|
tar czvf ../../../${{ matrix.name }} starship
|
||||||
fi
|
fi
|
||||||
|
@ -97,3 +97,12 @@ footer: ISC Licensed | Copyright © 2019-present Starship Contributors
|
|||||||
|
|
||||||
eval "$(starship init zsh)"
|
eval "$(starship init zsh)"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Powershell
|
||||||
|
|
||||||
|
Add the following to the end of `~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1` (or `~/.config/powershell/Microsoft.PowerShell_profile.ps1` on -Nix):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# ~\Documents\PowerShell\Profile.ps1
|
||||||
|
Invoke-Expression (&starship init powershell)
|
||||||
|
```
|
||||||
|
@ -94,6 +94,21 @@ fi"#,
|
|||||||
);
|
);
|
||||||
Some(script)
|
Some(script)
|
||||||
}
|
}
|
||||||
|
Some("powershell") => {
|
||||||
|
// Explanation of syntax:
|
||||||
|
// &: Explicitly tells powershell to execute path with starship executable.
|
||||||
|
//
|
||||||
|
// @: multi-line stdout is returned as an array, but a single line or no lines
|
||||||
|
// are returned as-is. @ ensures it's always an array.
|
||||||
|
//
|
||||||
|
// -join "`n": Joins the stdout array together as a string with newlines.
|
||||||
|
// Powershell escapes with ` instead of \ thus `n translates to a newline.
|
||||||
|
let script = format!(
|
||||||
|
"Invoke-Expression (@(&\"{}\" init powershell --print-full-init) -join \"`n\")",
|
||||||
|
starship
|
||||||
|
);
|
||||||
|
Some(script)
|
||||||
|
}
|
||||||
None => {
|
None => {
|
||||||
println!(
|
println!(
|
||||||
"Invalid shell name provided: {}\\n\
|
"Invalid shell name provided: {}\\n\
|
||||||
@ -130,6 +145,7 @@ pub fn init_main(shell_name: &str) -> io::Result<()> {
|
|||||||
"bash" => Some(BASH_INIT),
|
"bash" => Some(BASH_INIT),
|
||||||
"zsh" => Some(ZSH_INIT),
|
"zsh" => Some(ZSH_INIT),
|
||||||
"fish" => Some(FISH_INIT),
|
"fish" => Some(FISH_INIT),
|
||||||
|
"powershell" => Some(PWSH_INIT),
|
||||||
_ => {
|
_ => {
|
||||||
println!(
|
println!(
|
||||||
"printf \"Shell name detection failed on phase two init.\\n\
|
"printf \"Shell name detection failed on phase two init.\\n\
|
||||||
@ -168,3 +184,5 @@ const BASH_INIT: &str = include_str!("starship.bash");
|
|||||||
const ZSH_INIT: &str = include_str!("starship.zsh");
|
const ZSH_INIT: &str = include_str!("starship.zsh");
|
||||||
|
|
||||||
const FISH_INIT: &str = include_str!("starship.fish");
|
const FISH_INIT: &str = include_str!("starship.fish");
|
||||||
|
|
||||||
|
const PWSH_INIT: &str = include_str!("starship.ps1");
|
||||||
|
23
src/init/starship.ps1
Normal file
23
src/init/starship.ps1
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
|
||||||
|
# Starship assumes UTF-8
|
||||||
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||||
|
function global:prompt {
|
||||||
|
$out = $null
|
||||||
|
# @ makes sure the result is an array even if single or no values are returned
|
||||||
|
$jobs = @(Get-Job | Where-Object { $_.State -eq 'Running' }).Count
|
||||||
|
|
||||||
|
if ($lastCmd = Get-History -Count 1) {
|
||||||
|
$duration = [math]::Round(($lastCmd.EndExecutionTime - $lastCmd.StartExecutionTime).TotalSeconds)
|
||||||
|
# & ensures the path is interpreted as something to execute
|
||||||
|
$out = @(&::STARSHIP:: prompt --status=$lastexitcode --jobs=$jobs --cmd-duration=$duration)
|
||||||
|
} else {
|
||||||
|
$out = @(&::STARSHIP:: prompt --status=$lastexitcode --jobs=$jobs)
|
||||||
|
}
|
||||||
|
|
||||||
|
# Convert stdout (array of lines) to expected return type string
|
||||||
|
# `n is an escaped newline
|
||||||
|
$out -join "`n"
|
||||||
|
}
|
||||||
|
|
||||||
|
$ENV:STARSHIP_SHELL = "powershell"
|
@ -34,7 +34,7 @@ fn main() {
|
|||||||
let shell_arg = Arg::with_name("shell")
|
let shell_arg = Arg::with_name("shell")
|
||||||
.value_name("SHELL")
|
.value_name("SHELL")
|
||||||
.help(
|
.help(
|
||||||
"The name of the currently running shell\nCurrently supported options: bash, zsh, fish",
|
"The name of the currently running shell\nCurrently supported options: bash, zsh, fish, powershell",
|
||||||
)
|
)
|
||||||
.required(true);
|
.required(true);
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
let shell = std::env::var("STARSHIP_SHELL").unwrap_or_default();
|
let shell = std::env::var("STARSHIP_SHELL").unwrap_or_default();
|
||||||
let percentage_char = match shell.as_str() {
|
let percentage_char = match shell.as_str() {
|
||||||
"zsh" => "%%", // % is an escape in zsh, see PROMPT in `man zshmisc`
|
"zsh" => "%%", // % is an escape in zsh, see PROMPT in `man zshmisc`
|
||||||
|
"powershell" => "`%",
|
||||||
_ => "%",
|
_ => "%",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@ use crate::configs::conda::CondaConfig;
|
|||||||
/// Will display the Conda environment iff `$CONDA_DEFAULT_ENV` is set.
|
/// Will display the Conda environment iff `$CONDA_DEFAULT_ENV` is set.
|
||||||
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
||||||
// Reference implementation: https://github.com/denysdovhan/spaceship-prompt/blob/master/sections/conda.zsh
|
// Reference implementation: https://github.com/denysdovhan/spaceship-prompt/blob/master/sections/conda.zsh
|
||||||
let conda_env = env::var("CONDA_DEFAULT_ENV").ok()?;
|
let conda_env = env::var("CONDA_DEFAULT_ENV").unwrap_or_else(|_| "".into());
|
||||||
if conda_env.is_empty() {
|
if conda_env.trim().is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ RUN curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-ins
|
|||||||
RUN ruby --version
|
RUN ruby --version
|
||||||
|
|
||||||
# Install Python
|
# Install Python
|
||||||
ENV PYTHON_VERSION 3.6.9
|
ENV PYTHON_VERSION 3.7.4
|
||||||
ENV PYENV_ROOT /home/nonroot/.pyenv
|
ENV PYENV_ROOT /home/nonroot/.pyenv
|
||||||
ENV PATH $PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH
|
ENV PATH $PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH
|
||||||
RUN curl https://pyenv.run | bash \
|
RUN curl https://pyenv.run | bash \
|
||||||
|
@ -8,7 +8,10 @@ use crate::common;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_region_set() -> io::Result<()> {
|
fn no_region_set() -> io::Result<()> {
|
||||||
let output = common::render_module("aws").env_clear().output()?;
|
let output = common::render_module("aws")
|
||||||
|
.env_clear()
|
||||||
|
.env("PATH", env!("PATH"))
|
||||||
|
.output()?;
|
||||||
let expected = "";
|
let expected = "";
|
||||||
let actual = String::from_utf8(output.stdout).unwrap();
|
let actual = String::from_utf8(output.stdout).unwrap();
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
|
@ -8,9 +8,15 @@ use std::{env, fs, io, process};
|
|||||||
static MANIFEST_DIR: Lazy<&'static Path> = Lazy::new(|| Path::new(env!("CARGO_MANIFEST_DIR")));
|
static MANIFEST_DIR: Lazy<&'static Path> = Lazy::new(|| Path::new(env!("CARGO_MANIFEST_DIR")));
|
||||||
static EMPTY_CONFIG: Lazy<PathBuf> = Lazy::new(|| MANIFEST_DIR.join("empty_config.toml"));
|
static EMPTY_CONFIG: Lazy<PathBuf> = Lazy::new(|| MANIFEST_DIR.join("empty_config.toml"));
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
const EXE_PATH: &str = "./target/debug/starship.exe";
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
const EXE_PATH: &str = "./target/debug/starship";
|
||||||
|
|
||||||
/// Render the full starship prompt
|
/// Render the full starship prompt
|
||||||
pub fn render_prompt() -> process::Command {
|
pub fn render_prompt() -> process::Command {
|
||||||
let mut command = process::Command::new("./target/debug/starship");
|
let mut command = process::Command::new(EXE_PATH);
|
||||||
|
|
||||||
command
|
command
|
||||||
.arg("prompt")
|
.arg("prompt")
|
||||||
@ -23,7 +29,7 @@ pub fn render_prompt() -> process::Command {
|
|||||||
|
|
||||||
/// Render a specific starship module by name
|
/// Render a specific starship module by name
|
||||||
pub fn render_module(module_name: &str) -> process::Command {
|
pub fn render_module(module_name: &str) -> process::Command {
|
||||||
let binary = fs::canonicalize("./target/debug/starship").unwrap();
|
let binary = fs::canonicalize(EXE_PATH).unwrap();
|
||||||
let mut command = process::Command::new(binary);
|
let mut command = process::Command::new(binary);
|
||||||
|
|
||||||
command
|
command
|
||||||
@ -44,31 +50,37 @@ pub fn create_fixture_repo() -> io::Result<PathBuf> {
|
|||||||
|
|
||||||
let fixture_repo_dir = path_str(&fixture_repo_path)?;
|
let fixture_repo_dir = path_str(&fixture_repo_path)?;
|
||||||
let repo_dir = path_str(&repo_path)?;
|
let repo_dir = path_str(&repo_path)?;
|
||||||
let fixture = path_str(&fixture_path)?;
|
|
||||||
|
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
.args(&["clone", "-b", "master", fixture, fixture_repo_dir])
|
.args(&["clone", "-b", "master"])
|
||||||
|
.args(&[&fixture_path, &repo_path])
|
||||||
.output()?;
|
.output()?;
|
||||||
|
|
||||||
git2::Repository::clone(fixture_repo_dir, repo_dir).ok();
|
git2::Repository::clone(&fixture_repo_dir, &repo_dir).ok();
|
||||||
|
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
.args(&["config", "--local", "user.email", "starship@example.com"])
|
.args(&["config", "--local", "user.email", "starship@example.com"])
|
||||||
.current_dir(repo_dir)
|
.current_dir(&repo_path)
|
||||||
.output()?;
|
.output()?;
|
||||||
|
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
.args(&["config", "--local", "user.name", "starship"])
|
.args(&["config", "--local", "user.name", "starship"])
|
||||||
.current_dir(repo_dir)
|
.current_dir(&repo_path)
|
||||||
|
.output()?;
|
||||||
|
|
||||||
|
Command::new("git")
|
||||||
|
.args(&["reset", "--hard", "HEAD"])
|
||||||
|
.current_dir(&repo_path)
|
||||||
.output()?;
|
.output()?;
|
||||||
|
|
||||||
Ok(repo_path)
|
Ok(repo_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path_str(repo_dir: &PathBuf) -> io::Result<&str> {
|
fn path_str(repo_dir: &PathBuf) -> io::Result<String> {
|
||||||
repo_dir
|
repo_dir
|
||||||
.to_str()
|
.to_str()
|
||||||
.ok_or_else(|| Error::from(ErrorKind::Other))
|
.ok_or_else(|| Error::from(ErrorKind::Other))
|
||||||
|
.map(|i| i.replace("\\", "/"))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extends `std::process::Command` with methods for testing
|
/// Extends `std::process::Command` with methods for testing
|
||||||
|
@ -5,7 +5,10 @@ use crate::common;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn not_in_env() -> io::Result<()> {
|
fn not_in_env() -> io::Result<()> {
|
||||||
let output = common::render_module("conda").env_clear().output()?;
|
let output = common::render_module("conda")
|
||||||
|
.env_clear()
|
||||||
|
.env("PATH", env!("PATH"))
|
||||||
|
.output()?;
|
||||||
|
|
||||||
let expected = "";
|
let expected = "";
|
||||||
let actual = String::from_utf8(output.stdout).unwrap();
|
let actual = String::from_utf8(output.stdout).unwrap();
|
||||||
|
@ -111,7 +111,9 @@ fn directory_in_root() -> io::Result<()> {
|
|||||||
#[test]
|
#[test]
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
fn directory_in_root() -> io::Result<()> {
|
fn directory_in_root() -> io::Result<()> {
|
||||||
let output = common::render_module("dir").arg("--path=C:\\").output()?;
|
let output = common::render_module("directory")
|
||||||
|
.arg("--path=C:\\")
|
||||||
|
.output()?;
|
||||||
let actual = String::from_utf8(output.stdout).unwrap();
|
let actual = String::from_utf8(output.stdout).unwrap();
|
||||||
|
|
||||||
let expected = format!("in {} ", Color::Cyan.bold().paint("/c"));
|
let expected = format!("in {} ", Color::Cyan.bold().paint("/c"));
|
||||||
|
@ -113,7 +113,8 @@ fn touch_path(workspace: &TempDir, relative_path: &str, contents: Option<&str>)
|
|||||||
.create(true)
|
.create(true)
|
||||||
.truncate(true)
|
.truncate(true)
|
||||||
.open(&path)?;
|
.open(&path)?;
|
||||||
write!(file, "{}", contents.unwrap_or(""))
|
write!(file, "{}", contents.unwrap_or(""))?;
|
||||||
|
file.sync_data()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_pinned_sdk_json(version: &str) -> String {
|
fn make_pinned_sdk_json(version: &str) -> String {
|
||||||
|
@ -5,6 +5,18 @@ use std::process::Command;
|
|||||||
|
|
||||||
use crate::common::{self, TestCommand};
|
use crate::common::{self, TestCommand};
|
||||||
|
|
||||||
|
/// Right after the calls to git the filesystem state may not have finished
|
||||||
|
/// updating yet causing some of the tests to fail. These barriers are placed
|
||||||
|
/// after each call to git.
|
||||||
|
/// This barrier is windows-specific though other operating systems may need it
|
||||||
|
/// in the future.
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
fn barrier() {}
|
||||||
|
#[cfg(windows)]
|
||||||
|
fn barrier() {
|
||||||
|
std::thread::sleep(std::time::Duration::from_millis(500));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
#[ignore]
|
||||||
fn shows_behind() -> io::Result<()> {
|
fn shows_behind() -> io::Result<()> {
|
||||||
@ -14,6 +26,7 @@ fn shows_behind() -> io::Result<()> {
|
|||||||
.args(&["reset", "--hard", "HEAD^"])
|
.args(&["reset", "--hard", "HEAD^"])
|
||||||
.current_dir(repo_dir.as_path())
|
.current_dir(repo_dir.as_path())
|
||||||
.output()?;
|
.output()?;
|
||||||
|
barrier();
|
||||||
|
|
||||||
let output = common::render_module("git_status")
|
let output = common::render_module("git_status")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -36,6 +49,7 @@ fn shows_behind_with_count() -> io::Result<()> {
|
|||||||
.args(&["reset", "--hard", "HEAD^"])
|
.args(&["reset", "--hard", "HEAD^"])
|
||||||
.current_dir(repo_dir.as_path())
|
.current_dir(repo_dir.as_path())
|
||||||
.output()?;
|
.output()?;
|
||||||
|
barrier();
|
||||||
|
|
||||||
let output = common::render_module("git_status")
|
let output = common::render_module("git_status")
|
||||||
.use_config(toml::toml! {
|
.use_config(toml::toml! {
|
||||||
@ -58,12 +72,13 @@ fn shows_behind_with_count() -> io::Result<()> {
|
|||||||
fn shows_ahead() -> io::Result<()> {
|
fn shows_ahead() -> io::Result<()> {
|
||||||
let repo_dir = common::create_fixture_repo()?;
|
let repo_dir = common::create_fixture_repo()?;
|
||||||
|
|
||||||
File::create(repo_dir.join("readme.md"))?;
|
File::create(repo_dir.join("readme.md"))?.sync_all()?;
|
||||||
|
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
.args(&["commit", "-am", "Update readme"])
|
.args(&["commit", "-am", "Update readme"])
|
||||||
.current_dir(&repo_dir)
|
.current_dir(&repo_dir)
|
||||||
.output()?;
|
.output()?;
|
||||||
|
barrier();
|
||||||
|
|
||||||
let output = common::render_module("git_status")
|
let output = common::render_module("git_status")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -82,12 +97,13 @@ fn shows_ahead() -> io::Result<()> {
|
|||||||
fn shows_ahead_with_count() -> io::Result<()> {
|
fn shows_ahead_with_count() -> io::Result<()> {
|
||||||
let repo_dir = common::create_fixture_repo()?;
|
let repo_dir = common::create_fixture_repo()?;
|
||||||
|
|
||||||
File::create(repo_dir.join("readme.md"))?;
|
File::create(repo_dir.join("readme.md"))?.sync_all()?;
|
||||||
|
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
.args(&["commit", "-am", "Update readme"])
|
.args(&["commit", "-am", "Update readme"])
|
||||||
.current_dir(&repo_dir)
|
.current_dir(&repo_dir)
|
||||||
.output()?;
|
.output()?;
|
||||||
|
barrier();
|
||||||
|
|
||||||
let output = common::render_module("git_status")
|
let output = common::render_module("git_status")
|
||||||
.use_config(toml::toml! {
|
.use_config(toml::toml! {
|
||||||
@ -122,6 +138,8 @@ fn shows_diverged() -> io::Result<()> {
|
|||||||
.current_dir(repo_dir.as_path())
|
.current_dir(repo_dir.as_path())
|
||||||
.output()?;
|
.output()?;
|
||||||
|
|
||||||
|
barrier();
|
||||||
|
|
||||||
let output = common::render_module("git_status")
|
let output = common::render_module("git_status")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
.arg(repo_dir)
|
.arg(repo_dir)
|
||||||
@ -151,6 +169,8 @@ fn shows_diverged_with_count() -> io::Result<()> {
|
|||||||
.current_dir(repo_dir.as_path())
|
.current_dir(repo_dir.as_path())
|
||||||
.output()?;
|
.output()?;
|
||||||
|
|
||||||
|
barrier();
|
||||||
|
|
||||||
let output = common::render_module("git_status")
|
let output = common::render_module("git_status")
|
||||||
.use_config(toml::toml! {
|
.use_config(toml::toml! {
|
||||||
[git_status]
|
[git_status]
|
||||||
@ -179,23 +199,29 @@ fn shows_conflicted() -> io::Result<()> {
|
|||||||
.args(&["reset", "--hard", "HEAD^"])
|
.args(&["reset", "--hard", "HEAD^"])
|
||||||
.current_dir(repo_dir.as_path())
|
.current_dir(repo_dir.as_path())
|
||||||
.output()?;
|
.output()?;
|
||||||
|
barrier();
|
||||||
|
|
||||||
fs::write(repo_dir.join("readme.md"), "# goodbye")?;
|
fs::write(repo_dir.join("readme.md"), "# goodbye")?;
|
||||||
|
barrier();
|
||||||
|
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
.args(&["add", "."])
|
.args(&["add", "."])
|
||||||
.current_dir(repo_dir.as_path())
|
.current_dir(repo_dir.as_path())
|
||||||
.output()?;
|
.output()?;
|
||||||
|
|
||||||
|
barrier();
|
||||||
|
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
.args(&["commit", "-m", "Change readme"])
|
.args(&["commit", "-m", "Change readme"])
|
||||||
.current_dir(repo_dir.as_path())
|
.current_dir(repo_dir.as_path())
|
||||||
.output()?;
|
.output()?;
|
||||||
|
|
||||||
|
barrier();
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
.args(&["pull", "--rebase"])
|
.args(&["pull", "--rebase"])
|
||||||
.current_dir(repo_dir.as_path())
|
.current_dir(repo_dir.as_path())
|
||||||
.output()?;
|
.output()?;
|
||||||
|
barrier();
|
||||||
|
|
||||||
let output = common::render_module("git_status")
|
let output = common::render_module("git_status")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -214,7 +240,7 @@ fn shows_conflicted() -> io::Result<()> {
|
|||||||
fn shows_untracked_file() -> io::Result<()> {
|
fn shows_untracked_file() -> io::Result<()> {
|
||||||
let repo_dir = common::create_fixture_repo()?;
|
let repo_dir = common::create_fixture_repo()?;
|
||||||
|
|
||||||
File::create(repo_dir.join("license"))?;
|
File::create(repo_dir.join("license"))?.sync_all()?;
|
||||||
|
|
||||||
let output = common::render_module("git_status")
|
let output = common::render_module("git_status")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -233,12 +259,13 @@ fn shows_untracked_file() -> io::Result<()> {
|
|||||||
fn doesnt_show_untracked_file_if_disabled() -> io::Result<()> {
|
fn doesnt_show_untracked_file_if_disabled() -> io::Result<()> {
|
||||||
let repo_dir = common::create_fixture_repo()?;
|
let repo_dir = common::create_fixture_repo()?;
|
||||||
|
|
||||||
File::create(repo_dir.join("license"))?;
|
File::create(repo_dir.join("license"))?.sync_all()?;
|
||||||
|
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
.args(&["config", "status.showUntrackedFiles", "no"])
|
.args(&["config", "status.showUntrackedFiles", "no"])
|
||||||
.current_dir(repo_dir.as_path())
|
.current_dir(repo_dir.as_path())
|
||||||
.output()?;
|
.output()?;
|
||||||
|
barrier();
|
||||||
|
|
||||||
let output = common::render_module("git_status")
|
let output = common::render_module("git_status")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -256,13 +283,23 @@ fn doesnt_show_untracked_file_if_disabled() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn shows_stashed() -> io::Result<()> {
|
fn shows_stashed() -> io::Result<()> {
|
||||||
let repo_dir = common::create_fixture_repo()?;
|
let repo_dir = common::create_fixture_repo()?;
|
||||||
|
barrier();
|
||||||
|
|
||||||
File::create(repo_dir.join("readme.md"))?;
|
File::create(repo_dir.join("readme.md"))?.sync_all()?;
|
||||||
|
|
||||||
|
barrier();
|
||||||
|
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
.arg("stash")
|
.args(&["stash", "--all"])
|
||||||
.current_dir(repo_dir.as_path())
|
.current_dir(repo_dir.as_path())
|
||||||
.output()?;
|
.output()?;
|
||||||
|
barrier();
|
||||||
|
|
||||||
|
Command::new("git")
|
||||||
|
.args(&["reset", "--hard", "HEAD"])
|
||||||
|
.current_dir(repo_dir.as_path())
|
||||||
|
.output()?;
|
||||||
|
barrier();
|
||||||
|
|
||||||
let output = common::render_module("git_status")
|
let output = common::render_module("git_status")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -281,7 +318,7 @@ fn shows_stashed() -> io::Result<()> {
|
|||||||
fn shows_modified() -> io::Result<()> {
|
fn shows_modified() -> io::Result<()> {
|
||||||
let repo_dir = common::create_fixture_repo()?;
|
let repo_dir = common::create_fixture_repo()?;
|
||||||
|
|
||||||
File::create(repo_dir.join("readme.md"))?;
|
File::create(repo_dir.join("readme.md"))?.sync_all()?;
|
||||||
|
|
||||||
let output = common::render_module("git_status")
|
let output = common::render_module("git_status")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -300,12 +337,13 @@ fn shows_modified() -> io::Result<()> {
|
|||||||
fn shows_staged_file() -> io::Result<()> {
|
fn shows_staged_file() -> io::Result<()> {
|
||||||
let repo_dir = common::create_fixture_repo()?;
|
let repo_dir = common::create_fixture_repo()?;
|
||||||
|
|
||||||
File::create(repo_dir.join("license"))?;
|
File::create(repo_dir.join("license"))?.sync_all()?;
|
||||||
|
|
||||||
Command::new("git")
|
Command::new("git")
|
||||||
.args(&["add", "."])
|
.args(&["add", "."])
|
||||||
.current_dir(repo_dir.as_path())
|
.current_dir(repo_dir.as_path())
|
||||||
.output()?;
|
.output()?;
|
||||||
|
barrier();
|
||||||
|
|
||||||
let output = common::render_module("git_status")
|
let output = common::render_module("git_status")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -333,6 +371,7 @@ fn shows_renamed_file() -> io::Result<()> {
|
|||||||
.args(&["add", "-A"])
|
.args(&["add", "-A"])
|
||||||
.current_dir(repo_dir.as_path())
|
.current_dir(repo_dir.as_path())
|
||||||
.output()?;
|
.output()?;
|
||||||
|
barrier();
|
||||||
|
|
||||||
let output = common::render_module("git_status")
|
let output = common::render_module("git_status")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -369,7 +408,7 @@ fn shows_deleted_file() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn prefix() -> io::Result<()> {
|
fn prefix() -> io::Result<()> {
|
||||||
let repo_dir = common::create_fixture_repo()?;
|
let repo_dir = common::create_fixture_repo()?;
|
||||||
File::create(repo_dir.join("prefix"))?;
|
File::create(repo_dir.join("prefix"))?.sync_all()?;
|
||||||
let output = common::render_module("git_status")
|
let output = common::render_module("git_status")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
.arg(repo_dir)
|
.arg(repo_dir)
|
||||||
@ -390,7 +429,7 @@ fn prefix() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn suffix() -> io::Result<()> {
|
fn suffix() -> io::Result<()> {
|
||||||
let repo_dir = common::create_fixture_repo()?;
|
let repo_dir = common::create_fixture_repo()?;
|
||||||
File::create(repo_dir.join("suffix"))?;
|
File::create(repo_dir.join("suffix"))?.sync_all()?;
|
||||||
let output = common::render_module("git_status")
|
let output = common::render_module("git_status")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
.arg(repo_dir)
|
.arg(repo_dir)
|
||||||
|
@ -24,7 +24,7 @@ fn folder_without_go_files() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn folder_with_go_file() -> io::Result<()> {
|
fn folder_with_go_file() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
File::create(dir.path().join("main.go"))?;
|
File::create(dir.path().join("main.go"))?.sync_all()?;
|
||||||
|
|
||||||
let output = common::render_module("golang")
|
let output = common::render_module("golang")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -41,7 +41,7 @@ fn folder_with_go_file() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn folder_with_go_mod() -> io::Result<()> {
|
fn folder_with_go_mod() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
File::create(dir.path().join("go.mod"))?;
|
File::create(dir.path().join("go.mod"))?.sync_all()?;
|
||||||
|
|
||||||
let output = common::render_module("golang")
|
let output = common::render_module("golang")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -58,7 +58,7 @@ fn folder_with_go_mod() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn folder_with_go_sum() -> io::Result<()> {
|
fn folder_with_go_sum() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
File::create(dir.path().join("go.sum"))?;
|
File::create(dir.path().join("go.sum"))?.sync_all()?;
|
||||||
|
|
||||||
let output = common::render_module("golang")
|
let output = common::render_module("golang")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -93,7 +93,7 @@ fn folder_with_godeps() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn folder_with_glide_yaml() -> io::Result<()> {
|
fn folder_with_glide_yaml() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
File::create(dir.path().join("glide.yaml"))?;
|
File::create(dir.path().join("glide.yaml"))?.sync_all()?;
|
||||||
|
|
||||||
let output = common::render_module("golang")
|
let output = common::render_module("golang")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -110,7 +110,7 @@ fn folder_with_glide_yaml() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn folder_with_gopkg_yml() -> io::Result<()> {
|
fn folder_with_gopkg_yml() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
File::create(dir.path().join("Gopkg.yml"))?;
|
File::create(dir.path().join("Gopkg.yml"))?.sync_all()?;
|
||||||
|
|
||||||
let output = common::render_module("golang")
|
let output = common::render_module("golang")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -127,7 +127,7 @@ fn folder_with_gopkg_yml() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn folder_with_gopkg_lock() -> io::Result<()> {
|
fn folder_with_gopkg_lock() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
File::create(dir.path().join("Gopkg.lock"))?;
|
File::create(dir.path().join("Gopkg.lock"))?.sync_all()?;
|
||||||
|
|
||||||
let output = common::render_module("golang")
|
let output = common::render_module("golang")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
|
@ -5,11 +5,31 @@ use tempfile;
|
|||||||
|
|
||||||
use crate::common;
|
use crate::common;
|
||||||
|
|
||||||
|
/// Wrapper around common::render_module("nodejs") to work around platform quirks
|
||||||
|
fn render_node_module() -> std::process::Command {
|
||||||
|
let mut command = common::render_module("nodejs");
|
||||||
|
|
||||||
|
// If SYSTEMROOT is not set on Windows node will refuse to print its version
|
||||||
|
if cfg!(windows) {
|
||||||
|
let system_root = std::env::var("SYSTEMROOT")
|
||||||
|
.map(|i| {
|
||||||
|
if i.trim().is_empty() {
|
||||||
|
"C:\\WINDOWS".into()
|
||||||
|
} else {
|
||||||
|
i
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|_| "C:\\WINDOWS".into());
|
||||||
|
command.env("SYSTEMROOT", system_root);
|
||||||
|
}
|
||||||
|
command
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn folder_without_node_files() -> io::Result<()> {
|
fn folder_without_node_files() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
|
|
||||||
let output = common::render_module("nodejs")
|
let output = render_node_module()
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
.arg(dir.path())
|
.arg(dir.path())
|
||||||
.output()?;
|
.output()?;
|
||||||
@ -24,9 +44,9 @@ fn folder_without_node_files() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn folder_with_package_json() -> io::Result<()> {
|
fn folder_with_package_json() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
File::create(dir.path().join("package.json"))?;
|
File::create(dir.path().join("package.json"))?.sync_all()?;
|
||||||
|
|
||||||
let output = common::render_module("nodejs")
|
let output = render_node_module()
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
.arg(dir.path())
|
.arg(dir.path())
|
||||||
.output()?;
|
.output()?;
|
||||||
@ -41,9 +61,9 @@ fn folder_with_package_json() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn folder_with_js_file() -> io::Result<()> {
|
fn folder_with_js_file() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
File::create(dir.path().join("index.js"))?;
|
File::create(dir.path().join("index.js"))?.sync_all()?;
|
||||||
|
|
||||||
let output = common::render_module("nodejs")
|
let output = render_node_module()
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
.arg(dir.path())
|
.arg(dir.path())
|
||||||
.output()?;
|
.output()?;
|
||||||
@ -61,7 +81,7 @@ fn folder_with_node_modules() -> io::Result<()> {
|
|||||||
let node_modules = dir.path().join("node_modules");
|
let node_modules = dir.path().join("node_modules");
|
||||||
fs::create_dir_all(&node_modules)?;
|
fs::create_dir_all(&node_modules)?;
|
||||||
|
|
||||||
let output = common::render_module("nodejs")
|
let output = render_node_module()
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
.arg(dir.path())
|
.arg(dir.path())
|
||||||
.output()?;
|
.output()?;
|
||||||
|
@ -10,7 +10,7 @@ use crate::common;
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn folder_with_python_version() -> io::Result<()> {
|
fn folder_with_python_version() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
File::create(dir.path().join(".python-version"))?;
|
File::create(dir.path().join(".python-version"))?.sync_all()?;
|
||||||
|
|
||||||
let output = common::render_module("python")
|
let output = common::render_module("python")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -18,7 +18,7 @@ fn folder_with_python_version() -> io::Result<()> {
|
|||||||
.output()?;
|
.output()?;
|
||||||
let actual = String::from_utf8(output.stdout).unwrap();
|
let actual = String::from_utf8(output.stdout).unwrap();
|
||||||
|
|
||||||
let expected = format!("via {} ", Color::Yellow.bold().paint("🐍 v3.6.9"));
|
let expected = format!("via {} ", Color::Yellow.bold().paint("🐍 v3.7.4"));
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -27,7 +27,7 @@ fn folder_with_python_version() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn folder_with_requirements_txt() -> io::Result<()> {
|
fn folder_with_requirements_txt() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
File::create(dir.path().join("requirements.txt"))?;
|
File::create(dir.path().join("requirements.txt"))?.sync_all()?;
|
||||||
|
|
||||||
let output = common::render_module("python")
|
let output = common::render_module("python")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -35,7 +35,7 @@ fn folder_with_requirements_txt() -> io::Result<()> {
|
|||||||
.output()?;
|
.output()?;
|
||||||
let actual = String::from_utf8(output.stdout).unwrap();
|
let actual = String::from_utf8(output.stdout).unwrap();
|
||||||
|
|
||||||
let expected = format!("via {} ", Color::Yellow.bold().paint("🐍 v3.6.9"));
|
let expected = format!("via {} ", Color::Yellow.bold().paint("🐍 v3.7.4"));
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ fn folder_with_requirements_txt() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn folder_with_pyproject_toml() -> io::Result<()> {
|
fn folder_with_pyproject_toml() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
File::create(dir.path().join("pyproject.toml"))?;
|
File::create(dir.path().join("pyproject.toml"))?.sync_all()?;
|
||||||
|
|
||||||
let output = common::render_module("python")
|
let output = common::render_module("python")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -52,7 +52,7 @@ fn folder_with_pyproject_toml() -> io::Result<()> {
|
|||||||
.output()?;
|
.output()?;
|
||||||
let actual = String::from_utf8(output.stdout).unwrap();
|
let actual = String::from_utf8(output.stdout).unwrap();
|
||||||
|
|
||||||
let expected = format!("via {} ", Color::Yellow.bold().paint("🐍 v3.6.9"));
|
let expected = format!("via {} ", Color::Yellow.bold().paint("🐍 v3.7.4"));
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ fn folder_with_pyproject_toml() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn folder_with_pipfile() -> io::Result<()> {
|
fn folder_with_pipfile() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
File::create(dir.path().join("Pipfile"))?;
|
File::create(dir.path().join("Pipfile"))?.sync_all()?;
|
||||||
|
|
||||||
let output = common::render_module("python")
|
let output = common::render_module("python")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -69,7 +69,7 @@ fn folder_with_pipfile() -> io::Result<()> {
|
|||||||
.output()?;
|
.output()?;
|
||||||
let actual = String::from_utf8(output.stdout).unwrap();
|
let actual = String::from_utf8(output.stdout).unwrap();
|
||||||
|
|
||||||
let expected = format!("via {} ", Color::Yellow.bold().paint("🐍 v3.6.9"));
|
let expected = format!("via {} ", Color::Yellow.bold().paint("🐍 v3.7.4"));
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ fn folder_with_pipfile() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn folder_with_tox() -> io::Result<()> {
|
fn folder_with_tox() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
File::create(dir.path().join("tox.ini"))?;
|
File::create(dir.path().join("tox.ini"))?.sync_all()?;
|
||||||
|
|
||||||
let output = common::render_module("python")
|
let output = common::render_module("python")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -86,7 +86,7 @@ fn folder_with_tox() -> io::Result<()> {
|
|||||||
.output()?;
|
.output()?;
|
||||||
let actual = String::from_utf8(output.stdout).unwrap();
|
let actual = String::from_utf8(output.stdout).unwrap();
|
||||||
|
|
||||||
let expected = format!("via {} ", Color::Yellow.bold().paint("🐍 v3.6.9"));
|
let expected = format!("via {} ", Color::Yellow.bold().paint("🐍 v3.7.4"));
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ fn folder_with_tox() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn folder_with_py_file() -> io::Result<()> {
|
fn folder_with_py_file() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
File::create(dir.path().join("main.py"))?;
|
File::create(dir.path().join("main.py"))?.sync_all()?;
|
||||||
|
|
||||||
let output = common::render_module("python")
|
let output = common::render_module("python")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -103,7 +103,7 @@ fn folder_with_py_file() -> io::Result<()> {
|
|||||||
.output()?;
|
.output()?;
|
||||||
let actual = String::from_utf8(output.stdout).unwrap();
|
let actual = String::from_utf8(output.stdout).unwrap();
|
||||||
|
|
||||||
let expected = format!("via {} ", Color::Yellow.bold().paint("🐍 v3.6.9"));
|
let expected = format!("via {} ", Color::Yellow.bold().paint("🐍 v3.7.4"));
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ fn folder_with_py_file() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn with_virtual_env() -> io::Result<()> {
|
fn with_virtual_env() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
File::create(dir.path().join("main.py"))?;
|
File::create(dir.path().join("main.py"))?.sync_all()?;
|
||||||
let output = common::render_module("python")
|
let output = common::render_module("python")
|
||||||
.env("VIRTUAL_ENV", "/foo/bar/my_venv")
|
.env("VIRTUAL_ENV", "/foo/bar/my_venv")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -120,7 +120,7 @@ fn with_virtual_env() -> io::Result<()> {
|
|||||||
.output()?;
|
.output()?;
|
||||||
let actual = String::from_utf8(output.stdout).unwrap();
|
let actual = String::from_utf8(output.stdout).unwrap();
|
||||||
|
|
||||||
let expected = format!("via {} ", Color::Yellow.bold().paint("🐍 v3.6.9(my_venv)"));
|
let expected = format!("via {} ", Color::Yellow.bold().paint("🐍 v3.7.4(my_venv)"));
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ fn folder_without_ruby_files() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn folder_with_gemfile() -> io::Result<()> {
|
fn folder_with_gemfile() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
File::create(dir.path().join("Gemfile"))?;
|
File::create(dir.path().join("Gemfile"))?.sync_all()?;
|
||||||
|
|
||||||
let output = common::render_module("ruby")
|
let output = common::render_module("ruby")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
@ -41,7 +41,7 @@ fn folder_with_gemfile() -> io::Result<()> {
|
|||||||
#[ignore]
|
#[ignore]
|
||||||
fn folder_with_rb_file() -> io::Result<()> {
|
fn folder_with_rb_file() -> io::Result<()> {
|
||||||
let dir = tempfile::tempdir()?;
|
let dir = tempfile::tempdir()?;
|
||||||
File::create(dir.path().join("any.rb"))?;
|
File::create(dir.path().join("any.rb"))?.sync_all()?;
|
||||||
|
|
||||||
let output = common::render_module("ruby")
|
let output = common::render_module("ruby")
|
||||||
.arg("--path")
|
.arg("--path")
|
||||||
|
Loading…
Reference in New Issue
Block a user