Skip to content

Commit

Permalink
Skip interrupt tests on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
casey committed Aug 26, 2018
1 parent 0d45d9f commit a505b14
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions tests/interrupts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ use executable_path::executable_path;
use tempdir::TempDir;
use std::{process::Command, time::{Duration, Instant}, thread};

#[cfg(unix)]
fn kill(process_id: u32) {
unsafe {
libc::kill(process_id as i32, libc::SIGINT);
}
}

fn interrupt_test(justfile: &str) {
let tmp = TempDir::new("just-interrupts")
.unwrap_or_else(
Expand All @@ -25,9 +32,7 @@ fn interrupt_test(justfile: &str) {

thread::sleep(Duration::new(1, 0));

unsafe {
libc::kill(child.id() as i32, libc::SIGINT);
}
kill(child.id());

let status = child.wait().unwrap();

Expand All @@ -44,29 +49,32 @@ fn interrupt_test(justfile: &str) {
assert_eq!(status.code(), Some(130));
}

#[cfg(unix)]
#[test]
fn shebang_interrupt() {
fn interrupt_shebang() {
interrupt_test("
default:
#!/usr/bin/env sh
sleep 2
");
}

#[cfg(unix)]
#[test]
fn line_interrupt() {
fn interrupt_line() {
interrupt_test("
default:
sleep 2
@sleep 2
");
}

#[cfg(unix)]
#[test]
fn backtick_interrupt() {
fn interrupt_backtick() {
interrupt_test("
foo = `sleep 2`
default:
echo hello
@echo hello
");
}

0 comments on commit a505b14

Please sign in to comment.