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.
This commit is contained in:
Aneesh Agrawal 2017-01-14 22:49:57 -05:00
parent d09bf70d22
commit 73485b8a32
2 changed files with 21 additions and 14 deletions

View file

@ -39,7 +39,7 @@ impl PartialEq for ScheduledEvent {
impl TimerScheduler { impl TimerScheduler {
pub fn start() -> IpcSender<TimerEventRequest> { 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); let (req_sender, req_receiver) = mpsc::sync_channel(1);
// We could do this much more directly with recv_timeout // 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. // This thread can terminate if the req_ipc_sender is dropped.
warn!("TimerScheduler thread terminated."); warn!("TimerScheduler thread terminated.");
}) })
.unwrap() .expect("Thread creation failed.")
.thread() .thread()
.clone(); .clone();
@ -105,13 +105,13 @@ impl TimerScheduler {
.name(String::from("TimerProxy")) .name(String::from("TimerProxy"))
.spawn(move || { .spawn(move || {
while let Ok(req) = req_ipc_receiver.recv() { while let Ok(req) = req_ipc_receiver.recv() {
req_sender.send(req).unwrap(); let _ = req_sender.send(req);
timeout_thread.unpark(); timeout_thread.unpark();
} }
// This thread can terminate if the req_ipc_sender is dropped. // This thread can terminate if the req_ipc_sender is dropped.
warn!("TimerProxy thread terminated."); warn!("TimerProxy thread terminated.");
}) })
.unwrap(); .expect("Thread creation failed.");
// Return the IPC sender // Return the IPC sender
req_ipc_sender req_ipc_sender

View file

@ -4,7 +4,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # 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/. # 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 errexit
set -o nounset set -o nounset
@ -13,14 +13,21 @@ set -o pipefail
# cd into repo root to make sure paths work in any case # cd into repo root to make sure paths work in any case
cd "$(git rev-parse --show-toplevel)" cd "$(git rev-parse --show-toplevel)"
FILES=("components/compositing/compositor.rs" # Each path can be either a single file or a directory
"components/constellation/constellation.rs" PATHS=(
"components/constellation/pipeline.rs" "components/compositing/compositor.rs"
"ports/glutin/lib.rs" "components/constellation/"
"ports/glutin/window.rs") "ports/glutin/lib.rs"
"ports/glutin/window.rs"
)
# make sure the files exist # Make sure the paths exist
ls -1 "${FILES[@]}" ls -1 "${PATHS[@]}"
# make sure the files do not contain "unwrap" or "panic!" # Make sure the files do not contain "unwrap" or "panic!"
! grep --line-number --with-filename "unwrap(\|panic!(" "${FILES[@]}" ! grep \
--dereference-recursive \
--line-number \
--with-filename \
"unwrap(\|panic!(" \
"${PATHS[@]}"