Skip to content

Commit d1b1049

Browse files
Add Windows CI test for self-update
1 parent 6b86066 commit d1b1049

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,24 @@ jobs:
102102
throw 'error on rg.exe'
103103
}
104104
105+
- if: matrix.os == 'windows-latest'
106+
name: "Integration test: [windows] [sync-self]"
107+
env:
108+
SYNC_DIR: "sync-self"
109+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
110+
run: |
111+
mkdir sync-self
112+
113+
copy "target\debug\tool.exe" "sync-self\tool.exe"
114+
115+
sync-self\tool.exe --config="tests\sync-self-downgrade.toml" sync
116+
117+
$old_version = sync-self\tool.exe --version
118+
119+
if ($old_version -notmatch 'tool-sync 0.2.0') {
120+
throw 'self-update is not the same'
121+
}
122+
105123
- if: matrix.os != 'windows-latest'
106124
name: "Integration test: [unix] [sync-full]"
107125
env:

src/sync/install.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use indicatif::ProgressBar;
22
use self_replace;
3-
use std::env;
43
use std::error::Error;
54
use std::fs;
65
use std::path::{Path, PathBuf};
@@ -53,6 +52,8 @@ impl<'a> Installer<'a> {
5352
true
5453
}
5554
Err(e) => {
55+
eprintln!("ee {}", &e);
56+
5657
self.sync_progress
5758
.failure(pb_msg, tool_name, tag, format!("[error] {}", e));
5859
false
@@ -99,13 +100,15 @@ impl<'a> Installer<'a> {
99100
}
100101

101102
fn copy_file(tool_path: PathBuf, store_directory: &Path, exe_name: &str) -> std::io::Result<()> {
103+
let is_self_update = exe_name == "tool";
104+
102105
let exe_name = mk_exe_name(exe_name);
103106

104107
let mut install_path = PathBuf::new();
105108
install_path.push(store_directory);
106109
install_path.push(exe_name);
107110

108-
if &install_path == &env::current_exe()? {
111+
if is_self_update {
109112
// May have issues with a symbolic links. The assumption is that
110113
// the store directory is in the PATH and the executable itself
111114
// where this issue should not apply but may be an edge case.

tests/sync-self-downgrade.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
store_directory = "sync-self"
2+
3+
[tool-sync]
4+
tag = "v0.2.0"

0 commit comments

Comments
 (0)