Skip to content

Commit b2b80ed

Browse files
authored
Enable CI for Windows (ordinals#603)
1 parent 073d37e commit b2b80ed

File tree

7 files changed

+53
-65
lines changed

7 files changed

+53
-65
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* -text

.github/workflows/ci.yaml

+7-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ jobs:
1717
strategy:
1818
matrix:
1919
os:
20-
- ubuntu-latest
2120
- macos-latest
21+
- ubuntu-latest
22+
- windows-latest
2223

2324
runs-on: ${{matrix.os}}
2425

@@ -41,8 +42,13 @@ jobs:
4142
run: cargo update --locked --package ord
4243

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

48+
- name: Build Tests
49+
if: ${{ matrix.os == 'windows-latest' }}
50+
run: cargo build --tests
51+
4652
- name: Clippy
4753
run: cargo clippy --all --all-targets
4854

Cargo.lock

+19-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ tower-http = { version = "0.3.3", features = ["cors"] }
5050

5151
[dev-dependencies]
5252
executable-path = "1.0.0"
53-
nix = "0.25.0"
5453
pretty_assertions = "1.2.1"
5554
tempfile = "3.2.0"
5655
test-bitcoincore-rpc = { path = "test-bitcoincore-rpc" }

tests/command_builder.rs

+5-20
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
use super::*;
22

3-
enum ExpectedExitStatus {
4-
Code(i32),
5-
Signal(Signal),
6-
}
7-
83
pub(crate) struct Output {
94
pub(crate) tempdir: TempDir,
105
pub(crate) stdout: String,
@@ -34,7 +29,7 @@ impl<const N: usize> ToArgs for [&str; N] {
3429

3530
pub(crate) struct CommandBuilder {
3631
args: Vec<String>,
37-
expected_exit_status: ExpectedExitStatus,
32+
expected_exit_code: i32,
3833
expected_stderr: Expected,
3934
expected_stdout: Expected,
4035
rpc_server_url: Option<String>,
@@ -45,7 +40,7 @@ impl CommandBuilder {
4540
pub(crate) fn new(args: impl ToArgs) -> Self {
4641
Self {
4742
args: args.to_args(),
48-
expected_exit_status: ExpectedExitStatus::Code(0),
43+
expected_exit_code: 0,
4944
expected_stderr: Expected::String(String::new()),
5045
expected_stdout: Expected::String(String::new()),
5146
rpc_server_url: None,
@@ -88,16 +83,9 @@ impl CommandBuilder {
8883
}
8984
}
9085

91-
pub(crate) fn expected_exit_code(self, expected_status: i32) -> Self {
92-
Self {
93-
expected_exit_status: ExpectedExitStatus::Code(expected_status),
94-
..self
95-
}
96-
}
97-
98-
pub(crate) fn expected_exit_signal(self, expected_signal: Signal) -> Self {
86+
pub(crate) fn expected_exit_code(self, expected_exit_code: i32) -> Self {
9987
Self {
100-
expected_exit_status: ExpectedExitStatus::Signal(expected_signal),
88+
expected_exit_code,
10189
..self
10290
}
10391
}
@@ -131,10 +119,7 @@ impl CommandBuilder {
131119
let stdout = str::from_utf8(&output.stdout).unwrap();
132120
let stderr = str::from_utf8(&output.stderr).unwrap();
133121

134-
if match self.expected_exit_status {
135-
ExpectedExitStatus::Code(code) => output.status.code() != Some(code),
136-
ExpectedExitStatus::Signal(signal) => output.status.signal() != Some(signal as i32),
137-
} {
122+
if output.status.code() != Some(self.expected_exit_code) {
138123
panic!(
139124
"Test failed: {}\nstdout:\n{}\nstderr:\n{}",
140125
output.status, stdout, stderr

tests/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ use {
44
self::{command_builder::CommandBuilder, expected::Expected},
55
bitcoin::{blockdata::constants::COIN_VALUE, Network, OutPoint},
66
executable_path::executable_path,
7-
nix::{sys::signal::Signal, unistd::Pid},
87
pretty_assertions::assert_eq as pretty_assert_eq,
98
regex::Regex,
109
reqwest::{StatusCode, Url},
1110
std::{
1211
fs,
1312
net::TcpListener,
14-
os::unix::process::ExitStatusExt,
1513
process::{self, Child, Command, Stdio},
1614
str, thread,
1715
time::Duration,

tests/server.rs

+21-10
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,32 @@ use super::*;
44
fn run() {
55
let rpc_server = test_bitcoincore_rpc::spawn();
66

7-
let builder = CommandBuilder::new("server")
8-
.rpc_server(&rpc_server)
9-
.expected_exit_signal(Signal::SIGINT);
7+
let port = TcpListener::bind("127.0.0.1:0")
8+
.unwrap()
9+
.local_addr()
10+
.unwrap()
11+
.port();
12+
13+
let builder = CommandBuilder::new(format!("server --http-port {}", port)).rpc_server(&rpc_server);
1014

1115
let mut command = builder.command();
1216

1317
let mut child = command.spawn().unwrap();
1418

15-
nix::sys::signal::kill(
16-
Pid::from_raw(child.id().try_into().unwrap()),
17-
Signal::SIGINT,
18-
)
19-
.unwrap();
19+
for attempt in 0.. {
20+
if let Ok(response) = reqwest::blocking::get(format!("http://localhost:{port}/status")) {
21+
if response.status() == 200 {
22+
assert_eq!(response.text().unwrap(), "OK");
23+
break;
24+
}
25+
}
2026

21-
child.kill().unwrap();
27+
if attempt == 100 {
28+
panic!("Server did not respond to status check",);
29+
}
2230

23-
builder.check(child.wait_with_output().unwrap());
31+
thread::sleep(Duration::from_millis(50));
32+
}
33+
34+
child.kill().unwrap();
2435
}

0 commit comments

Comments
 (0)