approvals / go-approval-tests

Apache License 2.0
86 stars 22 forks source link

Reporter not seen #19

Open objarni opened 3 years ago

objarni commented 3 years ago

Hiya,

I tried using this lib for some approvals tonight, but the external reporter (Beyond Compare 4) I finally managed to configure - by writing my own - doesn't show up. After some more digging, this turns out to be because 'something' causes the process to die before the reporter window even shows up.

I switched my custom reporter to use cmd.Run() instead of cmd.Start() to 'prove' this.

Is there something I'm missing...?

Video of behaviour:

https://youtu.be/92SRqny-ojU

objarni commented 3 years ago

System: Ubuntu 20.04

Custom reporter code:

package tests

import (
    "github.com/approvals/go-approval-tests/reporters"
    "os/exec"
)

type beyondCompare struct{}

func NewBCompare() reporters.Reporter {
    return &beyondCompare{}
}

func (s *beyondCompare) Report(approved, received string) bool {
    cmd := exec.Command("/usr/bin/bcompare", approved, received)
    err := cmd.Start()   // Tried switching to Run(), then window does appear...
    if err != nil {
        panic(err)
    }
    return true
}
objarni commented 3 years ago

OK, what closes the reporter window is the test itself, because of the deferred call to r2.Close().

So a 'workaround' is not closing the reporter at all:

image

Is this the way others are using this library?

JanVanRyswyck commented 3 months ago

I seem to have a similar issue on MacOS. I'm using GoLand, and I'm not seeing a diff window appear. I also noticed that only the "received" file is being written, but no "approved" file.