Skip to content

Make runnable Examples work #590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Feb 27, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Always remove the temp file, even in case of error
  • Loading branch information
flimzy authored and dmitshur committed Feb 27, 2017
commit 01ef481aea2c69d54096b4669ee92bbd38607ceb
8 changes: 4 additions & 4 deletions compiler/natives/src/testing/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ func runExample(eg InternalExample) (ok bool) {
// Close pipe, restore stdout, get output.
Copy link
Member

Choose a reason for hiding this comment

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

Minor, we've changed the code to use file rather than pipe, but the comment still says pipe.

I can fix it.

w.Close()
os.Stdout = stdout
out, e := readFile(w.Name())
if e != nil {
fmt.Fprintf(os.Stderr, "testing: reading stdout file: %v\n", e)
out, readFileErr := readFile(w.Name())
_ = os.Remove(w.Name())
if readFileErr != nil {
fmt.Fprintf(os.Stderr, "testing: reading stdout file: %v\n", readFileErr)
os.Exit(1)
}
_ = os.Remove(w.Name())

var fail string
err := recover()
Expand Down