Skip to content

travis: add and run script which checks if listed files contain "unwrap". Should fix #10446. - #10448

Merged
bors-servo merged 1 commit into
servo:masterfrom
matthiaskrgr:travis
Apr 8, 2016
Merged

bors-servo merged 1 commit into
servo:masterfrom
matthiaskrgr:travis

Conversation

@matthiaskrgr

Copy link
Copy Markdown
Contributor

Unfortunately there is a lot of python code in tidy.py that I don't understand yet, so I simply wrote a bash script to do the job and hooked it up in travis.yml.

Tests are expected to fail:

components/compositing/compositor.rs:758:        self.pipeline_details.get_mut(&pipeline_id).unwrap()
components/compositing/compositor.rs:2194:        RgbImage::from_raw(width as u32, height as u32, pixels).unwrap()
components/compositing/pipeline.rs:130:        let (paint_shutdown_chan, paint_shutdown_port) = ipc::channel().unwrap();
components/compositing/pipeline.rs:131:        let (layout_shutdown_chan, layout_shutdown_port) = ipc::channel().unwrap();
components/compositing/pipeline.rs:132:        let (pipeline_chan, pipeline_port) = ipc::channel().unwrap();
components/compositing/pipeline.rs:133:        let (script_to_compositor_chan, script_to_compositor_port) = ipc::channel().unwrap();
components/compositing/pipeline.rs:151:            let (script_to_devtools_chan, script_to_devtools_port) = ipc::channel().unwrap();
components/compositing/pipeline.rs:154:                let message: ScriptToDevtoolsControlMsg = message.to().unwrap();
components/compositing/pipeline.rs:155:                devtools_chan.send(DevtoolsControlMsg::FromScript(message)).unwrap()
components/compositing/pipeline.rs:161:            ipc::channel().unwrap();
components/compositing/pipeline.rs:174:                    pipeline_port: mem::replace(&mut pipeline_port, None).unwrap(),
components/compositing/pipeline.rs:180:                           .unwrap();
components/compositing/pipeline.rs:184:                let (script_chan, script_port) = ipc::channel().unwrap();
components/compositing/pipeline.rs:190:            ipc::channel().unwrap();
components/compositing/pipeline.rs:298:        let (sender, receiver) = ipc::channel().unwrap();
components/compositing/pipeline.rs:300:        receiver.recv().unwrap();
components/compositing/pipeline.rs:315:        let _ = self.script_chan.send(ConstellationControlMsg::Freeze(self.id)).unwrap();
components/compositing/pipeline.rs:319:        let _ = self.script_chan.send(ConstellationControlMsg::Thaw(self.id)).unwrap();
components/compositing/pipeline.rs:323:        let _ = self.script_chan.send(ConstellationControlMsg::ExitPipeline(self.id)).unwrap();
components/compositing/pipeline.rs:326:        let _ = layout_channel.send(LayoutControlMsg::ExitNow).unwrap();
components/compositing/pipeline.rs:343:        let index = self.children.iter().position(|id| *id == frame_id).unwrap();
components/compositing/pipeline.rs:355:        self.script_chan.send(event).unwrap();
components/compositing/pipeline.rs:402:            control_port: mem::replace(&mut self.script_port, None).unwrap(),
components/compositing/pipeline.rs:423:                                  self.pipeline_port.unwrap(),
components/compositing/pipeline.rs:437:            self.script_content_process_shutdown_port.recv().unwrap();
components/compositing/pipeline.rs:438:            self.layout_content_process_shutdown_port.recv().unwrap();
components/compositing/constellation.rs:464:            IpcOneShotServer::<IpcSender<UnprivilegedPipelineContent>>::new().unwrap();
components/compositing/constellation.rs:468:            let mut command = sandbox::Command::me().unwrap();
components/compositing/constellation.rs:474:            let path_to_self = env::current_exe().unwrap();
components/compositing/constellation.rs:478:            ChildProcess::Unsandboxed(child_process.spawn().unwrap())
components/compositing/constellation.rs:482:        let (_receiver, sender) = server.accept().unwrap();
components/compositing/constellation.rs:835:            stderr.write_all("Pipeline failed in hard-fail mode.  Crashing!\n".as_bytes()).unwrap();
components/compositing/constellation.rs:1621:            let (sender, receiver) = ipc::channel().unwrap();
components/compositing/constellation.rs:1657:                        let (sender, receiver) = ipc::channel().unwrap();
components/compositing/constellation.rs:1659:                        layout_chan.send(LayoutControlMsg::GetCurrentEpoch(sender)).unwrap();
components/compositing/constellation.rs:1660:                        let layout_thread_epoch = receiver.recv().unwrap();
components/compositing/constellation.rs:1838:                let (chan, port) = ipc::channel().unwrap();

