From b6f6a66960597b1fcf475c0b2e89b6c8377eae96 Mon Sep 17 00:00:00 2001 From: Lars Trieloff Date: Thu, 25 Jul 2019 13:06:12 +0000 Subject: [PATCH 01/16] ci(windows): set up windows build for CI fixes #1098 --- .circleci/config.yml | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0d49f3db2..7f5a4dbf4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,23 +30,31 @@ commands: orbs: helix-smoke-tests: adobe/helix-smoke-tests@0.0.7 + win: circleci/windows-tools@0.0.4∂ jobs: - snyk: - executor: node8 - working_directory: ~/repo - + build_win: + parallelism: 4 + executor: win/preview-default steps: - - setup + - run: git config --global core.autocrlf false + - checkout + - run: choco install nodejs + - run: npm install + - run: mkdir junit - - run: - name: prepare test git user - command: git config --global user.email "you@example.com" && git config --global user.name "Your Name" + # test & get code coverage + - run: + name: Test and Code Coverage + command: npm run test-ci + environment: + MOCHA_FILE: junit/test-results.xml - # test & get code coverage - - run: - name: Running Tests with Snyk Agent - command: node snykmocha.js + - store_test_results: + path: junit + + - store_artifacts: + path: junit build: parallelism: 4 @@ -104,11 +112,12 @@ workflows: - publish-pre-release: requires: - build + - build_win filters: branches: only: master - build - - snyk + - build_win smoke: jobs: From 9107ec32618f2558405f30adf3875f6a125b8f19 Mon Sep 17 00:00:00 2001 From: Lars Trieloff Date: Thu, 25 Jul 2019 13:12:23 +0000 Subject: [PATCH 02/16] ci(windows): fix windows orb name --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7f5a4dbf4..99ec5f5a5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,7 +30,7 @@ commands: orbs: helix-smoke-tests: adobe/helix-smoke-tests@0.0.7 - win: circleci/windows-tools@0.0.4∂ + win: circleci/windows-tools@0.0.4 jobs: build_win: From 157ecd01d7db8fd0fd97b8c61637d0b127df23d9 Mon Sep 17 00:00:00 2001 From: Lars Trieloff Date: Thu, 25 Jul 2019 13:29:05 +0000 Subject: [PATCH 03/16] ci(windows): establish fallback for missing circleci executable --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f44a39a8b..c7cb7f55c 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "scripts": { "check": "npm run lint && npm run test", "test": "nyc --lines 90 --reporter=text --reporter=lcov mocha -t 5000", - "test-ci": "circleci tests glob 'test/test*.js' | circleci tests split --split-by=timings | xargs nyc --reporter=text --reporter=lcov mocha -R mocha-junit-reporter -t 5000 && codecov", + "test-ci": "circleci tests glob 'test/test*.js' | circleci tests split --split-by=timings || echo '' | xargs nyc --reporter=text --reporter=lcov mocha -R mocha-junit-reporter -t 5000 && codecov", "lint": "./node_modules/.bin/eslint .", "lint-ci": "circleci tests glob 'src/**/*.js' 'test/**/*.js' | circleci tests split | xargs eslint", "semantic-release": "semantic-release", From 506ccfd72f81cd08b9ff145a01743babc980f4e4 Mon Sep 17 00:00:00 2001 From: Lars Trieloff Date: Thu, 25 Jul 2019 13:34:57 +0000 Subject: [PATCH 04/16] ci(windows): introduce separate build target for windows Workaround for missing `circleci` executable: https://github.com/CircleCI-Public/windows-preview-docs/issues/12 --- .circleci/config.yml | 2 +- package.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 99ec5f5a5..6ee5ce5dc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -46,7 +46,7 @@ jobs: # test & get code coverage - run: name: Test and Code Coverage - command: npm run test-ci + command: npm run test-ci-win environment: MOCHA_FILE: junit/test-results.xml diff --git a/package.json b/package.json index c7cb7f55c..c26d8943d 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "scripts": { "check": "npm run lint && npm run test", "test": "nyc --lines 90 --reporter=text --reporter=lcov mocha -t 5000", - "test-ci": "circleci tests glob 'test/test*.js' | circleci tests split --split-by=timings || echo '' | xargs nyc --reporter=text --reporter=lcov mocha -R mocha-junit-reporter -t 5000 && codecov", + "test-ci": "circleci tests glob 'test/test*.js' | circleci tests split --split-by=timings | xargs nyc --reporter=text --reporter=lcov mocha -R mocha-junit-reporter -t 5000 && codecov", + "test-ci-win": "mocha -R mocha-junit-reporter -t 5000", "lint": "./node_modules/.bin/eslint .", "lint-ci": "circleci tests glob 'src/**/*.js' 'test/**/*.js' | circleci tests split | xargs eslint", "semantic-release": "semantic-release", From 41f6ff834ad3e563729df82ac6be8df3e345d3ea Mon Sep 17 00:00:00 2001 From: Lars Trieloff Date: Thu, 25 Jul 2019 13:55:15 +0000 Subject: [PATCH 05/16] ci(windows): use older node version --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6ee5ce5dc..8abcbb706 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,7 +39,7 @@ jobs: steps: - run: git config --global core.autocrlf false - checkout - - run: choco install nodejs + - run: choco install nodejs --version 10.16.0 - run: npm install - run: mkdir junit From 35638e0ff7306193e8f98e67fc671fc7536f7ead Mon Sep 17 00:00:00 2001 From: Lars Trieloff Date: Thu, 25 Jul 2019 14:00:18 +0000 Subject: [PATCH 06/16] ci(windows): reduce paralellism --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8abcbb706..16b2307c3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -34,7 +34,7 @@ orbs: jobs: build_win: - parallelism: 4 + parallelism: 1 executor: win/preview-default steps: - run: git config --global core.autocrlf false From 7ef7e3b2a366c8e189644035c97672acf0065421 Mon Sep 17 00:00:00 2001 From: Lars Trieloff Date: Thu, 25 Jul 2019 14:02:18 +0000 Subject: [PATCH 07/16] ci(windows): prepare git user --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 16b2307c3..339d3609a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -38,6 +38,9 @@ jobs: executor: win/preview-default steps: - run: git config --global core.autocrlf false + - run: + name: prepare test git user + command: git config --global user.email "circleci@project-helix.io" && git config --global user.name "CircleCi Build" - checkout - run: choco install nodejs --version 10.16.0 - run: npm install From 322282574138cc11aab6773dfbea8e491990f60e Mon Sep 17 00:00:00 2001 From: Lars Trieloff Date: Thu, 25 Jul 2019 14:06:29 +0000 Subject: [PATCH 08/16] ci(windows): fix command separator --- .circleci/config.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 339d3609a..8af833905 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -40,7 +40,10 @@ jobs: - run: git config --global core.autocrlf false - run: name: prepare test git user - command: git config --global user.email "circleci@project-helix.io" && git config --global user.name "CircleCi Build" + command: git config --global user.email "circleci@project-helix.io" + - run: + name: prepare test git user + command: git config --global user.name "CircleCi Build" - checkout - run: choco install nodejs --version 10.16.0 - run: npm install From cffdc9cb229a68584cd17fd05852511b73b5e313 Mon Sep 17 00:00:00 2001 From: Lars Trieloff Date: Thu, 25 Jul 2019 14:12:39 +0000 Subject: [PATCH 09/16] ci(windows): switch to text reporter --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c26d8943d..d5e9c95b9 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "check": "npm run lint && npm run test", "test": "nyc --lines 90 --reporter=text --reporter=lcov mocha -t 5000", "test-ci": "circleci tests glob 'test/test*.js' | circleci tests split --split-by=timings | xargs nyc --reporter=text --reporter=lcov mocha -R mocha-junit-reporter -t 5000 && codecov", - "test-ci-win": "mocha -R mocha-junit-reporter -t 5000", + "test-ci-win": "mocha -t 5000", "lint": "./node_modules/.bin/eslint .", "lint-ci": "circleci tests glob 'src/**/*.js' 'test/**/*.js' | circleci tests split | xargs eslint", "semantic-release": "semantic-release", From a86a679841840a0acba7585ede1996eabe62ab66 Mon Sep 17 00:00:00 2001 From: Lars Trieloff Date: Fri, 26 Jul 2019 12:26:50 +0000 Subject: [PATCH 10/16] ci(windows): adjust for win-weirdness --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d5e9c95b9..bb08a99ac 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "check": "npm run lint && npm run test", "test": "nyc --lines 90 --reporter=text --reporter=lcov mocha -t 5000", "test-ci": "circleci tests glob 'test/test*.js' | circleci tests split --split-by=timings | xargs nyc --reporter=text --reporter=lcov mocha -R mocha-junit-reporter -t 5000 && codecov", - "test-ci-win": "mocha -t 5000", + "test-ci-win": "./node_modules/.bin/mocha --reporter xunit test --reporter-options output=junit/test.xml -t 5000", "lint": "./node_modules/.bin/eslint .", "lint-ci": "circleci tests glob 'src/**/*.js' 'test/**/*.js' | circleci tests split | xargs eslint", "semantic-release": "semantic-release", From 162e506bd2883d94f1b20adb0d86b75ab7ad2dde Mon Sep 17 00:00:00 2001 From: Tobias Bocanegra Date: Wed, 31 Jul 2019 16:10:31 +0900 Subject: [PATCH 11/16] chore(package): update to @adobe/helix-simulator@2.12.19 --- package-lock.json | 20 ++++++++++---------- package.json | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index b7752e829..c04ce6582 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,9 +15,9 @@ } }, "@adobe/git-server": { - "version": "0.9.18", - "resolved": "https://registry.npmjs.org/@adobe/git-server/-/git-server-0.9.18.tgz", - "integrity": "sha512-fwErLEHzp+oECijoIZFVGCwDxFHdaTwxAZANOmXEUnI8B74gpbodlhKYZ2yHfWPiidxUI3leY2aNS9yt2vn7uQ==", + "version": "0.9.19", + "resolved": "https://registry.npmjs.org/@adobe/git-server/-/git-server-0.9.19.tgz", + "integrity": "sha512-jLoVWimoIAid6rBRy2V9ZR4WdUgLei9KGNtEfC8j6giSb+ODiJDhM1Xexq0Mbfhs19YrwXHKIoJXzO17+Zxb8A==", "requires": { "archiver": "^3.0.0", "async": "^3.0.1", @@ -199,11 +199,11 @@ } }, "@adobe/helix-simulator": { - "version": "2.12.18", - "resolved": "https://registry.npmjs.org/@adobe/helix-simulator/-/helix-simulator-2.12.18.tgz", - "integrity": "sha512-GcuW56wtRBoKnZfDs4nnjg4uB5inzr/mmhFMMx1f6bKgGU6REnEDpcQALaek+ViD2tNxRCwMeX0YkXXcm2A1IQ==", + "version": "2.12.19", + "resolved": "https://registry.npmjs.org/@adobe/helix-simulator/-/helix-simulator-2.12.19.tgz", + "integrity": "sha512-d9YRy0EdqbmbdUVUopgSLSS+JxvvQiy976HdwJzKnreYguwFVEPiueG8/1kLaV06YXOFObkUNbwYxBWuMRLHwQ==", "requires": { - "@adobe/git-server": "0.9.18", + "@adobe/git-server": "0.9.19", "@adobe/helix-shared": "2.1.1", "colors": "^1.3.0", "cookie-parser": "^1.4.4", @@ -11607,9 +11607,9 @@ } }, "nodesi": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/nodesi/-/nodesi-1.10.0.tgz", - "integrity": "sha512-qG1B9SmGQHoR45CTBjhuqIwudHgHQYqWakSVN5jOGW8n9AkOUvBuDtxTKrjD2ZhquqI8DyQu0yUglgotbDnxyA==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/nodesi/-/nodesi-1.11.0.tgz", + "integrity": "sha512-IWS8O0bsBpm1RiZ2XOjy8iLAlpgRNd+T650ZEVjX+MT8K5msfVMbkF6/lcxK06ezXWqzRNgL8d7vctTKvOZsSQ==", "requires": { "clone": "1.0.3", "good-guy-http": "1.12.0", diff --git a/package.json b/package.json index 533d917e2..f7fd3b6be 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "@adobe/fastly-native-promises": "^1.10.0", "@adobe/helix-pipeline": "4.0.5", "@adobe/helix-shared": "2.1.1", - "@adobe/helix-simulator": "2.12.18", + "@adobe/helix-simulator": "2.12.19", "@adobe/htlengine": "3.2.1", "@babel/core": "^7.5.5", "@parcel/logger": "^1.11.0", From fda84cacfbb6be9e9cf18283fc69b1f60e9cb64d Mon Sep 17 00:00:00 2001 From: Tobias Bocanegra Date: Wed, 31 Jul 2019 17:02:46 +0900 Subject: [PATCH 12/16] test(windows): skip submodule test on windows --- test/testGitUtils.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/testGitUtils.js b/test/testGitUtils.js index 147fffd2a..2311da002 100644 --- a/test/testGitUtils.js +++ b/test/testGitUtils.js @@ -82,7 +82,12 @@ describe('Testing GitUtils', () => { assert.equal(await GitUtils.isDirty(testRoot, GIT_USER_HOME), true); }); - it('isDirty #unit with submodules', async () => { + it('isDirty #unit with submodules', async function test() { + if (process.platform === 'win32') { + // windows has somehow problems wit adding file:// submodules. so we skip for now. + this.skip(); + return; + } // https://github.com/adobe/helix-cli/issues/614 const moduleRoot = await createTestRoot(); From 00ebbb3bf5b195b47d05184836ab2f37f5abef2f Mon Sep 17 00:00:00 2001 From: Tobias Bocanegra Date: Wed, 31 Jul 2019 17:15:30 +0900 Subject: [PATCH 13/16] test(git): make commit ref lookup more robust against cwd changes --- test/testGitUtils.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/testGitUtils.js b/test/testGitUtils.js index 2311da002..8789078cf 100644 --- a/test/testGitUtils.js +++ b/test/testGitUtils.js @@ -186,6 +186,8 @@ describe('Testing GitUtils', () => { }); describe('Tests against the helix-cli repo', () => { + const repoDir = path.resolve(__dirname, '..'); + function ishelix() { if (process.env.CIRCLE_REPOSITORY_URL) { return !!process.env.CIRCLE_REPOSITORY_URL.match('helix-cli'); @@ -194,17 +196,17 @@ describe('Tests against the helix-cli repo', () => { } condit('resolveCommit resolves the correct commit for tags', ishelix, async () => { - const commit = await GitUtils.resolveCommit('.', 'v1.0.0'); + const commit = await GitUtils.resolveCommit(repoDir, 'v1.0.0'); assert.equal(commit, 'f9ab59cd2baa2860289d826e270938f2eedb3e59'); }); condit('resolveCommit resolves the correct commit for shortened OID', ishelix, async () => { - const commit = await GitUtils.resolveCommit('.', 'f9ab59c'); + const commit = await GitUtils.resolveCommit(repoDir, 'f9ab59c'); assert.equal(commit, 'f9ab59cd2baa2860289d826e270938f2eedb3e59'); }); condit('resolveCommit throws for unknown ref', ishelix, async () => { - await assert.rejects(async () => GitUtils.resolveCommit('.', 'v99.unicorn.foobar'), { code: 'ResolveRefError' }); + await assert.rejects(async () => GitUtils.resolveCommit(repoDir, 'v99.unicorn.foobar'), { code: 'ResolveRefError' }); }); it('resolveCommit throws for invalid argument type', async () => { @@ -212,7 +214,7 @@ describe('Tests against the helix-cli repo', () => { }); condit('getRawContent gets the correct version', ishelix, async () => { - const content = await GitUtils.getRawContent('.', 'v1.0.0', 'package.json'); + const content = await GitUtils.getRawContent(repoDir, 'v1.0.0', 'package.json'); assert.equal(JSON.parse(content.toString()).version, '1.0.0'); }); }); From fc9508611d1c09f1dcc0e3f7c113a6586b36d24d Mon Sep 17 00:00:00 2001 From: Tobias Bocanegra Date: Wed, 31 Jul 2019 17:56:33 +0900 Subject: [PATCH 14/16] test(win): ensure tmp directories are removed --- test/testBuildCmd.js | 4 ++++ test/testCleanCmd.js | 10 ++++++---- test/testCli.js | 2 ++ test/testDemoCmd.js | 3 ++- test/testDeployCmd.js | 3 ++- test/testJUnitUtils.js | 4 ++-- test/testPackageCmd.js | 4 ++-- test/testPerfCmd.js | 10 +++++----- test/testUpCmd.js | 6 +++--- test/testUpCmdPages.js | 2 +- 10 files changed, 29 insertions(+), 19 deletions(-) diff --git a/test/testBuildCmd.js b/test/testBuildCmd.js index 0867f6e92..620ae1622 100644 --- a/test/testBuildCmd.js +++ b/test/testBuildCmd.js @@ -33,6 +33,10 @@ describe('Integration test for build', function suite() { return true; }); + afterEach(async () => { + await fs.remove(testRoot); + }); + it('build command succeeds and produces files', async () => { await new BuildCommand() .withFiles(['test/integration/src/**/*.htl', 'test/integration/src/**/*.js']) diff --git a/test/testCleanCmd.js b/test/testCleanCmd.js index bbc7b45a7..5fa7ee734 100644 --- a/test/testCleanCmd.js +++ b/test/testCleanCmd.js @@ -40,6 +40,10 @@ describe('Integration test for clean', () => { return true; }); + afterEach(async () => { + await fs.remove(testRoot); + }); + it('clean command succeeds and removes files', async () => { // add some files to the directories const testFile1 = path.resolve(buildDir, 'html.htl'); @@ -86,12 +90,10 @@ describe('Integration test for clean', () => { await fs.copy(path.resolve(testRoot, 'src', 'html.htl'), testFile1); const stub = sinon.stub(fs, 'remove') .throws(new Error('oops')); - assert.doesNotThrow(async () => { - await new CleanCommand() + await new CleanCommand() .withDirectory(testRoot) .withTargetDir(buildDir) .run(); - stub.restore(); - }); + stub.restore(); }); }); diff --git a/test/testCli.js b/test/testCli.js index 838713030..40ba5829a 100644 --- a/test/testCli.js +++ b/test/testCli.js @@ -71,6 +71,8 @@ describe('hlx command line', () => { const cmd = runCLI('--version'); assert.equal(cmd.code, 0); assert.ok(cmd.stdout.trim().indexOf('This is typically not good because it might contain secrets') >= 0); + shell.cd(cwd); + await fse.remove(testRoot); }); it('un-supported node version should give warning', async () => { diff --git a/test/testDemoCmd.js b/test/testDemoCmd.js index 0bdabaece..6342e9e9f 100644 --- a/test/testDemoCmd.js +++ b/test/testDemoCmd.js @@ -30,8 +30,9 @@ describe('Integration test for demo command', function suite() { testDir = await createTestRoot(); }); - afterEach('Change back to original working dir', () => { + afterEach('Change back to original working dir', async () => { process.chdir(pwd); + await fs.remove(testDir); }); it('demo type simple creates all files', async () => { diff --git a/test/testDeployCmd.js b/test/testDeployCmd.js index 4cfbefb07..6dd5c4e60 100644 --- a/test/testDeployCmd.js +++ b/test/testDeployCmd.js @@ -69,8 +69,9 @@ describe('hlx deploy (Integration)', () => { }); }); - afterEach(() => { + afterEach(async () => { $.cd(cwd); + await fs.remove(testRoot); }); it('deploy fails if no helix-config is present.', async () => { diff --git a/test/testJUnitUtils.js b/test/testJUnitUtils.js index 74b2bef8f..db743fcdc 100644 --- a/test/testJUnitUtils.js +++ b/test/testJUnitUtils.js @@ -24,8 +24,8 @@ describe('Test Junit Report Builder', () => { root = await createTestRoot(); }); - afterEach(() => { - // fs.removeSync(root); + afterEach(async () => { + await fs.remove(root); }); it('Responses can be appended', () => { diff --git a/test/testPackageCmd.js b/test/testPackageCmd.js index a843ff841..53d64f681 100644 --- a/test/testPackageCmd.js +++ b/test/testPackageCmd.js @@ -30,8 +30,8 @@ describe('hlx package (Integration)', () => { buildDir = path.resolve(hlxDir, 'build'); }); - afterEach(() => { - fs.remove(testRoot); + afterEach(async () => { + await fs.remove(testRoot); }); it('package creates correct package', async () => { diff --git a/test/testPerfCmd.js b/test/testPerfCmd.js index 214852b75..46d5c6b6a 100644 --- a/test/testPerfCmd.js +++ b/test/testPerfCmd.js @@ -676,7 +676,7 @@ describe('hlx perf #integrationtest', () => { assert.equal(e.message, 'Performance test failed partially'); assertFileEqual(junit, path.resolve(__dirname, 'fixtures', 'junit-partial.xml')); } finally { - fs.remove(root); + await fs.remove(root); } }).timeout(1000 * 60 * 10); @@ -1475,7 +1475,7 @@ describe('hlx perf #integrationtest', () => { await perf.run(); assertFileEqual(junit, path.resolve(__dirname, 'fixtures', 'junit-succeeded.xml')); - fs.remove(root); + await fs.remove(root); }).timeout(1000 * 60 * 10); it('hlx perf --junit (failure)', async function test() { @@ -2279,7 +2279,7 @@ describe('hlx perf #integrationtest', () => { assert.equal(e.message, 'Performance test failed entirely'); assertFileEqual(junit, path.resolve(__dirname, 'fixtures', 'junit-failed.xml')); } finally { - fs.remove(root); + await fs.remove(root); } }).timeout(1000 * 60 * 10); @@ -2312,7 +2312,7 @@ describe('hlx perf #integrationtest', () => { assert.equal(e.message, 'Performance test skipped entirely'); assertFileEqual(junit, path.resolve(__dirname, 'fixtures', 'junit-skipped.xml')); } finally { - fs.remove(root); + await fs.remove(root); } }).timeout(1000 * 60 * 10); @@ -2344,7 +2344,7 @@ describe('hlx perf #integrationtest', () => { } assert.equal(e.message, 'Unable to run performance test StatusCodeError: 500 - "Internal Server Error"'); } finally { - fs.remove(root); + await fs.remove(root); } }).timeout(1000 * 60 * 10); }); diff --git a/test/testUpCmd.js b/test/testUpCmd.js index aa84d4fb0..be40e615a 100644 --- a/test/testUpCmd.js +++ b/test/testUpCmd.js @@ -62,7 +62,7 @@ describe('Integration test for up command', function suite() { }); afterEach(async () => { - // await fse.remove(testRoot); + await fse.remove(testRoot); }); it('up command fails outside git repository', async () => { @@ -120,9 +120,9 @@ describe('Integration test for up command', function suite() { try { await assertHttpDom(`http://localhost:${cmd.project.server.port}/index.html`, 200, 'simple_response.html'); await assertHttp(`http://localhost:${cmd.project.server.port}/welcome.txt`, 200, 'welcome_response.txt'); - myDone(); + return myDone(); } catch (e) { - myDone(e); + return myDone(e); } }) .on('stopped', () => { diff --git a/test/testUpCmdPages.js b/test/testUpCmdPages.js index 3cf86a51a..95b3a2190 100644 --- a/test/testUpCmdPages.js +++ b/test/testUpCmdPages.js @@ -46,7 +46,7 @@ describe('Integration test for up command with helix pages', function suite() { }); afterEach(async () => { - // await fse.remove(testRoot); + await fse.remove(testRoot); }); it('up command delivers correct response.', (done) => { From 3f787eca62e4b93699b53db06cf0af3f5d1557c3 Mon Sep 17 00:00:00 2001 From: Tobias Bocanegra Date: Thu, 1 Aug 2019 15:16:27 +0900 Subject: [PATCH 15/16] test(win): fix tests for windows --- test/testCleanCmd.js | 7 +++---- test/testGitUtils.js | 18 ++++++------------ 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/test/testCleanCmd.js b/test/testCleanCmd.js index 5fa7ee734..719071c03 100644 --- a/test/testCleanCmd.js +++ b/test/testCleanCmd.js @@ -14,7 +14,6 @@ const path = require('path'); const fs = require('fs-extra'); -const assert = require('assert'); const sinon = require('sinon'); const { @@ -91,9 +90,9 @@ describe('Integration test for clean', () => { const stub = sinon.stub(fs, 'remove') .throws(new Error('oops')); await new CleanCommand() - .withDirectory(testRoot) - .withTargetDir(buildDir) - .run(); + .withDirectory(testRoot) + .withTargetDir(buildDir) + .run(); stub.restore(); }); }); diff --git a/test/testGitUtils.js b/test/testGitUtils.js index 8789078cf..14a7aa390 100644 --- a/test/testGitUtils.js +++ b/test/testGitUtils.js @@ -25,7 +25,9 @@ git.plugins.set('fs', require('fs')); const GitUtils = require('../src/git-utils'); -const GIT_USER_HOME = path.resolve(__dirname, 'fixtures/gitutils'); +const GIT_USER_HOME = path.resolve(__dirname, 'fixtures', 'gitutils'); + +const isNotWindows = () => (process.platform !== 'win32'); if (!shell.which('git')) { shell.echo('Sorry, this tests requires git'); @@ -82,12 +84,8 @@ describe('Testing GitUtils', () => { assert.equal(await GitUtils.isDirty(testRoot, GIT_USER_HOME), true); }); - it('isDirty #unit with submodules', async function test() { - if (process.platform === 'win32') { - // windows has somehow problems wit adding file:// submodules. so we skip for now. - this.skip(); - return; - } + // windows has somehow problems wit adding file:// submodules. so we skip for now. + condit('isDirty #unit with submodules', isNotWindows, async () => { // https://github.com/adobe/helix-cli/issues/614 const moduleRoot = await createTestRoot(); @@ -134,11 +132,7 @@ describe('Testing GitUtils', () => { assert.equal(await GitUtils.isDirty(testRoot, GIT_USER_HOME), false); }); - it('isDirty #unit with unix socket', async function socketTest() { - if (process.platform === 'win32') { - this.skip(); - return; - } + condit('isDirty #unit with unix socket', isNotWindows, async () => { assert.equal(await GitUtils.isDirty(testRoot, GIT_USER_HOME), false); await new Promise((resolve) => { From 28a5fe61532f9a347ed177102c17d7673e18d7e9 Mon Sep 17 00:00:00 2001 From: Tobias Bocanegra Date: Thu, 1 Aug 2019 15:40:35 +0900 Subject: [PATCH 16/16] test(perf): ignore colors then checking output --- test/testPerfCmd.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/test/testPerfCmd.js b/test/testPerfCmd.js index 46d5c6b6a..86e972afa 100644 --- a/test/testPerfCmd.js +++ b/test/testPerfCmd.js @@ -2350,41 +2350,44 @@ describe('hlx perf #integrationtest', () => { }); describe('hlx perf #unittest', () => { + // eslint-disable-next-line no-control-regex + const ansiRegexp = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g; + it('formatScore() #unittest', () => { assert.equal( - PerfCommand.formatScore(49, 50), - '\u001b[31m\u001b[1m49\u001b[22m\u001b[39m\u001b[31m (failed)\u001b[39m', + PerfCommand.formatScore(49, 50).replace(ansiRegexp, ''), + '49 (failed)', ); assert.equal( - PerfCommand.formatScore(0, 50), - '\u001b[31m\u001b[1m0\u001b[22m\u001b[39m\u001b[31m (failed)\u001b[39m', + PerfCommand.formatScore(0, 50).replace(ansiRegexp, ''), + '0 (failed)', ); assert.equal( - PerfCommand.formatScore(50, 50), - '\u001b[32m\u001b[1m50\u001b[22m\u001b[39m', + PerfCommand.formatScore(50, 50).replace(ansiRegexp, ''), + '50', ); assert.equal( - PerfCommand.formatScore(100, 50), - '\u001b[32m\u001b[1m100\u001b[22m\u001b[39m', + PerfCommand.formatScore(100, 50).replace(ansiRegexp, ''), + '100', ); }); it('formatMeasure() #unittest', () => { assert.equal( - PerfCommand.formatMeasure(49, 50), - '\u001b[32m\u001b[1m49\u001b[22m\u001b[39m', + PerfCommand.formatMeasure(49, 50).replace(ansiRegexp, ''), + '49', ); assert.equal( - PerfCommand.formatMeasure(0, 50), - '\u001b[32m\u001b[1m0\u001b[22m\u001b[39m', + PerfCommand.formatMeasure(0, 50).replace(ansiRegexp, ''), + '0', ); assert.equal( - PerfCommand.formatMeasure(50, 50), - '\u001b[32m\u001b[1m50\u001b[22m\u001b[39m', + PerfCommand.formatMeasure(50, 50).replace(ansiRegexp, ''), + '50', ); assert.equal( - PerfCommand.formatMeasure(100, 50), - '\u001b[31m\u001b[1m100\u001b[22m\u001b[39m\u001b[31m (failed)\u001b[39m', + PerfCommand.formatMeasure(100, 50).replace(ansiRegexp, ''), + '100 (failed)', ); });