Always use host Go installation as GOROOT_BOOTSTRAP

This commit is contained in:
Ivan Trubach 2019-12-19 00:07:28 +03:00
parent b6eca21110
commit 8d6c88b10d
2 changed files with 19 additions and 9 deletions

View file

@ -24,6 +24,20 @@ const cleanup = async () => {
beforeAll(cleanup, 100000); beforeAll(cleanup, 100000);
afterAll(cleanup, 100000); afterAll(cleanup, 100000);
let bootstrapCgo: string = '';
let bootstrapGo: string = '';
beforeAll(async () => {
bootstrapGo = await io.which('go', false);
if (!bootstrapGo) {
return;
}
bootstrapCgo = await executil.goEnv('CGO_ENABLED', bootstrapGo);
// Override the value for acquireGo, because running getGo tests
// exports different GOROOT each time.
const bootstrapGoroot = await executil.goEnv('GOROOT', bootstrapGo);
process.env['GOROOT_BOOTSTRAP'] = bootstrapGoroot
})
const describeTable = describe.each([ const describeTable = describe.each([
['tip', '+60f14fd', 'go1.13beta1', '0.0.0-devel.60f14fddfee107dedd76c0be6b422a3d8ccc841a'], ['tip', '+60f14fd', 'go1.13beta1', '0.0.0-devel.60f14fddfee107dedd76c0be6b422a3d8ccc841a'],
['tip', '+a5bfd9d', 'go1.14beta1', '0.0.0-devel.a5bfd9da1d1b24f326399b6b75558ded14514f23'], ['tip', '+a5bfd9d', 'go1.14beta1', '0.0.0-devel.a5bfd9da1d1b24f326399b6b75558ded14514f23'],
@ -39,7 +53,6 @@ describeTable('Go %s (%s)', (version: string, goVersion: string, gitRef: string,
const goRoot = path.join(toolDir, cacheDir, normVersion, osarch); const goRoot = path.join(toolDir, cacheDir, normVersion, osarch);
const goTool = path.join(goRoot, 'bin', goExe); const goTool = path.join(goRoot, 'bin', goExe);
let cgo: string = '';
if (!gotip) { if (!gotip) {
beforeAll(() => { beforeAll(() => {
nock('https://golang.org') nock('https://golang.org')
@ -51,15 +64,11 @@ describeTable('Go %s (%s)', (version: string, goVersion: string, gitRef: string,
nock.cleanAll(); nock.cleanAll();
nock.enableNetConnect(); nock.enableNetConnect();
}); });
} else {
beforeAll(async () => {
cgo = await executil.goEnv('CGO_ENABLED');
});
} }
const timeout = gotip ? 300000 : 100000; const timeout = gotip ? 300000 : 100000;
test('installation', async () => { test('installation', async () => {
const promise = installer.getGo(version, gitRef); const promise = installer.getGo(version, gitRef, bootstrapGo);
await expect(promise).resolves.toBeUndefined(); await expect(promise).resolves.toBeUndefined();
}, timeout); }, timeout);
@ -95,7 +104,7 @@ describeTable('Go %s (%s)', (version: string, goVersion: string, gitRef: string,
} }
test('CGO_ENABLED check', async () => { test('CGO_ENABLED check', async () => {
const promise = executil.goEnv('CGO_ENABLED', goTool); const promise = executil.goEnv('CGO_ENABLED', goTool);
await expect(promise).resolves.toBe(cgo); await expect(promise).resolves.toBe(bootstrapCgo);
}); });
}); });

View file

@ -112,8 +112,9 @@ async function acquireGo(version: string, gotipRef: string, bootstrapGo: string)
// The make.bat script on Windows is not smart enough // The make.bat script on Windows is not smart enough
// to figure out the path to bootstrap Go toolchain. // to figure out the path to bootstrap Go toolchain.
// Make script will show descriptive error message even // We have to spoonfeed it with GOROOT_BOOTSTRAP value.
// if we dont find Go installation on the host. // At least make script will show descriptive error message
// even if we dont find Go installation on the host.
let bootstrap: string = ''; let bootstrap: string = '';
if (bootstrapGo) { if (bootstrapGo) {
bootstrap = await executil.goEnv('GOROOT', bootstrapGo); bootstrap = await executil.goEnv('GOROOT', bootstrapGo);