+
Skip to content

Fix an issue on Intel Mac, where it fails from the wrong build agent #179

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

Merged
merged 3 commits into from
Aug 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/test/suite/utils/areTerminalsClosed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const baseTerminal = {
};

suite('areTerminalsClosed', () => {
test('Only one is closed', () => {
test('only one is closed', () => {
assert.strictEqual(
false,
areTerminalsClosed(
Expand All @@ -30,7 +30,7 @@ suite('areTerminalsClosed', () => {
);
});

test('All are closed', () => {
test('all are closed', () => {
assert.strictEqual(
true,
areTerminalsClosed(
Expand All @@ -40,7 +40,7 @@ suite('areTerminalsClosed', () => {
);
});

test('One undefined, one closed', () => {
test('one undefined, one closed', () => {
assert.strictEqual(
true,
areTerminalsClosed(
Expand Down
2 changes: 1 addition & 1 deletion src/test/suite/utils/cleanUpCommittedImages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mocha.afterEach(() => {
});

suite('cleanUpCommittedImages', () => {
test('No error', () => {
test('no error', () => {
sinon.mock(cp).expects('spawnSync').twice();
cleanUpCommittedImages('local-ci-lint');
});
Expand Down
4 changes: 2 additions & 2 deletions src/test/suite/utils/disposeTerminalsForJob.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mocha.afterEach(() => {
});

suite('disposeTerminalsForJob', () => {
test('Terminal is not disposed', async () => {
test('terminal is not disposed', async () => {
const jobName = 'build';

sinon.stub(vscode, 'window').value({
Expand All @@ -23,7 +23,7 @@ suite('disposeTerminalsForJob', () => {
disposeTerminalsForJob(jobName);
});

test('Terminal is disposed', async () => {
test('terminal is disposed', async () => {
const jobName = 'build';

sinon.stub(vscode, 'window').value({
Expand Down
2 changes: 1 addition & 1 deletion src/test/suite/utils/getAllJobs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import getAllJobs from '../../../utils/getJobs';
import { getTestFilePath } from '../../helpers';

suite('getAllJobs', () => {
test('Jobs from fixture', () => {
test('jobs from fixture', () => {
assert.strictEqual(
getAllJobs(
getConfig(
Expand Down
4 changes: 2 additions & 2 deletions src/test/suite/utils/getAttachWorkspaceCommand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { normalize } from '../../helpers';
import getAttachWorkspaceCommand from '../../../utils/getAttachWorkspaceCommand';

suite('getAttachWorkspaceCommand', () => {
test('No attach_workspace', () => {
test('no attach_workspace', () => {
assert.strictEqual(getAttachWorkspaceCommand({}), '');
});

test('With attach_workspace', () => {
test('with attach_workspace', () => {
assert.strictEqual(
normalize(
getAttachWorkspaceCommand({ attach_workspace: { at: '/foo/baz' } })
Expand Down
4 changes: 2 additions & 2 deletions src/test/suite/utils/getCheckoutJobs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ mocha.afterEach(() => {
});

suite('getCheckoutJobs', () => {
test('No config file', () => {
test('no config file', () => {
assert.deepStrictEqual(getCheckoutJobs(undefined), []);
});

test('No checkout job', () => {
test('no checkout job', () => {
sinon.mock(fs).expects('existsSync').once().returns(true);
sinon.mock(fs).expects('readFileSync').once().returns('');

Expand Down
4 changes: 2 additions & 2 deletions src/test/suite/utils/getConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ mocha.afterEach(() => {
});

suite('getConfig', () => {
test('No config', () => {
test('no config', () => {
sinon.mock(fs).expects('existsSync').once().returns(false);
sinon.mock(fs).expects('readFileSync').never();
assert.strictEqual(getConfig(''), undefined);
});

test('With config', () => {
test('with config', () => {
const configFile = {
jobs: { test: { docker: [{ image: 'cimg/node:16.8.0-browsers' }] } },
};
Expand Down
4 changes: 2 additions & 2 deletions src/test/suite/utils/getDockerError.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ mocha.afterEach(() => {
});

suite('getDockerError', () => {
test('No error', () => {
test('no error', () => {
sinon.mock(cp).expects('execSync').once();
assert.strictEqual(getDockerError(), '');
});

test('With error', () => {
test('with error', () => {
const message = 'Cannot connect to the Docker daemon';
sinon.mock(cp).expects('execSync').once().throws({ message });

Expand Down
4 changes: 2 additions & 2 deletions src/test/suite/utils/getDynamicConfigFilePath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import * as assert from 'assert';
import getDynamicConfigPath from '../../../utils/getDynamicConfigPath';

suite('getDynamicConfigFilePath', () => {
test('With empty string argument', () => {
test('with empty string argument', () => {
assert.strictEqual(
getDynamicConfigPath(''),
'/tmp/local-ci/unknown/volume/dynamic-config.yml'
);
});

test('With path as argument', () => {
test('with path as argument', () => {
assert.strictEqual(
getDynamicConfigPath('/home/foo/baz/.circleci/config.yml'),
'/tmp/local-ci/baz/volume/dynamic-config.yml'
Expand Down
4 changes: 2 additions & 2 deletions src/test/suite/utils/getFirstWorkspaceRootPath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ mocha.afterEach(() => {
});

suite('getFirstWorkspaceRootPath', () => {
test('With no workspaceFolders', () => {
test('with no workspaceFolders', () => {
sinon.stub(vscode, 'workspace').value({});
assert.strictEqual(getFirstWorkspaceRootPath(), '');
});

test('With workspaceFolders', () => {
test('Wwith workspaceFolders', () => {
const path = 'example';
sinon.stub(vscode, 'workspace').value({
workspaceFolders: [
Expand Down
6 changes: 3 additions & 3 deletions src/test/suite/utils/getImageFromJob.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import * as assert from 'assert';
import getImageFromJob from '../../../utils/getImageFromJob';

suite('getImageFromJob', () => {
test('No docker value', () => {
test('no docker value', () => {
assert.deepStrictEqual(
getImageFromJob({ working_directory: 'foo/baz' }),
''
);
});

test('Empty docker array', () => {
test('empty docker array', () => {
assert.deepStrictEqual(getImageFromJob({ docker: [] }), '');
});

test('With docker image', () => {
test('with docker image', () => {
assert.deepStrictEqual(
getImageFromJob({ docker: [{ image: 'foo-image' }] }),
'foo-image'
Expand Down
6 changes: 3 additions & 3 deletions src/test/suite/utils/getJobs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import getJobs from '../../../utils/getJobs';
import { getTestFilePath } from '../../helpers';

suite('getJobs', () => {
test('Single job', () => {
test('single job', () => {
assert.strictEqual(
getJobs({
jobs: {},
Expand All @@ -19,7 +19,7 @@ suite('getJobs', () => {
);
});

test('Multiple jobs', () => {
test('multiple jobs', () => {
assert.strictEqual(
getJobs({
jobs: { lint: {}, test: {}, deploy: {} },
Expand All @@ -39,7 +39,7 @@ suite('getJobs', () => {
);
});

test('Multiple jobs from fixture', () => {
test('multiple jobs from fixture', () => {
assert.strictEqual(
getJobs(
getConfig(
Expand Down
4 changes: 2 additions & 2 deletions src/test/suite/utils/getLogFilePath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import * as assert from 'assert';
import getLogFilePath from '../../../utils/getLogFilePath';

suite('getLogFilePath', () => {
test('Empty path to config file', () => {
test('empty path to config file', () => {
assert.ok(
getLogFilePath('', 'test-lint').startsWith(
'/tmp/local-ci/logs/test-lint/'
)
);
});

test('With path to config file', () => {
test('with path to config file', () => {
assert.ok(
getLogFilePath('your-repo/.circleci/config.yml', 'test-lint').startsWith(
'/tmp/local-ci/your-repo/logs/test-lint/'
Expand Down
2 changes: 1 addition & 1 deletion src/test/suite/utils/getLogFilesDirectory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as assert from 'assert';
import getLogFilesDirectory from '../../../utils/getLogFilesDirectory';

suite('getLogFilePath', () => {
test('With path to config file', () => {
test('with path to config file', () => {
assert.strictEqual(
getLogFilesDirectory('baz-repo/.circleci/config.yml', 'test-lint'),
'/tmp/local-ci/baz-repo/logs/test-lint'
Expand Down
6 changes: 3 additions & 3 deletions src/test/suite/utils/getPath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ mocha.afterEach(() => {
});

suite('getPath', () => {
test('On Linux', () => {
test('on Linux', () => {
sinon.mock(os).expects('type').once().returns('Linux');
sinon.stub(process, 'env').value({ PATH: '' });
assert.strictEqual(getPath(), '');
});

test('On Mac without the bin path', () => {
test('on Mac without the bin path', () => {
sinon.mock(os).expects('type').once().returns('Darwin');
sinon.stub(process, 'env').value({ PATH: 'Users/Foo/' });
assert.strictEqual(getPath(), 'Users/Foo/:/usr/local/bin');
});

test('On Mac with the bin path', () => {
test('on Mac with the bin path', () => {
sinon.mock(os).expects('type').once().returns('Darwin');
sinon.stub(process, 'env').value({ PATH: 'Users/Foo/:/usr/local/bin' });
assert.strictEqual(getPath(), 'Users/Foo/:/usr/local/bin');
Expand Down
2 changes: 1 addition & 1 deletion src/test/suite/utils/getSaveCacheSteps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import getConfigFromPath from '../../../utils/getConfigFromPath';
import getSaveCacheSteps from '../../../utils/getSaveCacheSteps';

suite('getSaveCacheSteps', () => {
test('With 2 save_cache values', () => {
test('with 2 save_cache values', () => {
assert.deepStrictEqual(
getSaveCacheSteps(
getConfigFromPath(getTestFilePath('fixture', 'with-cache.yml'))
Expand Down
6 changes: 3 additions & 3 deletions src/test/suite/utils/getSpawnOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mocha.afterEach(() => {
});

suite('getSpawnOptions', () => {
test('Has working directory', () => {
test('has working directory', () => {
sinon.mock(os).expects('platform').once().returns('darwin');
const path = 'example';
sinon.stub(vscode, 'workspace').value({
Expand All @@ -23,12 +23,12 @@ suite('getSpawnOptions', () => {
assert.strictEqual(getSpawnOptions().cwd, path);
});

test('Has bin directory', () => {
test('has bin directory', () => {
sinon.mock(os).expects('platform').once().returns('darwin');
assert.ok(getSpawnOptions().env.PATH.includes('/usr/local/bin'));
});

test('With cwd argument', () => {
test('with cwd argument', () => {
assert.strictEqual(getSpawnOptions('/foo/baz').cwd, '/foo/baz');
});
});
4 changes: 2 additions & 2 deletions src/test/suite/utils/isDockerRunning.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mocha.afterEach(() => {
});

suite('isDockerRunning', () => {
test('Is not running', () => {
test('is not running', () => {
sinon
.mock(cp)
.expects('execSync')
Expand All @@ -18,7 +18,7 @@ suite('isDockerRunning', () => {
assert.strictEqual(isDockerRunning(), false);
});

test('Is running', () => {
test('is running', () => {
sinon.mock(cp).expects('execSync').once();
assert.strictEqual(isDockerRunning(), true);
});
Expand Down
12 changes: 6 additions & 6 deletions src/test/suite/utils/sanitizeLicenseKey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,39 @@ import * as assert from 'assert';
import sanitizeLicenseKey from '../../../utils/sanitizeLicenseKey';

suite('sanitizeLicenseKey', () => {
test('Empty', async () => {
test('empty', async () => {
assert.strictEqual(sanitizeLicenseKey(''), '');
});

test('Only letters and numbers', () => {
test('only letters and numbers', () => {
assert.strictEqual(
sanitizeLicenseKey('1b2e78c9b0ea4ee888fed8a66d553dfc'),
'1b2e78c9b0ea4ee888fed8a66d553dfc'
);
});

test('With dashes', () => {
test('with dashes', () => {
assert.strictEqual(
sanitizeLicenseKey('e9bd961ce2d04c0ab2f5b3212127b01a'),
'e9bd961ce2d04c0ab2f5b3212127b01a'
);
});

test('With tag', () => {
test('with tag', () => {
assert.strictEqual(
sanitizeLicenseKey('ccae17<script>alert("dothis")</script>632f10407'),
'ccae17scriptalertdothisscript632f10407'
);
});

test('With invalid characters', () => {
test('with invalid characters', () => {
assert.strictEqual(
sanitizeLicenseKey('66e56321$(*&@!2b0b4~**))5b1af385e10ff9049e8'),
'66e563212b0b45b1af385e10ff9049e8'
);
});

test('With whitespace', () => {
test('with whitespace', () => {
assert.strictEqual(
sanitizeLicenseKey(' f5d5e 32c017b4e9 8a066d8c22e6f1ea1 '),
'f5d5e32c017b4e98a066d8c22e6f1ea1'
Expand Down
42 changes: 42 additions & 0 deletions src/test/suite/utils/setBuildAgentSettings.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import * as assert from 'assert';
import * as cp from 'child_process';
import * as mocha from 'mocha';
import * as os from 'os';
import * as sinon from 'sinon';
import setBuildAgentSettings from '../../../utils/setBuildAgentSettings';

mocha.afterEach(() => {
sinon.restore();
});

suite('setBuildAgentSettings', () => {
test('should not set the settings on a Linux machine', () => {
const spawnSpy = sinon.spy();
sinon.stub(os, 'type').value(() => 'Intel');
sinon.stub(os, 'arch').value(() => 'x64');
sinon.stub(cp, 'spawn').value(spawnSpy);

setBuildAgentSettings();
assert.equal(spawnSpy.called, false);
});

test('should not set the settings on an M1 Mac machine', () => {
const spawnSpy = sinon.spy();
sinon.stub(os, 'type').value(() => 'Darwin');
sinon.stub(os, 'arch').value(() => 'arm64');
sinon.stub(cp, 'spawn').value(spawnSpy);

setBuildAgentSettings();
assert.equal(spawnSpy.called, false);
});

test('should set the settings on an Intel Mac machine', () => {
const spawnSpy = sinon.spy();
sinon.stub(os, 'type').value(() => 'Darwin');
sinon.stub(os, 'arch').value(() => 'x64');
sinon.stub(cp, 'spawn').value(spawnSpy);

setBuildAgentSettings();
assert.equal(spawnSpy.called, true);
});
});
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载