Skip to content

Commit

Permalink
Enable Windows tests on CI (#846)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Dec 5, 2022
1 parent 8ded343 commit 87832c6
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 29 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,4 @@ jobs:
- uses: Swatinem/rust-cache@v1

- name: Test
if: ${{ matrix.os != 'windows-latest' }}
run: cargo test --all

- name: Build Tests
if: ${{ matrix.os == 'windows-latest' }}
run: cargo build --tests
91 changes: 74 additions & 17 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ mod tests {
.unwrap()
.display()
.to_string()
.ends_with("/signet/.cookie"))
.ends_with(if cfg!(windows) {
r"\signet\.cookie"
} else {
"/signet/.cookie"
}));
}

#[test]
Expand All @@ -191,11 +195,13 @@ mod tests {
.display()
.to_string();

if cfg!(target_os = "linux") {
assert!(cookie_file.ends_with("/.bitcoin/.cookie"));
assert!(cookie_file.ends_with(if cfg!(target_os = "linux") {
"/.bitcoin/.cookie"
} else if cfg!(windows) {
r"\Bitcoin\.cookie"
} else {
assert!(cookie_file.ends_with("/Bitcoin/.cookie"));
}
"/Bitcoin/.cookie"
}))
}

#[test]
Expand All @@ -209,11 +215,13 @@ mod tests {
.display()
.to_string();

if cfg!(target_os = "linux") {
assert!(cookie_file.ends_with("/.bitcoin/signet/.cookie"));
assert!(cookie_file.ends_with(if cfg!(target_os = "linux") {
"/.bitcoin/signet/.cookie"
} else if cfg!(windows) {
r"\Bitcoin\signet\.cookie"
} else {
assert!(cookie_file.ends_with("/Bitcoin/signet/.cookie"));
}
"/Bitcoin/signet/.cookie"
}));
}

#[test]
Expand All @@ -229,7 +237,11 @@ mod tests {
.display()
.to_string();

assert!(cookie_file.ends_with("foo/signet/.cookie"));
assert!(cookie_file.ends_with(if cfg!(windows) {
r"foo\signet\.cookie"
} else {
"foo/signet/.cookie"
}));
}

#[test]
Expand All @@ -241,7 +253,10 @@ mod tests {
.unwrap()
.display()
.to_string();
assert!(data_dir.ends_with("/ord"), "{data_dir}");
assert!(
data_dir.ends_with(if cfg!(windows) { r"\ord" } else { "/ord" }),
"{data_dir}"
);
}

#[test]
Expand All @@ -253,7 +268,14 @@ mod tests {
.unwrap()
.display()
.to_string();
assert!(data_dir.ends_with("/ord/signet"), "{data_dir}");
assert!(
data_dir.ends_with(if cfg!(windows) {
r"\ord\signet"
} else {
"/ord/signet"
}),
"{data_dir}"
);
}

#[test]
Expand All @@ -266,7 +288,14 @@ mod tests {
.unwrap()
.display()
.to_string();
assert!(data_dir.ends_with("foo/signet"), "{data_dir}");
assert!(
data_dir.ends_with(if cfg!(windows) {
r"foo\signet"
} else {
"foo/signet"
}),
"{data_dir}"
);
}

#[test]
Expand All @@ -285,10 +314,38 @@ mod tests {

check_network_alias("main", "ord");
check_network_alias("mainnet", "ord");
check_network_alias("regtest", "ord/regtest");
check_network_alias("signet", "ord/signet");
check_network_alias("test", "ord/testnet3");
check_network_alias("testnet", "ord/testnet3");
check_network_alias(
"regtest",
if cfg!(windows) {
r"ord\regtest"
} else {
"ord/regtest"
},
);
check_network_alias(
"signet",
if cfg!(windows) {
r"ord\signet"
} else {
"ord/signet"
},
);
check_network_alias(
"test",
if cfg!(windows) {
r"ord\testnet3"
} else {
"ord/testnet3"
},
);
check_network_alias(
"testnet",
if cfg!(windows) {
r"ord\testnet3"
} else {
"ord/testnet3"
},
);
}

#[test]
Expand Down
9 changes: 8 additions & 1 deletion src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,14 @@ mod tests {
.unwrap()
.display()
.to_string();
assert!(acme_cache.contains("foo/acme-cache"), "{acme_cache}")
assert!(
acme_cache.contains(if cfg!(windows) {
r"foo\acme-cache"
} else {
"foo/acme-cache"
}),
"{acme_cache}"
)
}

#[test]
Expand Down
3 changes: 2 additions & 1 deletion src/subcommand/wallet/identify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ impl Identify {
if let Some(path) = &self.ordinals {
for (output, ordinal) in identify_from_tsv(
utxos,
&fs::read_to_string(path).with_context(|| "I/O error reading `{path}`")?,
&fs::read_to_string(path)
.with_context(|| format!("I/O error reading `{}`", path.display()))?,
)? {
println!("{output}\t{ordinal}");
}
Expand Down
3 changes: 2 additions & 1 deletion tests/command_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ impl CommandBuilder {
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.env("HOME", self.tempdir.path())
.current_dir(&self.tempdir)
.arg("--data-dir")
.arg(self.tempdir.path())
.args(&self.args);

command
Expand Down
1 change: 0 additions & 1 deletion tests/test_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ impl TestServer {
tempdir.path().display(),
args.join(" "),
).to_args())
.env("HOME", tempdir.path())
.env("ORD_DISABLE_PROGRESS_BAR", "1")
.current_dir(&tempdir)
.spawn().unwrap();
Expand Down
4 changes: 1 addition & 3 deletions tests/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ fn identify_from_tsv_file_not_found() {
CommandBuilder::new("wallet identify --ordinals foo.tsv")
.rpc_server(&rpc_server)
.expected_exit_code(1)
.expected_stderr(
"error: I/O error reading `{path}`\nbecause: No such file or directory (os error 2)\n",
)
.stderr_regex("error: I/O error reading `.*`\nbecause: .*\n")
.run();
}

Expand Down

0 comments on commit 87832c6

Please sign in to comment.