Skip to content

Commit

Permalink
test: fix macos tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ecyrbe committed Mar 1, 2020
1 parent 947653f commit e537177
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
7 changes: 7 additions & 0 deletions cli/priority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,20 @@ mod tests {
assert_eq!(priority, PRIORITY_BELOW_NORMAL);
}

#[cfg(not(target_os = "macos"))]
#[test]
fn test_set_current_process_priority_to_normal() {
set_priority(0, PRIORITY_NORMAL).expect("Should set priority");
let priority = get_priority(0).expect("Should get priority");
assert_eq!(priority, PRIORITY_NORMAL);
}

#[cfg(target_os = "macos")]
#[test]
fn test_set_current_process_normal_priority_should_fail() {
assert!(set_priority(0, PRIORITY_NORMAL).is_err());
}

#[cfg(unix)]
#[test]
fn test_set_current_process_high_priority_should_fail() {
Expand Down
36 changes: 29 additions & 7 deletions std/node/os_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,35 @@ test({
}
});

test({
name: "setPriority(): should set current process priority to normal",
fn() {
os.setPriority(os.constants.priority.PRIORITY_NORMAL);
assertEquals(os.getPriority(), os.constants.priority.PRIORITY_NORMAL);
}
});
if (os.platform() !== "darwin")
test({
name: "setPriority(): should set current process priority to normal",
fn() {
os.setPriority(os.constants.priority.PRIORITY_NORMAL);
assertEquals(os.getPriority(), os.constants.priority.PRIORITY_NORMAL);
}
});

if (os.platform() === "win32")
test({
name: "setPriority(): should set current process priority to above normal",
fn() {
os.setPriority(os.constants.priority.PRIORITY_ABOVE_NORMAL);
assertEquals(
os.getPriority(),
os.constants.priority.PRIORITY_ABOVE_NORMAL
);
}
});

if (os.platform() === "win32")
test({
name: "setPriority(): should set current process priority to high",
fn() {
os.setPriority(os.constants.priority.PRIORITY_HIGH);
assertEquals(os.getPriority(), os.constants.priority.PRIORITY_HIGH);
}
});

test({
name: "getPriority(): PID must be a 32 bit integer",
Expand Down

0 comments on commit e537177

Please sign in to comment.