Skip to content

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

Closed
@flimzy

Description

@flimzy

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions