servo: Merge #10534 - Re-enabled etc/ci/check_no_unwrap (from asajeffrey:reenable-check-no-unwrap); r=Manishearth
authorAlan Jeffrey <ajeffrey@mozilla.com>
Tue, 12 Apr 2016 09:28:04 +0500
changeset 338486 38744ec4387bb940b7daf0083b6710fe5b8878d0
parent 338485 48d67a2d0e7ef082ce3c856972f607f6291b4127
child 338487 d3ff60403934d6a4297085282459de97f2c250cb
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersManishearth
servo: Merge #10534 - Re-enabled etc/ci/check_no_unwrap (from asajeffrey:reenable-check-no-unwrap); r=Manishearth Got `etc/ci/check_no_unwrap.sh` to pass, and re-enabled it. Source-Repo: https://github.com/servo/servo Source-Revision: a61fc5285fa00915d538a9672c04030804f7db2d
servo/.travis.yml
servo/components/compositing/compositor.rs
servo/components/compositing/constellation.rs
--- a/servo/.travis.yml
+++ b/servo/.travis.yml
@@ -9,16 +9,17 @@ matrix:
          - ./mach test-tidy --no-progress
       cache: false
     - sudo: 9000
       dist: trusty
       script:
          - ./mach build -d --verbose
          - ./mach test-unit
          - ./mach test-compiletest
+         - bash etc/ci/check_no_unwrap.sh
          - bash etc/ci/lockfile_changed.sh
          - bash etc/ci/manifest_changed.sh
       cache:
         directories:
           - .cargo
           - .servo
           - $HOME/.ccache
       env: CCACHE=/usr/bin/ccache
--- a/servo/components/compositing/compositor.rs
+++ b/servo/components/compositing/compositor.rs
@@ -750,17 +750,17 @@ impl<Window: WindowMethods> IOCompositor
     }
 
     pub fn pipeline_details (&mut self,
                                               pipeline_id: PipelineId)
                                               -> &mut PipelineDetails {
         if !self.pipeline_details.contains_key(&pipeline_id) {
             self.pipeline_details.insert(pipeline_id, PipelineDetails::new());
         }
-        self.pipeline_details.get_mut(&pipeline_id).unwrap()
+        self.pipeline_details.get_mut(&pipeline_id).expect("Insert then get failed!")
     }
 
     pub fn pipeline(&self, pipeline_id: PipelineId) -> Option<&CompositionPipeline> {
         match self.pipeline_details.get(&pipeline_id) {
             Some(ref details) => details.pipeline.as_ref(),
             None => panic!("Compositor layer has an unknown pipeline ({:?}).", pipeline_id),
         }
     }
@@ -2186,17 +2186,17 @@ impl<Window: WindowMethods> IOCompositor
         let orig_pixels = pixels.clone();
         let stride = width * 3;
         for y in 0..height {
             let dst_start = y * stride;
             let src_start = (height - y - 1) * stride;
             let src_slice = &orig_pixels[src_start .. src_start + stride];
             (&mut pixels[dst_start .. dst_start + stride]).clone_from_slice(&src_slice[..stride]);
         }
-        RgbImage::from_raw(width as u32, height as u32, pixels).unwrap()
+        RgbImage::from_raw(width as u32, height as u32, pixels).expect("Flipping image failed!")
     }
 
     fn composite_if_necessary(&mut self, reason: CompositingReason) {
         if self.composition_request == CompositionRequest::NoCompositingNecessary {
             if opts::get().is_running_problem_test {
                 println!("updating composition_request ({:?})", reason);
             }
             self.composition_request = CompositionRequest::CompositeNow(reason)
--- a/servo/components/compositing/constellation.rs
+++ b/servo/components/compositing/constellation.rs
@@ -456,35 +456,38 @@ impl<LTF: LayoutThreadFactory, STF: Scri
     fn spawn_multiprocess(&mut self,
                           pipeline_id: PipelineId,
                           unprivileged_pipeline_content: UnprivilegedPipelineContent)
     {
         // Note that this function can panic, due to process creation,
         // avoiding this panic would require a mechanism for dealing
         // with low-resource scenarios.
         let (server, token) =
-            IpcOneShotServer::<IpcSender<UnprivilegedPipelineContent>>::new().unwrap();
+            IpcOneShotServer::<IpcSender<UnprivilegedPipelineContent>>::new()
+            .expect("Failed to create IPC one-shot server.");
 
         // If there is a sandbox, use the `gaol` API to create the child process.
         let child_process = if opts::get().sandbox {
-            let mut command = sandbox::Command::me().unwrap();
+            let mut command = sandbox::Command::me().expect("Failed to get current sandbox.");
             command.arg("--content-process").arg(token);
             let profile = sandboxing::content_process_sandbox_profile();
-            ChildProcess::Sandboxed(Sandbox::new(profile).start(&mut command).expect(
-                "Failed to start sandboxed child process!"))
+            ChildProcess::Sandboxed(Sandbox::new(profile).start(&mut command)
+                                    .expect("Failed to start sandboxed child process!"))
         } else {
-            let path_to_self = env::current_exe().unwrap();
+            let path_to_self = env::current_exe()
+                .expect("Failed to get current executor.");
             let mut child_process = process::Command::new(path_to_self);
             child_process.arg("--content-process");
             child_process.arg(token);
-            ChildProcess::Unsandboxed(child_process.spawn().unwrap())
+            ChildProcess::Unsandboxed(child_process.spawn()
+                                      .expect("Failed to start unsandboxed child process!"))
         };
 
         self.child_processes.push(child_process);
-        let (_receiver, sender) = server.accept().unwrap();
+        let (_receiver, sender) = server.accept().expect("Server failed to accept.");
         sender.send(unprivileged_pipeline_content)
             .unwrap_or_else(|_| self.handle_send_error(pipeline_id));
     }
 
     #[cfg(target_os = "windows")]
     fn spawn_multiprocess(&mut self, _: PipelineId, _: UnprivilegedPipelineContent) {
         panic!("Multiprocess is not supported on Windows.");
     }
@@ -827,17 +830,18 @@ impl<LTF: LayoutThreadFactory, STF: Scri
 
     fn handle_failure_msg(&mut self,
                           pipeline_id: PipelineId,
                           parent_info: Option<(PipelineId, SubpageId)>) {
         if opts::get().hard_fail {
             // It's quite difficult to make Servo exit cleanly if some threads have failed.
             // Hard fail exists for test runners so we crash and that's good enough.
             let mut stderr = io::stderr();
-            stderr.write_all("Pipeline failed in hard-fail mode.  Crashing!\n".as_bytes()).unwrap();
+            stderr.write_all("Pipeline failed in hard-fail mode.  Crashing!\n".as_bytes())
+                .expect("Failed to write to stderr!");
             process::exit(1);
         }
 
         let window_size = self.pipelines.get(&pipeline_id).and_then(|pipeline| pipeline.size);
 
         self.close_pipeline(pipeline_id, ExitPipelineMode::Force);
 
         while let Some(pending_pipeline_id) = self.pending_frames.iter().find(|pending| {
@@ -1613,17 +1617,17 @@ impl<LTF: LayoutThreadFactory, STF: Scri
             // Check to see if there are any webfonts still loading.
             //
             // If GetWebFontLoadState returns false, either there are no
             // webfonts loading, or there's a WebFontLoaded message waiting in
             // script_chan's message queue. Therefore, we need to check this
             // before we check whether the document is ready; otherwise,
             // there's a race condition where a webfont has finished loading,
             // but hasn't yet notified the document.
-            let (sender, receiver) = ipc::channel().unwrap();
+            let (sender, receiver) = ipc::channel().expect("Failed to create IPC channel!");
             let msg = LayoutControlMsg::GetWebFontLoadState(sender);
             pipeline.layout_chan.0.send(msg)
                 .unwrap_or_else(|e| debug!("Get web font failed ({})", e));
             if receiver.recv().unwrap_or(true) {
                 return ReadyToSave::WebFontNotLoaded;
             }
 
             // See if this pipeline has reached idle script state yet.
@@ -1649,22 +1653,26 @@ impl<LTF: LayoutThreadFactory, STF: Scri
                 // Get the epoch that the compositor has drawn for this pipeline.
                 let compositor_epoch = pipeline_states.get(&frame.current);
                 match compositor_epoch {
                     Some(compositor_epoch) => {
                         // Synchronously query the layout thread to see if the current
                         // epoch matches what the compositor has drawn. If they match
                         // (and script is idle) then this pipeline won't change again
                         // and can be considered stable.
-                        let (sender, receiver) = ipc::channel().unwrap();
+                        let (sender, receiver) = ipc::channel().expect("Failed to create IPC channel!");
                         let LayoutControlChan(ref layout_chan) = pipeline.layout_chan;
-                        layout_chan.send(LayoutControlMsg::GetCurrentEpoch(sender)).unwrap();
-                        let layout_thread_epoch = receiver.recv().unwrap();
-                        if layout_thread_epoch != *compositor_epoch {
-                            return ReadyToSave::EpochMismatch;
+                        if let Err(e) = layout_chan.send(LayoutControlMsg::GetCurrentEpoch(sender)) {
+                            warn!("Failed to send GetCurrentEpoch ({}).", e);
+                        }
+                        match receiver.recv() {
+                            Err(e) => warn!("Failed to receive current epoch ({}).", e),
+                            Ok(layout_thread_epoch) => if layout_thread_epoch != *compositor_epoch {
+                                return ReadyToSave::EpochMismatch;
+                            },
                         }
                     }
                     None => {
                         // The compositor doesn't know about this pipeline yet.
                         // Assume it hasn't rendered yet.
                         return ReadyToSave::PipelineUnknown;
                     }
                 }
@@ -1830,17 +1838,17 @@ impl<LTF: LayoutThreadFactory, STF: Scri
     // permission to each pipeline in the current frame tree.
     fn send_frame_tree_and_grant_paint_permission(&mut self) {
         // Note that this function can panic, due to ipc-channel creation failure.
         // avoiding this panic would require a mechanism for dealing
         // with low-resource scenarios.
         if let Some(root_frame_id) = self.root_frame_id {
             if let Some(frame_tree) = self.frame_to_sendable(root_frame_id) {
 
-                let (chan, port) = ipc::channel().unwrap();
+                let (chan, port) = ipc::channel().expect("Failed to create IPC channel!");
                 self.compositor_proxy.send(ToCompositorMsg::SetFrameTree(frame_tree,
                                                                          chan,
                                                                          self.compositor_sender.clone()));
                 if port.recv().is_err() {
                     debug!("Compositor has discarded SetFrameTree");
                     return; // Our message has been discarded, probably shutting down.
                 }
             }