New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gopherjs test ./with/relative/path
failing
#302
Comments
Also, to correct your terminology, |
gopherjs test /with/explicit/path
failinggopherjs test ./with/relative/path
failing
Thanks for the explanation. I hadn't thought to try |
When writing Go code that is something more than just a very short snippet, it helps to organize code as a Go package. It may contain 1 or more .go files in a directory. `go build` is primarily used with Go packages, as in `go build import/path`. We should suggest the same use of `gopherjs build`. That will make it easier for users to get started and grow their code, because they'll be able to split into multiple .go files without having to update their build step.
I'm going to reopen and resolve this issue. /cc @slimsag Sure, there's always the workaround of doing:
But that's not nice and not friendly to new people who are used to being able to do things like I've prototyped a fix. It's not the most trivial fix, but still very manageable. Will send a PR soon. |
Previously, in build.Import, the srcDir argument to importWithSrcDir call was always empty string. Ideally, the Import method should have a srcDir parameter and pass it onwards. Then the caller (gopherjs tool, for example) can provide the working directory, if available. However, this is an exported method and changing its signature at this time is hard. Settle for an intermediate solution of try to figure out working directory inside Import, but continue to use empty string on failure (such as if in GOARCH=js mode, e.g., inside browser). This will be used by the gopherjs tool in the next commit to be able to resolve relative import paths, such as "." or "./foo/bar". The future plan is to bring all the "supported" code into gopherjs repo for convenience, mark the build API as unstable and make breaking API changes to bring it up to speed. Helps #302.
Use github.com/kisielk/gotool package to expand import path patterns in gopherjs build, gopherjs install, and gopherjs test commands. For example, "./..." can become {"."} or {"./foo", "./foo/bar", "./foo/baz"}. In gopherjs build command, only write output to working directory when a single package is specified (and that package is a command). This matches behavior of cmd/go tool. Fixes #302.
Previously, there was a special case to handle when user ran "gopherjs build", "gopherjs install", or "gopherjs test", without specifying any import paths via arguments. The code to handle this special case was complicated and poorly implemented, making assumptions about the first GOPATH workspace. The code can be completely removed now, because of support for relative import paths (#302) is resolved, and because gotool is guaranteed to map zero arguments to ".": If args is empty, a single element "." is returned. As a result, after this change, running "gopherjs build", "gopherjs install", "gopherjs test" is equivalent to running "gopherjs build .", "gopherjs install .", "gopherjs test ." respectively. There's less code to accomplish the same task.
Previously, in build.Import, the srcDir argument to importWithSrcDir call was always empty string. Ideally, the Import method should have a srcDir parameter and pass it onwards. Then the caller (gopherjs tool, for example) can provide the working directory, if available. However, this is an exported method and changing its signature at this time is hard. Settle for an intermediate solution of try to figure out working directory inside Import, but continue to use empty string on failure (such as if in GOARCH=js mode, e.g., inside browser). This will be used by the gopherjs tool in the next commit to be able to resolve relative import paths, such as "." or "./foo/bar". The future plan is to bring all the "supported" code into gopherjs repo for convenience, mark the build API as unstable and make breaking API changes to bring it up to speed. Helps #302.
Use github.com/kisielk/gotool package to expand import path patterns in gopherjs build, gopherjs install, and gopherjs test commands. For example, "./..." can become {"."} or {"./foo", "./foo/bar", "./foo/baz"}. In gopherjs build command, only write output to working directory when a single package is specified (and that package is a command). This matches behavior of cmd/go tool. Fixes #302.
Previously, there was a special case to handle when user ran "gopherjs build", "gopherjs install", or "gopherjs test", without specifying any import paths via arguments. The code to handle this special case was complicated and poorly implemented, making assumptions about the first GOPATH workspace. The code can be completely removed now, because of support for relative import paths (#302) is resolved, and because gotool is guaranteed to map zero arguments to ".": If args is empty, a single element "." is returned. As a result, after this change, running "gopherjs build", "gopherjs install", "gopherjs test" is equivalent to running "gopherjs build .", "gopherjs install .", "gopherjs test ." respectively. There's less code to accomplish the same task.
Previously, in build.Import, the srcDir argument to importWithSrcDir call was always empty string. Ideally, the Import method should have a srcDir parameter and pass it onwards. Then the caller (gopherjs tool, for example) can provide the working directory, if available. However, this is an exported method and changing its signature at this time is hard. Settle for an intermediate solution of try to figure out working directory inside Import, but continue to use empty string on failure (such as if in GOARCH=js mode, e.g., inside browser). This will be used by the gopherjs tool in the next commit to be able to resolve relative import paths, such as "." or "./foo/bar". The future plan is to bring all the "supported" code into gopherjs repo for convenience, mark the build API as unstable and make breaking API changes to bring it up to speed. Helps #302.
Use github.com/kisielk/gotool package to expand import path patterns in gopherjs build, gopherjs install, and gopherjs test commands. For example, "./..." can become {"."} or {"./foo", "./foo/bar", "./foo/baz"}. In gopherjs build command, only write output to working directory when a single package is specified (and that package is a command). This matches behavior of cmd/go tool. Fixes #302.
Previously, there was a special case to handle when user ran "gopherjs build", "gopherjs install", or "gopherjs test", without specifying any import paths via arguments. The code to handle this special case was complicated and poorly implemented, making assumptions about the first GOPATH workspace. The code can be completely removed now, because of support for relative import paths (#302) is resolved, and because gotool is guaranteed to map zero arguments to ".": If args is empty, a single element "." is returned. As a result, after this change, running "gopherjs build", "gopherjs install", "gopherjs test" is equivalent to running "gopherjs build .", "gopherjs install .", "gopherjs test ." respectively. There's less code to accomplish the same task.
The
gopherjs test
command fails when I specify an explicit path, while this works with standardgo test
. A simple proof:Similar tests with gopherjs in another directory:
Of course testing '.' isn't that useful, that just proved a simple test case. The same happens if I specify a full path:
And with gopherjs:
The text was updated successfully, but these errors were encountered: