Add JSON output of go env and some env as strings

Additional outputs are:
- GOPATH as `go-path` string
- GOMOD as `go-mod` string
- GOCACHE as `go-cache` string
- GOMODCACHE as `go-mod-cache` string
- `go env` as `go-env` JSON
This commit is contained in:
Luca Comellini 2023-02-15 16:16:09 -08:00
parent c4c1141886
commit 18710d65d4
No known key found for this signature in database
GPG key ID: 4850B36E838507C6
5 changed files with 112 additions and 12 deletions

View file

@ -143,6 +143,29 @@ describe('setup-go', () => {
expect(main.parseGoVersion(goVersionOutput)).toBe('1.16.6');
});
it('can read go env variables', async () => {
const goRoot = '/opt/hostedtoolcache/go/1.18.10/x64';
const goPath = '/home/runner/go';
const goModCache = '/home/runner/go/pkg/mod';
const goCache = '/home/runner/.cache/go-build';
const goVersion = 'go1.18.10';
const env = `
GOROOT="${goRoot}"
GOPATH="${goPath}"
GOMODCACHE="${goModCache}"
GOCACHE="${goCache}"
GOVERSION="${goVersion}"
`;
const json = JSON.parse(main.convertEnvStringToJson(env));
expect(json).toBeDefined();
expect(json['GOROOT']).toBe(goRoot);
expect(json['GOPATH']).toBe(goPath);
expect(json['GOMODCACHE']).toBe(goModCache);
expect(json['GOCACHE']).toBe(goCache);
expect(json['GOVERSION']).toBe(goVersion);
});
it('can find 1.9.7 from manifest on osx', async () => {
os.platform = 'darwin';
os.arch = 'x64';