run cli, static, and dynamic tests on CI, add tests for cache busting

This commit is contained in:
Amila Welihinda 2019-01-18 15:23:36 -08:00
parent db0a79dd49
commit c5934e338c
5 changed files with 109 additions and 7 deletions

18
.editorconfig Normal file
View File

@ -0,0 +1,18 @@
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.rs]
indent_size = 4
[*.toml]
indent_size = 4
[*.md]
trim_trailing_whitespace = false

View File

@ -31,6 +31,9 @@ before_install:
- nvm use ${TRAVIS_NODE_VERSION}
- node -v
- npm -v
- npm install --prefix cli
- npm install --prefix test/cli
- npm install --prefix test/dynamic
addons:
apt:
@ -39,8 +42,12 @@ addons:
packages:
- g++-4.8
script: |
cargo test --release -- --nocapture
script:
- cargo test --release -- --nocapture
- npm test --prefix cli
- npm test --prefix test/cli
- npm test --prefix test/dynamic
- cargo test --manifest-path=test/static/Cargo.toml
jobs:
include:

View File

@ -77,9 +77,9 @@
"dev": true
},
"@types/node": {
"version": "8.10.18",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.18.tgz",
"integrity": "sha512-WoepSz+wJlU5Bjq5oK6cO1oXe2FgPcjMtQPgKPS8fVaTAD0lxkScMCCbMimdkVCsykqaA4lvHWz3cmj28yimhA==",
"version": "8.10.39",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.39.tgz",
"integrity": "sha512-rE7fktr02J8ybFf6eysife+WF+L4sAHWzw09DgdCebEu+qDwMvv4zl6Bc+825ttGZP73kCKxa3dhJOoGJ8+5mA==",
"dev": true
},
"@types/rimraf": {

View File

@ -34,7 +34,7 @@
"@types/inquirer": "0.0.35",
"@types/mkdirp": "^0.5.1",
"@types/mocha": "^5.2.0",
"@types/node": "^8.0.28",
"@types/node": "^8.10.39",
"@types/rimraf": "^2.0.2",
"@types/rsvp": "^3.3.1",
"@types/semver": "^5.3.31",
@ -49,7 +49,7 @@
"typescript": "^2.2.2"
},
"scripts": {
"test": "mocha lib/acceptance",
"test": "npm run transpile && mocha lib/**/*.js",
"transpile": "tsc"
}
}

View File

@ -0,0 +1,77 @@
import { expect } from 'chai';
import BuildSettings from '../../../../cli/lib/build-settings';
describe('build settings', () => {
const env = {
npm_config_target: null,
npm_config_arch: null,
npm_config_target_arch: null,
npm_config_disturl: null,
npm_config_runtime: null,
npm_config_build_from_source: null,
npm_config_devdir: null
};
describe('match', () => {
it('should not match build settings if nodeVersion is different', () => {
const buildSettings = new BuildSettings('rustc-version', 'v11.8.0', env);
const otherSettings = new BuildSettings('rustc-version', 'v10.8.0', env);
expect(buildSettings.match(otherSettings)).equal(false);
});
it('should match build settings if nodeVersion is same', () => {
const buildSettings = new BuildSettings('rustc-version', 'v11.8.0', env);
const otherSettings = new BuildSettings('rustc-version', 'v11.8.0', env);
expect(buildSettings.match(otherSettings)).equal(true);
});
it('should not match against current build settings when nodeVersion is null', () => {
const buildSettings = BuildSettings.current();
const otherSettings = new BuildSettings('rustc-version', null, env);
expect(buildSettings.match(otherSettings)).equal(false);
})
});
describe('serialize', () => {
it('should work when nodeVersion is null', () => {
})
})
describe('current build settings', () => {
it('should return values of expected types', () => {
// @ts-ignore
const { nodeVersion, env, rustc } = BuildSettings.current();
expect(nodeVersion).to.be.a('string');
expect(rustc).to.be.a('string');
expect(env).to.deep.equal({
npm_config_target: process.env.npm_config_target || null,
npm_config_arch: process.env.npm_config_arch || null,
npm_config_target_arch: process.env.npm_config_target_arch || null,
npm_config_disturl: process.env.npm_config_disturl || null,
npm_config_runtime: process.env.npm_config_runtime || null,
npm_config_build_from_source: process.env.npm_config_build_from_source || null,
npm_config_devdir: process.env.npm_config_devdir || null
});
});
});
describe('get node version', () => {
it('should return a string', () => {
expect(BuildSettings.getNodeVersion()).to.be.a('string');
});
});
describe('serialize and deserialize', () => {
it('should be equal when nodeVersion is null', () => {
expect(JSON.stringify(BuildSettings.fromJSON({
rustc: 'rustc-version',
env
}))).equal(JSON.stringify(new BuildSettings(
'rustc-version',
null,
env
).toJSON()));
});
})
});