Skip to content

t.Fatalf() doesn't cause test to fail when triggered by lack of syscalls #506

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

Closed
flimzy opened this issue Sep 4, 2016 · 2 comments
Closed
Labels

Comments

@flimzy
Copy link
Member

flimzy commented Sep 4, 2016

I have a test file which attempts to read a file from disk. When gopherjs has not been configured to support syscalls, this leads to a 'permission denied' error, but the test suite still passes:

$ gopherjs test
gopherjs: Source maps disabled. Use Node.js 4.x with source-map-support module for nice stack traces.
warning: system calls not available, see https://github.com/gopherjs/gopherjs/blob/master/doc/syscalls.md
--- FAIL: TestFile (0.02s)
        test.607290009:23615: Error opening file: open foobarbaz: permission denied
FAIL
ok      github.com/flimzy/jstest        0.326s

My test file:

package main

import (
    "io/ioutil"
    "testing"
)

func TestFile(t *testing.T) {
    _, err := ioutil.ReadFile("foobarbaz")
    t.Fatalf("Error opening file: %s", err)
}

I'm not sure what could possibly be causing this (why should t.Fatalf() care that syscalls are unsupported?), so I'm not entirely sure it's a problem with gopherjs.

I discovered this problem when some Travis CI tests were passing, despite the error message shown above.

@dmitshur dmitshur added the bug label Sep 5, 2016
@dmitshur
Copy link
Member

dmitshur commented Sep 5, 2016

(why should t.Fatalf() care that syscalls are unsupported?), so I'm not entirely sure it's a problem with gopherjs.

A guess is that it's because t.Fatalf calls os.Exit, which in turn requires syscalls. Or something along those lines.

This is a bug, failing individual tests should result in the entire package failing too.

One way of resolving this is to make syscalls module a mandatory part of installing GopherJS. Another way is to simply find a way to make it work without syscalls.

@nevkontakte
Copy link
Member

I believe this is resolved as of #1111.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants