zarro 1.203.0 → 1.204.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.
@@ -180,6 +180,11 @@
180
180
  help: `comma-separated list of exclusions for tests${extra}`,
181
181
  default: defaultTestExclude
182
182
  });
183
+ env.register({
184
+ name: "TEST_ORDER",
185
+ help: "comma-separated list of project names or paths to use as an ordering guide when testing dotnet projects",
186
+ default: ""
187
+ });
183
188
  env.register({
184
189
  name: "TEST_ADDITIONAL_EXCLUDE",
185
190
  help: "And additional list of test exclusions - perhaps you'd like a subset test task?"
@@ -146,6 +146,48 @@ Object.defineProperty(exports, "__esModule", { value: true });
146
146
  logParallelState(testInParallel, parallelFlag);
147
147
  return testInParallel;
148
148
  }
149
+ function sortTestProjects(testProjects) {
150
+ const envOrder = env.resolveArray(env.TEST_ORDER);
151
+ if (envOrder.length === 0) {
152
+ return testProjects;
153
+ }
154
+ const rankLookup = envOrder.reduce((acc, cur, idx) => {
155
+ acc[cur] = testProjects.length - idx;
156
+ return acc;
157
+ }, {});
158
+ const result = [...testProjects];
159
+ const rankKeys = Object.keys(rankLookup);
160
+ return result.sort((a, b) => {
161
+ const rankA = findProjectRank(rankLookup, rankKeys, a), rankB = findProjectRank(rankLookup, rankKeys, b);
162
+ if (rankA === rankB) {
163
+ return 0;
164
+ }
165
+ return rankA > rankB ? -1 : 1;
166
+ });
167
+ }
168
+ function findProjectRank(lookup, keys, seek) {
169
+ var _a;
170
+ const k = findBestMatch(seek, keys);
171
+ if (!k) {
172
+ return 0;
173
+ }
174
+ return (_a = lookup[k]) !== null && _a !== void 0 ? _a : 0;
175
+ }
176
+ function findBestMatch(needle, haystack) {
177
+ const lowerNeedle = needle.toLowerCase();
178
+ for (const key of haystack) {
179
+ const lowerKey = key.toLowerCase();
180
+ if (lowerKey.endsWith(lowerNeedle)) {
181
+ return key;
182
+ }
183
+ const project = path.basename(lowerNeedle)
184
+ .replace(/\.dll$/i, "")
185
+ .replace(/\.csproj$/i, "");
186
+ if (project === key) {
187
+ return key;
188
+ }
189
+ }
190
+ }
149
191
  async function testAsDotNetCore(configuration, testProjects) {
150
192
  const runInParallel = requireModule("run-in-parallel"), testResults = {
151
193
  quackersEnabled: false,
@@ -271,7 +313,7 @@ Test Run Summary
271
313
  acc.push({ project, runTimeMs: cur.runTimeMs });
272
314
  return acc;
273
315
  }, []);
274
- console.log(yellow(`Test suite timings:`));
316
+ console.log(yellow(`\nTest suite timings:`));
275
317
  for (const r of assembliesAndTimes) {
276
318
  console.log(yellow(` ${r.project}: ${nunitLikeTime(r.runTimeMs)}`));
277
319
  }
@@ -592,6 +634,7 @@ Test Run Summary
592
634
  shouldTestInParallel,
593
635
  testOneDotNetCoreProject,
594
636
  testAsDotNetCore,
595
- logTestSuiteTimes
637
+ logTestSuiteTimes,
638
+ sortTestProjects
596
639
  };
597
640
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zarro",
3
- "version": "1.203.0",
3
+ "version": "1.204.1",
4
4
  "description": "Some glue to make gulp easier, perhaps even zero- or close-to-zero-conf",
5
5
  "bin": {
6
6
  "zarro": "index.js"
package/types.d.ts CHANGED
@@ -284,6 +284,7 @@ declare global {
284
284
  testAsDotNetCore: DotNetTester;
285
285
  shouldTestInParallel: (testProjectPaths: string[]) => Promise<boolean>;
286
286
  logTestSuiteTimes: (results: ResultOrError[], styleFn: StyleFunction) => void;
287
+ sortTestProjects: (projects: string[]) => string;
287
288
  testOneDotNetCoreProject: (
288
289
  target: string,
289
290
  configuration: string,
@@ -403,6 +404,7 @@ declare global {
403
404
  "NUNIT_LABELS" |
404
405
  "NUNIT_PROCESS" |
405
406
  "TEST_INCLUDE" |
407
+ "TEST_ORDER" |
406
408
  "TEST_ADDITIONAL_INCLUDE" |
407
409
  "TEST_EXCLUDE" |
408
410
  "TEST_ADDITIONAL_EXCLUDE" |
@@ -611,6 +613,7 @@ declare global {
611
613
  NUNIT_LABELS: StringEnvVar; // for now, at least
612
614
  NUNIT_PROCESS: StringEnvVar;
613
615
  TEST_INCLUDE: StringEnvVar;
616
+ TEST_ORDER: StringEnvVar;
614
617
  TEST_ADDITIONAL_INCLUDE: StringEnvVar;
615
618
  TEST_EXCLUDE: StringEnvVar;
616
619
  TEST_ADDITIONAL_EXCLUDE: StringEnvVar;