tasty-golden icon indicating copy to clipboard operation
tasty-golden copied to clipboard

Is there some way to override `--no-create`?

Open brprice opened this issue 2 years ago • 1 comments

I find it too easy to mess up with the default configuration of creating missing golden files. Either by forgetting to commit the file, or by running the testsuite from the wrong working directory (which is easy in a multi-package project, and using cabal run library-test) and not noticing that it only passes because it did not find the golden files. Or worse: forgetting to set --no-create in CI.

I feel it would work better for me if I could configure tasty-golden such that a missing golden file were considered an error, unless a flag is passed to create the file. I had hoped that setting --no-create permanently (in my use case, via tasty-discover) would enable this, but afaict I cannot then override it on the rare occasion that I add a new golden test.

On the other hand, maybe I am missing something, and a better question may be "why do we default to creating missing golden files?"

brprice avatar Mar 10 '22 19:03 brprice

It would be possible to make --no-create the default if the NoCreateFile option would be exported (just opened https://github.com/UnkindPartition/tasty-golden/pull/52 to do that), namely by wrapping the golden TestTree with

localOption (NoCreateFile True)

Then --no-create-file still can't be used to reenable creation of files, but it can be changed in code selectively.

amesgen avatar Jun 03 '22 11:06 amesgen