-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump version: 0.3.13 -> 0.4.0 (#401)
- Loading branch information
Showing
5 changed files
with
73 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "just" | ||
version = "0.3.13" | ||
version = "0.4.0" | ||
description = "🤖 Just a command runner" | ||
authors = ["Casey Rodarmor <[email protected]>"] | ||
license = "CC0-1.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,87 @@ | ||
use executable_path::executable_path; | ||
use std::{ | ||
process::Command, | ||
time::{Duration, Instant}, | ||
}; | ||
use tempdir::TempDir; | ||
|
||
#[cfg(unix)] | ||
fn kill(process_id: u32) { | ||
unsafe { | ||
libc::kill(process_id as i32, libc::SIGINT); | ||
mod unix { | ||
use executable_path::executable_path; | ||
use std::{ | ||
process::Command, | ||
time::{Duration, Instant}, | ||
}; | ||
use tempdir::TempDir; | ||
|
||
fn kill(process_id: u32) { | ||
unsafe { | ||
libc::kill(process_id as i32, libc::SIGINT); | ||
} | ||
} | ||
} | ||
|
||
#[cfg(unix)] | ||
fn interrupt_test(justfile: &str) { | ||
let tmp = TempDir::new("just-interrupts").unwrap_or_else(|err| { | ||
panic!( | ||
"integration test: failed to create temporary directory: {}", | ||
err | ||
) | ||
}); | ||
fn interrupt_test(justfile: &str) { | ||
let tmp = TempDir::new("just-interrupts").unwrap_or_else(|err| { | ||
panic!( | ||
"integration test: failed to create temporary directory: {}", | ||
err | ||
) | ||
}); | ||
|
||
let mut justfile_path = tmp.path().to_path_buf(); | ||
justfile_path.push("justfile"); | ||
brev::dump(justfile_path, justfile); | ||
let mut justfile_path = tmp.path().to_path_buf(); | ||
justfile_path.push("justfile"); | ||
brev::dump(justfile_path, justfile); | ||
|
||
let start = Instant::now(); | ||
let start = Instant::now(); | ||
|
||
let mut child = Command::new(&executable_path("just")) | ||
.current_dir(&tmp) | ||
.spawn() | ||
.expect("just invocation failed"); | ||
let mut child = Command::new(&executable_path("just")) | ||
.current_dir(&tmp) | ||
.spawn() | ||
.expect("just invocation failed"); | ||
|
||
while start.elapsed() < Duration::from_millis(500) {} | ||
while start.elapsed() < Duration::from_millis(500) {} | ||
|
||
kill(child.id()); | ||
kill(child.id()); | ||
|
||
let status = child.wait().unwrap(); | ||
let status = child.wait().unwrap(); | ||
|
||
let elapsed = start.elapsed(); | ||
let elapsed = start.elapsed(); | ||
|
||
if elapsed > Duration::from_secs(2) { | ||
panic!("process returned too late: {:?}", elapsed); | ||
} | ||
if elapsed > Duration::from_secs(2) { | ||
panic!("process returned too late: {:?}", elapsed); | ||
} | ||
|
||
if elapsed < Duration::from_millis(100) { | ||
panic!("process returned too early : {:?}", elapsed); | ||
} | ||
if elapsed < Duration::from_millis(100) { | ||
panic!("process returned too early : {:?}", elapsed); | ||
} | ||
|
||
assert_eq!(status.code(), Some(130)); | ||
} | ||
assert_eq!(status.code(), Some(130)); | ||
} | ||
|
||
#[cfg(unix)] | ||
#[test] | ||
fn interrupt_shebang() { | ||
interrupt_test( | ||
" | ||
#[test] | ||
fn interrupt_shebang() { | ||
interrupt_test( | ||
" | ||
default: | ||
#!/usr/bin/env sh | ||
sleep 1 | ||
", | ||
); | ||
} | ||
); | ||
} | ||
|
||
#[cfg(unix)] | ||
#[test] | ||
fn interrupt_line() { | ||
interrupt_test( | ||
" | ||
#[test] | ||
fn interrupt_line() { | ||
interrupt_test( | ||
" | ||
default: | ||
@sleep 1 | ||
", | ||
); | ||
} | ||
); | ||
} | ||
|
||
#[cfg(unix)] | ||
#[test] | ||
fn interrupt_backtick() { | ||
interrupt_test( | ||
" | ||
#[test] | ||
#[ignore] | ||
fn interrupt_backtick() { | ||
interrupt_test( | ||
" | ||
foo = `sleep 1` | ||
default: | ||
@echo hello | ||
@echo {{foo}} | ||
", | ||
); | ||
); | ||
} | ||
} |