Skip to content

Commit

Permalink
Fix tests for Windows and add Azure Pipelines for cross platform CI (#…
Browse files Browse the repository at this point in the history
…5410)

* Add azure pipelines

* Add gitattributes

* Updating tests to work on Windows or Unix

* Lint

* Cleaning up

* Fixing names

* Clean up naming

* try to consolidate images

* Clean up

* Add back txt to gitattributes
  • Loading branch information
Danny McCormick authored and j-f1 committed Nov 14, 2018
1 parent 57b057c commit 18b03a3
Show file tree
Hide file tree
Showing 33 changed files with 403 additions and 137 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
@@ -0,0 +1,4 @@
# Make sure baseline files have consistent line endings
*.txt text eol=lf
*.snap text eol=lf
*.debug-check text eol=lf
19 changes: 19 additions & 0 deletions azure-pipelines-tests.yml
@@ -0,0 +1,19 @@
steps:
- task: NodeTool@0
inputs:
versionSpec: '$(node_version)'
displayName: 'Install Node.js'

- script: npm install -g yarn
displayName: 'Get yarn'

- script: yarn install
displayName: 'yarn install'

- script: yarn test
displayName: 'Test'

- task: PublishTestResults@2
inputs:
testResultsFiles: '**/junit.xml'
condition: succeededOrFailed()
109 changes: 109 additions & 0 deletions azure-pipelines.yml
@@ -0,0 +1,109 @@
trigger:
- master
- releases/*

jobs:

# Build and test on Windows
- job: Test_Windows
displayName: Tests on Windows Node8
pool:
vmImage: vs2017-win2016
variables:
node_version: 8.x
report_summaries: true
steps:
- template: azure-pipelines-tests.yml

# Build and test on macOS
- job: Test_macOS
displayName: Tests on macOS Node8
pool:
vmImage: macos-10.13
variables:
node_version: 8.x
report_summaries: true
steps:
- template: azure-pipelines-tests.yml

# Test on Linux
- job: Test_Linux
displayName: Run tests
pool:
vmImage: 'Ubuntu 16.04'
strategy:
matrix:
Node8:
node_version: '8.x'
Node11:
node_version: '11.x'
variables:
report_summaries: true
steps:
- template: azure-pipelines-tests.yml

# Test production bundle on Linux using Node 4
- job: Prod_Linux
displayName: Test production bundle on Linux
pool:
vmImage: 'Ubuntu 16.04'
strategy:
matrix:
Node4:
node_version: '4.x'
Node9:
node_version: '9.x'
steps:
- task: NodeTool@0
inputs:
versionSpec: '11.x'
displayName: 'Install Node.js'

- script: npm install -g yarn
displayName: 'Get yarn'

- script: yarn install
displayName: 'yarn install'

- script: yarn check-deps
displayName: 'Check dependencies'

- script: yarn build
displayName: 'Build'

- task: NodeTool@0
inputs:
versionSpec: '$(node_version)'
displayName: 'Use Node.js $(node_version)'

- script: npm install -g yarn@1.5
displayName: 'Get yarn compatible with node 4'
condition: eq(variables['node_version'], '4.x')

- script: node ./scripts/test-dist.js
displayName: 'Test'

- task: PublishTestResults@2
inputs:
testResultsFiles: '**/junit.xml'
condition: and(variables['report_summaries'], succeededOrFailed())

# Lint checks on Linux
- job: Lint_linux
displayName: Lint (Linux)
pool:
vmImage: 'Ubuntu 16.04'
steps:
- task: NodeTool@0
inputs:
versionSpec: '8.x'
displayName: 'Install Node.js'

- script: yarn install
displayName: 'yarn install'

- script: yarn lint
displayName: 'Lint code'

