@salesforce/cli-plugins-testkit 1.4.31 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.5.1](https://github.com/salesforcecli/cli-plugins-testkit/compare/v1.5.0...v1.5.1) (2022-01-08)
6
+
7
+ ## [1.5.0](https://github.com/salesforcecli/cli-plugins-testkit/compare/v1.4.33...v1.5.0) (2022-01-07)
8
+
9
+ ### Features
10
+
11
+ - retries on session rmDir ([8632d5d](https://github.com/salesforcecli/cli-plugins-testkit/commit/8632d5dcde0fb1f2acee33ed26dd96a0983bb938))
12
+
13
+ ### [1.4.33](https://github.com/salesforcecli/cli-plugins-testkit/compare/v1.4.32...v1.4.33) (2022-01-03)
14
+
15
+ ### [1.4.32](https://github.com/salesforcecli/cli-plugins-testkit/compare/v1.4.31...v1.4.32) (2022-01-03)
16
+
5
17
  ### [1.4.31](https://github.com/salesforcecli/cli-plugins-testkit/compare/v1.4.30...v1.4.31) (2022-01-03)
6
18
 
7
19
  ### [1.4.30](https://github.com/salesforcecli/cli-plugins-testkit/compare/v1.4.29...v1.4.30) (2022-01-02)
@@ -1,3 +1,4 @@
1
+ import { RetryConfig } from 'ts-retry-promise';
1
2
  import { AsyncOptionalCreatable } from '@salesforce/kit';
2
3
  import { AnyJson, Optional } from '@salesforce/ts-types';
3
4
  import * as shell from 'shelljs';
@@ -60,6 +61,7 @@ export declare class TestSession extends AsyncOptionalCreatable<TestSessionOptio
60
61
  homeDir: string;
61
62
  project?: TestProject;
62
63
  setup?: AnyJson[] | shell.ShellString;
64
+ rmRetryConfig: Partial<RetryConfig<void>>;
63
65
  private debug;
64
66
  private cwdStub?;
65
67
  private overriddenDir?;
@@ -8,6 +8,7 @@ exports.TestSession = void 0;
8
8
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
9
9
  */
10
10
  const path = require("path");
11
+ const ts_retry_promise_1 = require("ts-retry-promise");
11
12
  const debug_1 = require("debug");
12
13
  const core_1 = require("@salesforce/core");
13
14
  const kit_1 = require("@salesforce/kit");
@@ -48,6 +49,8 @@ const hubAuth_1 = require("./hubAuth");
48
49
  class TestSession extends kit_1.AsyncOptionalCreatable {
49
50
  constructor(options = {}) {
50
51
  super(options);
52
+ // this is stored on the class so that tests can set it to something much lower than default
53
+ this.rmRetryConfig = { retries: 12, delay: 5000 };
51
54
  this.sandbox = sinon_1.createSandbox();
52
55
  this.orgs = [];
53
56
  this.shelljsExecOptions = {
@@ -183,16 +186,23 @@ class TestSession extends kit_1.AsyncOptionalCreatable {
183
186
  }
184
187
  async rmSessionDir() {
185
188
  // Delete the test session unless they overrode the test session dir
186
- if (!this.overriddenDir) {
189
+ if (this.overriddenDir) {
190
+ return;
191
+ }
192
+ // this is wrapped in a promise because shelljs isn't async/await
193
+ return await ts_retry_promise_1.retry(() => new Promise((resolve, reject) => {
187
194
  this.debug(`Deleting test session dir: ${this.dir}`);
188
- // Processes can hang on to files within the test session dir, preventing
189
- // removal so we wait a bit before trying.
190
- await this.sleep(kit_1.Duration.seconds(4));
191
195
  const rv = shell.rm('-rf', this.dir);
192
196
  if (rv.code !== 0) {
193
- throw Error(`Deleting the test session failed due to: ${rv.stderr}`);
197
+ reject(`Deleting the test session failed due to: ${rv.stderr}`);
194
198
  }
195
- }
199
+ resolve();
200
+ }), this.rmRetryConfig).catch((err) => {
201
+ if (err instanceof ts_retry_promise_1.RetryError) {
202
+ throw err.lastError;
203
+ }
204
+ throw err;
205
+ });
196
206
  }
197
207
  // Executes commands and keeps track of any orgs created.
198
208
  // Throws if any commands return a non-zero exitCode.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@salesforce/cli-plugins-testkit",
3
3
  "description": "Provides test utilities to assist Salesforce CLI plug-in authors with writing non-unit tests (NUT).",
4
- "version": "1.4.31",
4
+ "version": "1.5.1",
5
5
  "author": "Salesforce",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "lib/index.js",
@@ -48,11 +48,12 @@
48
48
  "archiver": "^5.2.0",
49
49
  "debug": "^4.3.1",
50
50
  "shelljs": "^0.8.4",
51
- "strip-ansi": "6.0.1"
51
+ "strip-ansi": "6.0.1",
52
+ "ts-retry-promise": "^0.6.0"
52
53
  },
53
54
  "devDependencies": {
54
- "@salesforce/dev-config": "^2.1.2",
55
- "@salesforce/dev-scripts": "^1.0.2",
55
+ "@salesforce/dev-config": "^3.0.0",
56
+ "@salesforce/dev-scripts": "^2.0.0",
56
57
  "@salesforce/prettier-config": "^0.0.2",
57
58
  "@salesforce/ts-sinon": "^1.3.18",
58
59
  "@types/archiver": "^5.1.0",
@@ -75,7 +76,7 @@
75
76
  "eslint-plugin-jsdoc": "^35.1.2",
76
77
  "eslint-plugin-prettier": "^3.4.0",
77
78
  "husky": "^7.0.4",
78
- "mocha": "^8.4.0",
79
+ "mocha": "^9.1.3",
79
80
  "nyc": "^15.1.0",
80
81
  "prettier": "^2.3.1",
81
82
  "pretty-quick": "^3.1.0",