This change is Reviewable

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Apr 7, 2016
@notriddle

Copy link
Copy Markdown
Contributor

@bors-servo try

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit b7257e1 with merge 9a1a9e6...

bors-servo pushed a commit that referenced this pull request Apr 7, 2016
travis: add and run script which checks if listed files contain "unwrap". Should fix #10446.

Unfortunately there is a lot of python code in tidy.py that I don't understand yet, so I simply wrote a bash script to do the job and hooked it up in travis.yml.

Tests are expected to fail:

````
components/compositing/compositor.rs:758:        self.pipeline_details.get_mut(&pipeline_id).unwrap()
components/compositing/compositor.rs:2194:        RgbImage::from_raw(width as u32, height as u32, pixels).unwrap()
components/compositing/pipeline.rs:130:        let (paint_shutdown_chan, paint_shutdown_port) = ipc::channel().unwrap();
components/compositing/pipeline.rs:131:        let (layout_shutdown_chan, layout_shutdown_port) = ipc::channel().unwrap();
components/compositing/pipeline.rs:132:        let (pipeline_chan, pipeline_port) = ipc::channel().unwrap();
components/compositing/pipeline.rs:133:        let (script_to_compositor_chan, script_to_compositor_port) = ipc::channel().unwrap();
components/compositing/pipeline.rs:151:            let (script_to_devtools_chan, script_to_devtools_port) = ipc::channel().unwrap();
components/compositing/pipeline.rs:154:                let message: ScriptToDevtoolsControlMsg = message.to().unwrap();
components/compositing/pipeline.rs:155:                devtools_chan.send(DevtoolsControlMsg::FromScript(message)).unwrap()
components/compositing/pipeline.rs:161:            ipc::channel().unwrap();
components/compositing/pipeline.rs:174:                    pipeline_port: mem::replace(&mut pipeline_port, None).unwrap(),
components/compositing/pipeline.rs:180:                           .unwrap();
components/compositing/pipeline.rs:184:                let (script_chan, script_port) = ipc::channel().unwrap();
components/compositing/pipeline.rs:190:            ipc::channel().unwrap();
components/compositing/pipeline.rs:298:        let (sender, receiver) = ipc::channel().unwrap();
components/compositing/pipeline.rs:300:        receiver.recv().unwrap();
components/compositing/pipeline.rs:315:        let _ = self.script_chan.send(ConstellationControlMsg::Freeze(self.id)).unwrap();
components/compositing/pipeline.rs:319:        let _ = self.script_chan.send(ConstellationControlMsg::Thaw(self.id)).unwrap();
components/compositing/pipeline.rs:323:        let _ = self.script_chan.send(ConstellationControlMsg::ExitPipeline(self.id)).unwrap();
components/compositing/pipeline.rs:326:        let _ = layout_channel.send(LayoutControlMsg::ExitNow).unwrap();
components/compositing/pipeline.rs:343:        let index = self.children.iter().position(|id| *id == frame_id).unwrap();
components/compositing/pipeline.rs:355:        self.script_chan.send(event).unwrap();
components/compositing/pipeline.rs:402:            control_port: mem::replace(&mut self.script_port, None).unwrap(),
components/compositing/pipeline.rs:423:                                  self.pipeline_port.unwrap(),
components/compositing/pipeline.rs:437:            self.script_content_process_shutdown_port.recv().unwrap();
components/compositing/pipeline.rs:438:            self.layout_content_process_shutdown_port.recv().unwrap();
components/compositing/constellation.rs:464:            IpcOneShotServer::<IpcSender<UnprivilegedPipelineContent>>::new().unwrap();
components/compositing/constellation.rs:468:            let mut command = sandbox::Command::me().unwrap();
components/compositing/constellation.rs:474:            let path_to_self = env::current_exe().unwrap();
components/compositing/constellation.rs:478:            ChildProcess::Unsandboxed(child_process.spawn().unwrap())
components/compositing/constellation.rs:482:        let (_receiver, sender) = server.accept().unwrap();
components/compositing/constellation.rs:835:            stderr.write_all("Pipeline failed in hard-fail mode.  Crashing!\n".as_bytes()).unwrap();
components/compositing/constellation.rs:1621:            let (sender, receiver) = ipc::channel().unwrap();
components/compositing/constellation.rs:1657:                        let (sender, receiver) = ipc::channel().unwrap();
components/compositing/constellation.rs:1659:                        layout_chan.send(LayoutControlMsg::GetCurrentEpoch(sender)).unwrap();
components/compositing/constellation.rs:1660:                        let layout_thread_epoch = receiver.recv().unwrap();
components/compositing/constellation.rs:1838:                let (chan, port) = ipc::channel().unwrap();
````

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10448)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt

@notriddle

Copy link
Copy Markdown
Contributor

LGTM. Once this is merged, we'll want to add it to servo/saltfs, so that we
can actually gate on this.

On Wed, Apr 6, 2016 at 6:08 PM bors-servo [email protected] wrote:

[image: ☀️] Test successful - android
http://build.servo.org/builders/android/builds/137, arm32
http://build.servo.org/builders/arm32/builds/150, arm64
http://build.servo.org/builders/arm64/builds/143, linux-dev
http://build.servo.org/builders/linux-dev/builds/145, linux-rel
http://build.servo.org/builders/linux-rel/builds/156, mac-dev-unit
http://build.servo.org/builders/mac-dev-unit/builds/150, mac-rel-css
http://build.servo.org/builders/mac-rel-css/builds/143, mac-rel-wpt
http://build.servo.org/builders/mac-rel-wpt/builds/146

—
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#10448 (comment)

@jdm

jdm commented Apr 7, 2016

Copy link
Copy Markdown
Member

Will need to wait for #10423.

@jdm jdm added the S-blocked-on-external Something, somewhere else, needs to happen before this PR can be merged. label Apr 7, 2016
@KiChjang

KiChjang commented Apr 7, 2016

Copy link
Copy Markdown
Contributor

I'd prefer a tidy.py solution, or even a compiler plugin, so that devs can easily check whether their code conforms to this rule.

@KiChjang KiChjang removed the S-awaiting-review There is new code that needs to be reviewed. label Apr 7, 2016
Comment thread etc/ci/check_no_unwrap.sh Outdated
# Make sure listed files do not contain "unwrap"
set -e

cd `git rev-parse --show-toplevel` # cd into repo root so make sure paths works in any case

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use $(git rev-parse --show-toplevel) instead of backticks for process substitution.

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Apr 8, 2016
@matthiaskrgr

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback, done.

@KiChjang

KiChjang commented Apr 8, 2016

Copy link
Copy Markdown
Contributor

There's only 1 changed file in this PR?

@matthiaskrgr

Copy link
Copy Markdown
Contributor Author

Ooops, yes, I forgot to re-add the file after squashing.

Comment thread etc/ci/check_no_unwrap.sh Outdated

# files that should not contain "unwrap"
FILES=("components/compositing/compositor.rs"
"components/compositing/pipeline.rs"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, looks like markdown messed up the indentation here - can you line up all of the starting quotes?

@KiChjang

KiChjang commented Apr 8, 2016

Copy link
Copy Markdown
Contributor

r? @aneeshusa

@aneeshusa

Copy link
Copy Markdown
Contributor

This looks great aside from the indentation nit - @matthiaskrgr once you take care of that then r=me.

@KiChjang KiChjang assigned aneeshusa and unassigned KiChjang Apr 8, 2016
@aneeshusa

Copy link
Copy Markdown
Contributor

I took a deeper look at the Travis failure and unfortunately we need a more complicated lint. There are some unwrap() calls in these files where there is no good story for clean error recovery and a panic is the best option, so our simple grep is not enough. It looks like each one already has a detailed comment explaining why panicing is allowed, but some comments are on the previous line while others have a comment for an entire function that is allowed to panic. I see a few options:

  • Only allow unwrap() on lines with a // allow_panic comment on it, and check during reviews that each instance has a longer associated comment. This is probably easier to do, but less satisfying to me. I think this is complicated enough that we should switch from a shell script to Python for this.
  • Use a compiler lint like result_unwrap_used from rust-clippy, but only enforce it on these files. This makes it easy to use #[allow(unwrap)] on whole functions - is it possible to apply an attribute to a single line of code? I'm not sure how feasible this is and it would take longer, but this seems cleaner.
  • Add a highfive warning for manual review if the changes include new instances of unwrap().

Open to suggestions here.

@asajeffrey

Copy link
Copy Markdown
Contributor

I've been replacing unavoidable uses of unwrap() by expect("msg"), so a simple syntactic check should be enough.

@aneeshusa

Copy link
Copy Markdown
Contributor

Great, I completely forgot about expect(). @bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit dc4fe7e has been approved by aneeshusa

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Apr 8, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit dc4fe7e with merge c56eb65...

bors-servo pushed a commit that referenced this pull request Apr 8, 2016
travis: add and run script which checks if listed files contain "unwrap". Should fix #10446.

Unfortunately there is a lot of python code in tidy.py that I don't understand yet, so I simply wrote a bash script to do the job and hooked it up in travis.yml.

Tests are expected to fail:

````
components/compositing/compositor.rs:758:        self.pipeline_details.get_mut(&pipeline_id).unwrap()
components/compositing/compositor.rs:2194:        RgbImage::from_raw(width as u32, height as u32, pixels).unwrap()
components/compositing/pipeline.rs:130:        let (paint_shutdown_chan, paint_shutdown_port) = ipc::channel().unwrap();
components/compositing/pipeline.rs:131:        let (layout_shutdown_chan, layout_shutdown_port) = ipc::channel().unwrap();
components/compositing/pipeline.rs:132:        let (pipeline_chan, pipeline_port) = ipc::channel().unwrap();
components/compositing/pipeline.rs:133:        let (script_to_compositor_chan, script_to_compositor_port) = ipc::channel().unwrap();
components/compositing/pipeline.rs:151:            let (script_to_devtools_chan, script_to_devtools_port) = ipc::channel().unwrap();
components/compositing/pipeline.rs:154:                let message: ScriptToDevtoolsControlMsg = message.to().unwrap();
components/compositing/pipeline.rs:155:                devtools_chan.send(DevtoolsControlMsg::FromScript(message)).unwrap()
components/compositing/pipeline.rs:161:            ipc::channel().unwrap();
components/compositing/pipeline.rs:174:                    pipeline_port: mem::replace(&mut pipeline_port, None).unwrap(),
components/compositing/pipeline.rs:180:                           .unwrap();
components/compositing/pipeline.rs:184:                let (script_chan, script_port) = ipc::channel().unwrap();
components/compositing/pipeline.rs:190:            ipc::channel().unwrap();
components/compositing/pipeline.rs:298:        let (sender, receiver) = ipc::channel().unwrap();
components/compositing/pipeline.rs:300:        receiver.recv().unwrap();
components/compositing/pipeline.rs:315:        let _ = self.script_chan.send(ConstellationControlMsg::Freeze(self.id)).unwrap();
components/compositing/pipeline.rs:319:        let _ = self.script_chan.send(ConstellationControlMsg::Thaw(self.id)).unwrap();
components/compositing/pipeline.rs:323:        let _ = self.script_chan.send(ConstellationControlMsg::ExitPipeline(self.id)).unwrap();
components/compositing/pipeline.rs:326:        let _ = layout_channel.send(LayoutControlMsg::ExitNow).unwrap();
components/compositing/pipeline.rs:343:        let index = self.children.iter().position(|id| *id == frame_id).unwrap();
components/compositing/pipeline.rs:355:        self.script_chan.send(event).unwrap();
components/compositing/pipeline.rs:402:            control_port: mem::replace(&mut self.script_port, None).unwrap(),
components/compositing/pipeline.rs:423:                                  self.pipeline_port.unwrap(),
components/compositing/pipeline.rs:437:            self.script_content_process_shutdown_port.recv().unwrap();
components/compositing/pipeline.rs:438:            self.layout_content_process_shutdown_port.recv().unwrap();
components/compositing/constellation.rs:464:            IpcOneShotServer::<IpcSender<UnprivilegedPipelineContent>>::new().unwrap();
components/compositing/constellation.rs:468:            let mut command = sandbox::Command::me().unwrap();
components/compositing/constellation.rs:474:            let path_to_self = env::current_exe().unwrap();
components/compositing/constellation.rs:478:            ChildProcess::Unsandboxed(child_process.spawn().unwrap())
components/compositing/constellation.rs:482:        let (_receiver, sender) = server.accept().unwrap();
components/compositing/constellation.rs:835:            stderr.write_all("Pipeline failed in hard-fail mode.  Crashing!\n".as_bytes()).unwrap();
components/compositing/constellation.rs:1621:            let (sender, receiver) = ipc::channel().unwrap();
components/compositing/constellation.rs:1657:                        let (sender, receiver) = ipc::channel().unwrap();
components/compositing/constellation.rs:1659:                        layout_chan.send(LayoutControlMsg::GetCurrentEpoch(sender)).unwrap();
components/compositing/constellation.rs:1660:                        let layout_thread_epoch = receiver.recv().unwrap();
components/compositing/constellation.rs:1838:                let (chan, port) = ipc::channel().unwrap();
````

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10448)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt

@bors-servo
bors-servo merged commit dc4fe7e into servo:master Apr 8, 2016
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Apr 8, 2016
@aneeshusa

Copy link
Copy Markdown
Contributor

Thanks @matthiaskrgr! In order to enforce this, we need to add a step running this to our saltfs configurations, specifically in the Buildbot master configuration - do you want to work on a PR for this?

@matthiaskrgr

Copy link
Copy Markdown
Contributor Author

Neither do I have experience regarding buildbot configuration nor a local buildbotsetup to test changes on, so I guess I'll have to pass on that one.

@timvandermeij

Copy link
Copy Markdown
Contributor

Travis seems to fail with The command "bash etc/ci/check_no_unwrap.sh" exited with 1 for all new PRs in the queue. I guess the failing occurrences (see e.g. https://travis-ci.org/servo/servo/jobs/121820005#L1426) have not been fixed before this PR was landed, or something else is going on. Since I don't know anything about these Servo internals, could someone else verify?

@matthiaskrgr

Copy link
Copy Markdown
Contributor Author

Yes, as I said at the very beginning of the pull request, tests are expected to fail.
The S-blocked-on-external label was still there at the time of merge.

bors-servo pushed a commit that referenced this pull request Apr 9, 2016
…KiChjang

Removed etc/ci/check_no_unwrap.sh from .travis.yml

Temporarily disable #10448 until all the uses of unwrap are removed from the constellation/compositor.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10495)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-blocked-on-external Something, somewhere else, needs to happen before this PR can be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants