diff options
author | Aneesh Agrawal <aneeshusa@gmail.com> | 2017-01-14 22:49:57 -0500 |
---|---|---|
committer | Aneesh Agrawal <aneeshusa@gmail.com> | 2017-01-20 14:24:21 -0500 |
commit | 73485b8a32d56ca7535494c1787b56384ea992b0 (patch) | |
tree | 3515d4513add672a6830af9e95b21eccfb6a6596 | |
parent | d09bf70d220262e2c199abf61b4b78b7137d6665 (diff) | |
download | servo-73485b8a32d56ca7535494c1787b56384ea992b0.tar.gz servo-73485b8a32d56ca7535494c1787b56384ea992b0.zip |
Check all constellation files for panics
Teaches the `etc/ci/check_no_panic.sh` script to handle directories,
so it can check all constellation files for panics.
-rw-r--r-- | components/constellation/timer_scheduler.rs | 8 | ||||
-rwxr-xr-x | etc/ci/check_no_panic.sh | 27 |
2 files changed, 21 insertions, 14 deletions
diff --git a/components/constellation/timer_scheduler.rs b/components/constellation/timer_scheduler.rs index 1578da7a951..832773f0d71 100644 --- a/components/constellation/timer_scheduler.rs +++ b/components/constellation/timer_scheduler.rs @@ -39,7 +39,7 @@ impl PartialEq for ScheduledEvent { impl TimerScheduler { pub fn start() -> IpcSender<TimerEventRequest> { - let (req_ipc_sender, req_ipc_receiver) = ipc::channel().unwrap(); + let (req_ipc_sender, req_ipc_receiver) = ipc::channel().expect("Channel creation failed."); let (req_sender, req_receiver) = mpsc::sync_channel(1); // We could do this much more directly with recv_timeout @@ -92,7 +92,7 @@ impl TimerScheduler { // This thread can terminate if the req_ipc_sender is dropped. warn!("TimerScheduler thread terminated."); }) - .unwrap() + .expect("Thread creation failed.") .thread() .clone(); @@ -105,13 +105,13 @@ impl TimerScheduler { .name(String::from("TimerProxy")) .spawn(move || { while let Ok(req) = req_ipc_receiver.recv() { - req_sender.send(req).unwrap(); + let _ = req_sender.send(req); timeout_thread.unpark(); } // This thread can terminate if the req_ipc_sender is dropped. warn!("TimerProxy thread terminated."); }) - .unwrap(); + .expect("Thread creation failed."); // Return the IPC sender req_ipc_sender diff --git a/etc/ci/check_no_panic.sh b/etc/ci/check_no_panic.sh index c25f45fa763..251d61591d0 100755 --- a/etc/ci/check_no_panic.sh +++ b/etc/ci/check_no_panic.sh @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -# Make sure listed files do not use unwrap() or panic!() +# Make sure listed paths do not use unwrap() or panic!() set -o errexit set -o nounset @@ -13,14 +13,21 @@ set -o pipefail # cd into repo root to make sure paths work in any case cd "$(git rev-parse --show-toplevel)" -FILES=("components/compositing/compositor.rs" - "components/constellation/constellation.rs" - "components/constellation/pipeline.rs" - "ports/glutin/lib.rs" - "ports/glutin/window.rs") +# Each path can be either a single file or a directory +PATHS=( + "components/compositing/compositor.rs" + "components/constellation/" + "ports/glutin/lib.rs" + "ports/glutin/window.rs" +) -# make sure the files exist -ls -1 "${FILES[@]}" +# Make sure the paths exist +ls -1 "${PATHS[@]}" -# make sure the files do not contain "unwrap" or "panic!" -! grep --line-number --with-filename "unwrap(\|panic!(" "${FILES[@]}" +# Make sure the files do not contain "unwrap" or "panic!" +! grep \ + --dereference-recursive \ + --line-number \ + --with-filename \ + "unwrap(\|panic!(" \ + "${PATHS[@]}" |