testcontainers / testcontainers-go

Testcontainers for Go is a Go package that makes it simple to create and clean up container-based dependencies for automated integration/smoke tests. The clean, easy-to-use API enables developers to programmatically define containers that should be run as part of a test and clean up those resources when the test is done.
https://golang.testcontainers.org
MIT License
3.36k stars 460 forks source link

[Enhancement]: modulegen: print output from failed commands #1689

Open pablochacin opened 10 months ago

pablochacin commented 10 months ago

Proposal

When generating the scaffold for a new module, the modulegen tool executes multiple commands.

In case one of them fails, it is only reported the step that failed, but the actual error is not reported, as seen in the following output:

Error: >> error synchronizing the dependencies: exit status 1

A more detailed output from the tool would facilitate the debugging of errors. For example:

Error: >> error synchronizing the dependencies: exit status 1

go: finding module for package github.com/testcontainers/testcontainers-go/modules/k6
github.com/testcontainers/testcontainers-go/examples/k6 tested by
    github.com/testcontainers/testcontainers-go/examples/k6.test imports
    github.com/testcontainers/testcontainers-go/modules/k6: module github.com/testcontainers/testcontainers-go@latest found (v0.24.1, replaced by ../..), but does not contain package github.com/testcontainers/testcontainers-go/modules/k6
mdelapenya commented 10 months ago

I think there is a bug in the example template, but it should work if you create a module instead of a example:

In the mean time, instead of creating an example, please try with a real module.

- go run . new example --name k6 --image "grafana/k6" --title k6
+ go run . new module --name k6 --image "grafana/k6" --title k6
mdelapenya commented 10 months ago

We saw that the docs are a bit misleading, as the first code snippet is for creating an example module (just copy&paste code, no public API) when it should be just the module.

pablochacin commented 10 months ago

Hi @mdelapenya thanks for the clarification. I tried that and it worked. :+1:

I think it would be worth providing more information about the reason for the failure in the command.