Skip to content

Commit 130ecc5

Browse files
feat(windows): add basic unit tests
1 parent 87f337e commit 130ecc5

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

.github/workflows/push_pr_checks_tests.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,6 @@ jobs:
8989
with:
9090
toolchain: ${{ env.RUST_VERSION }}
9191

92-
- uses: actions/cache/restore@v4
93-
with:
94-
path: |
95-
~/.cargo/bin/
96-
~/.cargo/registry/index/
97-
~/.cargo/registry/cache/
98-
~/.cargo/git/db/
99-
target/
100-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-checks
101-
10292
- name: Create documentation
10393
run: cargo doc --no-deps --package newrelic_agent_control
10494
env:
@@ -409,7 +399,7 @@ jobs:
409399
E2E_LICENSE_KEY: ${{ secrets.AC_PROD_E2E_LICENSE_KEY }}
410400

411401
build-windows:
412-
name: build-widows-binary
402+
name: build-windows-binary
413403
runs-on: windows-2025
414404
steps:
415405
- uses: actions/checkout@v4
@@ -420,6 +410,19 @@ jobs:
420410
RUST_VERSION=$(grep "rust-version" Cargo.toml | cut -d "=" -f2 | tr -d "[:space:]")
421411
echo "RUST_VERSION=${RUST_VERSION}" >> $GITHUB_ENV
422412
413+
- name: cargo generate-lockfile
414+
if: hashFiles('Cargo.lock') == ''
415+
run: cargo generate-lockfile
416+
- uses: actions/cache@v4
417+
with:
418+
path: |
419+
~/.cargo/bin/
420+
~/.cargo/registry/index/
421+
~/.cargo/registry/cache/
422+
~/.cargo/git/db/
423+
target/
424+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-windows-release
425+
423426
- name: Install Rust ${{ env.RUST_VERSION }}
424427
uses: dtolnay/rust-toolchain@master
425428
with:

agent-control/src/agent_control/pid_cache.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ pub mod tests {
111111
use fs::mock::MockLocalFile;
112112
use std::path::PathBuf;
113113

114+
#[cfg(target_family = "unix")] //TODO This should be removed when Windows support is added
114115
#[test]
115116
fn test_new_pid_when_already_running_pid_fails_storing() {
116117
let already_running_pid: u32 = 123;

agent-control/src/sub_agent/on_host/command/shutdown.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ mod tests {
9090
thread::{self, sleep},
9191
};
9292

93+
#[cfg(target_family = "unix")] //TODO This should be removed when Windows support is added
9394
#[test]
9495
fn shutdown_custom_timeout() {
9596
let mut trap_cmd = Command::new("sh")
@@ -125,6 +126,7 @@ mod tests {
125126
assert_eq!("signal: 9 (SIGKILL)", result.unwrap().to_string());
126127
}
127128

129+
#[cfg(target_family = "unix")] //TODO This should be removed when Windows support is added
128130
#[test]
129131
fn shutdown_on_time() {
130132
let mut trap_cmd = Command::new("sh")

agent-control/src/sub_agent/on_host/supervisor.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ pub mod tests {
485485
use tracing_test::internal::logs_with_scope_contain;
486486
use tracing_test::traced_test;
487487

488+
#[cfg(target_family = "unix")] //TODO This should be removed when Windows support is added
488489
#[traced_test]
489490
#[rstest]
490491
#[case::long_running_process_shutdown_after_start(
@@ -502,11 +503,6 @@ pub mod tests {
502503
ExecutableData::new("sleep".to_owned(), "sleep".to_owned()).with_args(vec!["10".to_owned()]),
503504
None,
504505
vec!["supervisor stopped before starting the process", "stopped supervisor without process running"])]
505-
#[case::long_running_process_shutdown_after_start(
506-
"long-running",
507-
ExecutableData::new("sleep".to_owned(), "sleep".to_owned()).with_args(vec!["10".to_owned()]),
508-
Some(Duration::from_secs(1)),
509-
vec!["stopping supervisor process", "supervisor has been stopped and process terminated"])]
510506
fn test_supervisor_gracefully_shutdown(
511507
#[case] agent_id: &str,
512508
#[case] executable: ExecutableData,

0 commit comments

Comments
 (0)