Skip to content

Commit

Permalink
[ci] Switch to Travis entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
passcod committed Jan 23, 2019
1 parent eab7511 commit 50924cd
Show file tree
Hide file tree
Showing 19 changed files with 2,631 additions and 1,682 deletions.
91 changes: 84 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,86 @@
dist: xenial
language: rust
cache: cargo
rust:
- stable
- beta
os:
- linux
- osx

cache:
- directories:
- $HOME/.cargo
- target/debug/deps
- target/$TARGET/debug/deps
before_cache:
# Travis can't cache files that are not readable by "others"
- chmod -R a+r $HOME/.cargo

matrix:
fast_finish: true
include:

# Audit only
- env: CARGO_AUDIT=1

# Stable on windows first to get it going (very slow)
- os: windows

# Linux
- os: linux
rust: nightly
- os: linux
rust: 1.26.1
- os: linux

# macOS
- os: osx
rust: nightly
- os: osx
rust: 1.26.1
- os: osx

# Other windowses later
- os: windows
rust: nightly
- os: windows
rust: 1.26.1

# Clippy only
- env: CARGO_CLIPPY=1

allow_failures:
- env: CARGO_CLIPPY=1

before_install:
- set -e
- |
if [ $TRAVIS_OS_NAME = windows ]; then
choco install windows-sdk-10.0
fi
if [[ ! -z "$CARGO_AUDIT" ]]; then
which cargo-audit || cargo install --debug cargo-audit
elif [[ ! -z "$CARGO_CLIPPY" ]]; then
rustup component add clippy
fi
# --debug for faster build at the minimal expense of runtime speed

script:
- |
if [[ ! -z "$CARGO_AUDIT" ]]; then
cargo check
cargo audit
elif [[ ! -z "$CARGO_CLIPPY" ]]; then
cargo clippy
else
cargo test
fi
after_script: set +e

branches:
only:
# release tags
- /^v\d+\.\d+\.\d+.*$/

# test branches
- /^try-/

# main branches
# - main
- next
- v4-legacy
23 changes: 0 additions & 23 deletions appveyor.yml

This file was deleted.

6 changes: 4 additions & 2 deletions examples/monitor_debounced.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate notify;

use notify::{RecommendedWatcher, Watcher, RecursiveMode};
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
use std::path::Path;
use std::sync::mpsc::channel;
use std::time::Duration;
Expand Down Expand Up @@ -28,7 +28,9 @@ fn watch<P: AsRef<Path>>(path: P) -> notify::Result<()> {
}

fn main() {
let path = std::env::args().nth(1).expect("Argument 1 needs to be a path");
let path = std::env::args()
.nth(1)
.expect("Argument 1 needs to be a path");
println!("watching {}", path);
if let Err(e) = watch(path) {
println!("error: {:?}", e)
Expand Down
12 changes: 9 additions & 3 deletions examples/monitor_raw.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate notify;

use notify::{RecommendedWatcher, Watcher, RecursiveMode};
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
use std::path::Path;
use std::sync::mpsc::channel;

Expand All @@ -20,15 +20,21 @@ fn watch<P: AsRef<Path>>(path: P) -> notify::Result<()> {
// for example to handle I/O.
loop {
match rx.recv() {
Ok(notify::RawEvent{path: Some(path), op: Ok(op), cookie}) => println!("{:?} {:?} ({:?})", op, path, cookie),
Ok(notify::RawEvent {
path: Some(path),
op: Ok(op),
cookie,
}) => println!("{:?} {:?} ({:?})", op, path, cookie),
Ok(event) => println!("broken event: {:?}", event),
Err(e) => println!("watch error: {:?}", e),
}
}
}

fn main() {
let path = std::env::args().nth(1).expect("Argument 1 needs to be a path");
let path = std::env::args()
.nth(1)
.expect("Argument 1 needs to be a path");
println!("watching {}", path);
if let Err(e) = watch(path) {
println!("error: {:?}", e)
Expand Down
60 changes: 36 additions & 24 deletions src/debounce/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@

mod timer;

use super::{op, RawEvent, DebouncedEvent};
use super::{op, DebouncedEvent, RawEvent};

use self::timer::WatchTimer;

use std::sync::mpsc;
use std::path::PathBuf;
use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::mpsc;
use std::sync::{Arc, Mutex};
use std::time::Duration;

pub type OperationsBuffer = Arc<Mutex<HashMap<PathBuf,
(Option<op::Op>, Option<PathBuf>, Option<u64>)>>>;
pub type OperationsBuffer =
Arc<Mutex<HashMap<PathBuf, (Option<op::Op>, Option<PathBuf>, Option<u64>)>>>;

pub enum EventTx {
Raw { tx: mpsc::Sender<RawEvent> },
Raw {
tx: mpsc::Sender<RawEvent>,
},
Debounced {
tx: mpsc::Sender<DebouncedEvent>,
debounce: Debounce,
},
DebouncedTx { tx: mpsc::Sender<DebouncedEvent> },
DebouncedTx {
tx: mpsc::Sender<DebouncedEvent>,
},
}

impl EventTx {
Expand All @@ -30,7 +34,10 @@ impl EventTx {
EventTx::Raw { ref tx } => {
let _ = tx.send(event);
}
EventTx::Debounced { ref tx, ref mut debounce } => {
EventTx::Debounced {
ref tx,
ref mut debounce,
} => {
match (event.path, event.op, event.cookie) {
(None, Ok(op::Op::RESCAN), None) => {
let _ = tx.send(DebouncedEvent::Rescan);
Expand Down Expand Up @@ -99,9 +106,12 @@ impl Debounce {
// the last rename event might not be found in case the timer already fired
// (https://github.com/passcod/notify/issues/101).
if let Some(&mut (ref mut operation, ref mut from_path, ref mut timer_id)) =
op_buf.get_mut(self.rename_path.as_ref().unwrap()) {
if op != op::Op::RENAME || self.rename_cookie.is_none() ||
self.rename_cookie != cookie {
op_buf.get_mut(self.rename_path.as_ref().unwrap())
{
if op != op::Op::RENAME
|| self.rename_cookie.is_none()
|| self.rename_cookie != cookie
{
if self.rename_path.as_ref().unwrap().exists() {
match *operation {
Some(op::Op::RENAME) if from_path.is_none() => {
Expand Down Expand Up @@ -194,8 +204,8 @@ impl Debounce {
}

if op.contains(op::Op::CREATE) {
let &mut (ref mut operation, _, ref mut timer_id) = op_buf.entry(path.clone())
.or_insert((None, None, None));
let &mut (ref mut operation, _, ref mut timer_id) =
op_buf.entry(path.clone()).or_insert((None, None, None));
match *operation {
// file can't be created twice
Some(op::Op::CREATE) |
Expand Down Expand Up @@ -229,8 +239,8 @@ impl Debounce {
}

if op.contains(op::Op::WRITE) {
let &mut (ref mut operation, _, ref mut timer_id) = op_buf.entry(path.clone())
.or_insert((None, None, None));
let &mut (ref mut operation, _, ref mut timer_id) =
op_buf.entry(path.clone()).or_insert((None, None, None));
match *operation {
// keep create event / no need to emit NoticeWrite because
// the file has just been created
Expand Down Expand Up @@ -264,8 +274,8 @@ impl Debounce {
}

if op.contains(op::Op::CHMOD) {
let &mut (ref mut operation, _, ref mut timer_id) = op_buf.entry(path.clone())
.or_insert((None, None, None));
let &mut (ref mut operation, _, ref mut timer_id) =
op_buf.entry(path.clone()).or_insert((None, None, None));
match *operation {
// keep create event
Some(op::Op::CREATE) |
Expand Down Expand Up @@ -295,9 +305,11 @@ impl Debounce {

if op.contains(op::Op::RENAME) {
// unwrap is safe because rename_path is Some
if self.rename_path.is_some() && self.rename_cookie.is_some() &&
self.rename_cookie == cookie &&
op_buf.contains_key(self.rename_path.as_ref().unwrap()) {
if self.rename_path.is_some()
&& self.rename_cookie.is_some()
&& self.rename_cookie == cookie
&& op_buf.contains_key(self.rename_path.as_ref().unwrap())
{
// This is the second part of a rename operation, the old path is stored in the
// rename_path variable.

Expand Down Expand Up @@ -355,8 +367,8 @@ impl Debounce {
self.rename_path = Some(path.clone());
self.rename_cookie = cookie;

let &mut (ref mut operation, _, ref mut timer_id) = op_buf.entry(path.clone())
.or_insert((None, None, None));
let &mut (ref mut operation, _, ref mut timer_id) =
op_buf.entry(path.clone()).or_insert((None, None, None));
match *operation {
// keep create event / no need to emit NoticeRemove because
// the file has just been created
Expand Down Expand Up @@ -416,8 +428,8 @@ impl Debounce {
}
}

let &mut (ref mut operation, _, ref mut timer_id) = op_buf.entry(path.clone())
.or_insert((None, None, None));
let &mut (ref mut operation, _, ref mut timer_id) =
op_buf.entry(path.clone()).or_insert((None, None, None));

if remove_path.is_none() {
match *operation {
Expand Down
Loading

0 comments on commit 50924cd

Please sign in to comment.