- script: yarn lint-docs
displayName: 'Lint docs'
10 changes: 7 additions & 3 deletions jest.config.js
Expand Up @@ -17,9 +17,13 @@ module.exports = {
"jest-snapshot-serializer-ansi"
],
testRegex: "jsfmt\\.spec\\.js$|__tests__/.*\\.js$",
testPathIgnorePatterns: ["tests/new_react", "tests/more_react"].concat(
isOldNode ? requiresPrettierInternals : []
),
testPathIgnorePatterns: ["tests/new_react", "tests/more_react"]
.concat(isOldNode ? requiresPrettierInternals : [])
.concat(
require("os").EOL == "\n"
? ["tests_integration/__tests__/eol-crlf.js"]
: ["tests_integration/__tests__/eol-lf.js"]
),
collectCoverage: ENABLE_COVERAGE,
collectCoverageFrom: ["src/**/*.js", "index.js", "!<rootDir>/node_modules/"],
coveragePathIgnorePatterns: [
Expand Down
35 changes: 0 additions & 35 deletions tests/windows/__snapshots__/jsfmt.spec.js.snap

This file was deleted.

1 change: 0 additions & 1 deletion tests/windows/jsfmt.spec.js

This file was deleted.

5 changes: 0 additions & 5 deletions tests/windows/line-ending.js

This file was deleted.

7 changes: 0 additions & 7 deletions tests/windows/template.js

This file was deleted.

Expand Up @@ -3,17 +3,7 @@
exports[`CLI overrides take precedence (stderr) 1`] = `""`;

exports[`CLI overrides take precedence (stdout) 1`] = `
"function f() {/*CR*/ console.log(/*CR*/ \\"line endings should be CR\\"/*CR*/ )/*CR*/}/*CR*/function f() {/*CR*/
console.log(/*CR*/
\\"line endings should be CRLF\\"/*CR*/
)/*CR*/
}/*CR*/
function f() {
console.log(
\\"line endings should be LF\\"
)
}
function f() {
"function f() {
console.log(
\\"should have tab width 8\\"
)
Expand Down Expand Up @@ -50,6 +40,8 @@ function js() {
\\"use strict\\";
module.exports = {
endOfLine:
\\"lf\\",
tabWidth: 8
};
function noConfigJs() {
Expand Down Expand Up @@ -124,13 +116,7 @@ exports[`resolves configuration file with --find-config-path file (write) 1`] =
exports[`resolves configuration from external files (stderr) 1`] = `""`;

exports[`resolves configuration from external files (stdout) 1`] = `
"function f() {/*CR*/ console.log(\\"line endings should be CR\\")/*CR*/}/*CR*/function f() {/*CR*/
console.log(\\"line endings should be CRLF\\")/*CR*/
}/*CR*/
function f() {
console.log(\\"line endings should be LF\\")
}
function f() {
"function f() {
console.log(\\"should have tab width 8\\")
}
function f() {
Expand All @@ -153,6 +139,7 @@ function js() {
\\"use strict\\";
module.exports = {
endOfLine: \\"lf\\",
tabWidth: 8
};
function noConfigJs() {
Expand Down
62 changes: 62 additions & 0 deletions tests_integration/__tests__/__snapshots__/eol-crlf.js.snap
@@ -0,0 +1,62 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Has correct default Windows line endings (stderr) 1`] = `""`;

exports[`Has correct default Windows line endings (stdout) 1`] = `
"function f() {
console.log(\\"should have tab width 8\\")
}
function f() {
console.log(\\"should have space width 2\\")
}
function f() {
console.log(\\"should have space width 8\\")
}
function f() {
console.log(
\\"should have space width 2 despite ../.editorconfig specifying 8, because ./.hg is present\\"
)
}
console.log(\\"jest/__best-tests__/file.js should have semi\\");/*CR*/
console.log(\\"jest/Component.js should not have semi\\")/*CR*/
console.log(\\"jest/Component.test.js should have semi\\");/*CR*/
function js() {
console.log(\\"js/file.js should have tab width 8 (1 if CLI)\\");
}
\\"use strict\\";
module.exports = {
endOfLine: \\"lf\\",
tabWidth: 8
};
function noConfigJs() {
console.log(\\"no-config/file.js should have no semicolons\\")
}
function packageJs() {/*CR*/
console.log(\\"package/file.js should have tab width 3\\");/*CR*/
}/*CR*/
function rcJson() {/*CR*/
console.log.apply(null, [/*CR*/
'rc-json/file.js',/*CR*/
'should have trailing comma',/*CR*/
'and single quotes',/*CR*/
]);/*CR*/
}/*CR*/
function rcToml() {/*CR*/
console.log.apply(null, [/*CR*/
'rc-toml/file.js',/*CR*/
'should have trailing comma',/*CR*/
'and single quotes',/*CR*/
]);/*CR*/
}/*CR*/
function rcYaml() {/*CR*/
console.log.apply(null, [/*CR*/
'rc-yaml/file.js',/*CR*/
'should have trailing comma',/*CR*/
'and single quotes',/*CR*/
]);/*CR*/
}/*CR*/
"
`;

exports[`Has correct default Windows line endings (write) 1`] = `Array []`;
62 changes: 62 additions & 0 deletions tests_integration/__tests__/__snapshots__/eol-lf.js.snap
@@ -0,0 +1,62 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Has correct default Unix line endings (stderr) 1`] = `""`;

exports[`Has correct default Unix line endings (stdout) 1`] = `
"function f() {
console.log(\\"should have tab width 8\\")
}
function f() {
console.log(\\"should have space width 2\\")
}
function f() {
console.log(\\"should have space width 8\\")
}
function f() {
console.log(
\\"should have space width 2 despite ../.editorconfig specifying 8, because ./.hg is present\\"
)
}
console.log(\\"jest/__best-tests__/file.js should have semi\\");
console.log(\\"jest/Component.js should not have semi\\")
console.log(\\"jest/Component.test.js should have semi\\");
function js() {
console.log(\\"js/file.js should have tab width 8 (1 if CLI)\\");
}
\\"use strict\\";
module.exports = {
endOfLine: \\"lf\\",
tabWidth: 8
};
function noConfigJs() {
console.log(\\"no-config/file.js should have no semicolons\\")
}
function packageJs() {
console.log(\\"package/file.js should have tab width 3\\");
}
function rcJson() {
console.log.apply(null, [
'rc-json/file.js',
'should have trailing comma',
'and single quotes',
]);
}
function rcToml() {
console.log.apply(null, [
'rc-toml/file.js',
'should have trailing comma',
'and single quotes',
]);
}
function rcYaml() {
console.log.apply(null, [
'rc-yaml/file.js',
'should have trailing comma',
'and single quotes',
]);
}
"
`;

exports[`Has correct default Unix line endings (write) 1`] = `Array []`;

0 comments on commit 18b03a3

Please sign in to comment.