Go: x/playground: support running tests

Created on 30 Sep 2013  路  11Comments  路  Source: golang/go

It'd be useful if the playground could run tests -- more like `go test` instead of `go
run`.

This is possible now (http://play.golang.org/p/K0gFil6jFC), but it's clumsy and
non-obvious.

Just to get the conversation started, here's a concrete proposal:

* Tests and examples are supported, but not benchmarks. (Benchmarks are going to
unreliable anyway, right?)
* If main is not present and there is an appropriate test function (or example function
with output), then the playground executes in test mode. Otherwise, behavior is
unchanged.
* "Test mode" is equivalent to `go test -v`.
* Add text to the About page explaining how to use playground for tests.
FrozenDueToAge help wanted

Most helpful comment

If we're to do this, we could be more general: extend the API to accept multiple input files, which are built together as a package. We could even permit building a tree of packages. Then we could provide execution options (run, test, bench, others?) to run against those packages. I think the implementation of this would be pretty straightforward. The hardest part would be designing a nice JSON API for the requests.

All 11 comments

Comment 1:

_Owner changed to @adg._

_Status changed to Accepted._

Comment 2:

_Labels changed: added go1.3maybe._

Comment 3:

_Labels changed: added release-none, removed go1.3maybe._

Comment 4:

_Labels changed: added repo-main._

Comment 5:

_Labels changed: added repo-playground, removed priority-triage, repo-main._

_Owner changed to @josharian._

_Status changed to Started._

Comment 6:

CL https://golang.org/cl/102420043 mentions this issue.

@adg any new thoughts about this? I could bring that old CL back to life if you were interested.

If we're to do this, we could be more general: extend the API to accept multiple input files, which are built together as a package. We could even permit building a tree of packages. Then we could provide execution options (run, test, bench, others?) to run against those packages. I think the implementation of this would be pretty straightforward. The hardest part would be designing a nice JSON API for the requests.

@adg, we could even introduce magic comments as a way to mark new files, which is common in people's bug reports anyway.

But I see no reason to tie that feature to this. They seem separable.

Change https://golang.org/cl/98155 mentions this issue: playground: support running tests

I have committed a change based mostly on the way @josharian did it 3.5 years ago. I was going different direction at first but ended with something very close to that old change by Josh. At worst it was very good learning experience for me. I would be glad of somebody gave it a proper review.

Was this page helpful?
0 / 5 - 0 ratings