Skip to content

Commit

Permalink
asds
Browse files Browse the repository at this point in the history
  • Loading branch information
Gankra committed Mar 20, 2024
1 parent f2db573 commit 8fe7c6a
Show file tree
Hide file tree
Showing 28 changed files with 30 additions and 19 deletions.
8 changes: 1 addition & 7 deletions cargo-dist/templates/installer/installer.ps1.j2
Original file line number Diff line number Diff line change
Expand Up @@ -284,17 +284,14 @@ function Invoke-Installer($bin_paths, $platforms) {
# Returns true if the registry was modified, otherwise returns false
# (indicating it was already on PATH)
function Add-Path($OrigPathToAdd) {
Write-Information "updating PATH"
$RegistryPath = "HKCU:\Environment"
$PropertyName = "Path"
$PathToAdd = $OrigPathToAdd

$Item = if (Test-Path $RegistryPath) {
Write-Information "getting HKCU"
# If the registry key exists, get it
Get-Item -Path $RegistryPath
} else {
Write-Information "creating HKCU"
# If the registry key doesn't exist, create it
Write-Verbose "Creating $RegistryPath"
New-Item -Path $RegistryPath -Force
Expand All @@ -306,21 +303,19 @@ function Add-Path($OrigPathToAdd) {
# Otherwise assume there's already paths in here and use a ; separator
$OldPath = $Item | Get-ItemPropertyValue -Name $PropertyName
$PathToAdd = "$PathToAdd;"
Write-Information "path existed"
} catch {
# We'll be creating the PATH from scratch
Write-Verbose "Adding $PropertyName Property to $RegistryPath"
Write-Information "path didn't exist"
}

# Check if the path is already there
#
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Information "nothing to do"
Write-Verbose "install dir already on PATH, all done!"
return $false
} else {
Expand All @@ -329,7 +324,6 @@ function Add-Path($OrigPathToAdd) {
$NewPath = $PathToAdd + $OldPath
# We use -Force here to make the value already existing not be an error
$Item | New-ItemProperty -Name $PropertyName -Value $NewPath -PropertyType String -Force | Out-Null
Write-Information "did the thing"
return $true
}
}
Expand Down
15 changes: 3 additions & 12 deletions cargo-dist/tests/gallery/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,20 +523,15 @@ impl DistResult {
let output = powershell.output_checked(|cmd| {
cmd.arg("-c")
.arg(shell_path)
.arg("-Verbose")
.env("UserProfile", &tempdir)
.env("LOCALAPPDATA", &appdata)
.env("MY_ENV_VAR", &app_home)
.env_remove("CARGO_HOME")
.env_remove("PSModulePath")
})?;
eprintln!(
"installer.ps1 stdout:\n{}",
String::from_utf8(output.stdout).unwrap()
);
eprintln!(
"installer.ps1 stderr:\n{}",
String::from_utf8(output.stderr).unwrap()
);
eprintln!("installer.ps1 stdout:\n{}", String::from_utf8(output.stdout).unwrap());
eprintln!("installer.ps1 stderr:\n{}", String::from_utf8(output.stderr).unwrap());
// log the current PATH in the registry
let new_path = run_ps1_script(
&powershell,
Expand Down Expand Up @@ -597,7 +592,6 @@ impl DistResult {
"{bin_name} path wasn't right"
);
}

// check the install receipts
// FIXME: temporarily disabled for the feature being broken
// self.check_install_receipt(ctx, &bin_dir, &receipt_file, ".exe");
Expand Down Expand Up @@ -888,12 +882,9 @@ impl GenerateResult {

impl Snapshots {
pub fn snap(self) {
eprintln!("{} {} {:?}", self.name, self.payload, self.settings.has_info());
/*
self.settings.bind(|| {
insta::assert_snapshot!(self.name, self.payload);
})
*/
}

pub fn join(mut self, other: Self) -> Self {
Expand Down
1 change: 1 addition & 0 deletions cargo-dist/tests/snapshots/akaikatana_basic.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
1 change: 1 addition & 0 deletions cargo-dist/tests/snapshots/akaikatana_updaters.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
1 change: 1 addition & 0 deletions cargo-dist/tests/snapshots/axolotlsay_abyss.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
1 change: 1 addition & 0 deletions cargo-dist/tests/snapshots/axolotlsay_abyss_only.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
1 change: 1 addition & 0 deletions cargo-dist/tests/snapshots/axolotlsay_basic.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
1 change: 1 addition & 0 deletions cargo-dist/tests/snapshots/axolotlsay_edit_existing.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
1 change: 1 addition & 0 deletions cargo-dist/tests/snapshots/axolotlsay_updaters.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
1 change: 1 addition & 0 deletions cargo-dist/tests/snapshots/axolotlsay_user_host_job.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
1 change: 1 addition & 0 deletions cargo-dist/tests/snapshots/axolotlsay_user_plan_job.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
1 change: 1 addition & 0 deletions cargo-dist/tests/snapshots/install_path_cargo_home.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
1 change: 1 addition & 0 deletions cargo-dist/tests/snapshots/install_path_env_no_subdir.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
1 change: 1 addition & 0 deletions cargo-dist/tests/snapshots/install_path_env_subdir.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ function Add-Path($OrigPathToAdd) {
# We don't want to incorrectly match "C:\blah\" to "C:\blah\blah\", so we include the semicolon
# delimiters when searching, ensuring exact matches. To avoid corner cases we add semicolons to
# both sides of the input, allowing us to pretend we're always in the middle of a list.
Write-Verbose "Old $PropertyName is $OldPath"
if (";$OldPath;" -like "*;$OrigPathToAdd;*") {
# Already on path, nothing to do
Write-Verbose "install dir already on PATH, all done!"
Expand Down

0 comments on commit 8fe7c6a

Please sign in to comment.