ultimate-jekyll-manager 1.9.23 → 1.9.24

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.
@@ -398,6 +398,11 @@ function filterBySource(source, files, sourceFilter, pathPart) {
398
398
  });
399
399
  }
400
400
 
401
+ // Glob ignore patterns implementing the "underscore = not a suite" convention:
402
+ // `_`-prefixed FILES (e.g. test/_init.js) and everything under a `_`-prefixed
403
+ // DIRECTORY at any depth (helpers, fixtures — e.g. test/_helpers/harness.js).
404
+ const DISCOVERY_IGNORE = ['**/_*.js', '**/_*/**'];
405
+
401
406
  function discoverTestFiles(target) {
402
407
  const { source: sourceFilter, pathPart } = parseTarget(target);
403
408
 
@@ -421,7 +426,7 @@ function discoverTestFiles(target) {
421
426
  // Consumers write their own boot tests under <cwd>/test/boot/.
422
427
  const frameworkSuitesDir = path.join(__dirname, 'suites');
423
428
  if (jetpack.exists(frameworkSuitesDir)) {
424
- const ignore = ['_**'];
429
+ const ignore = [...DISCOVERY_IGNORE];
425
430
  if (!isFrameworkSelfTest) ignore.push('boot/**');
426
431
  glob('**/*.js', { cwd: frameworkSuitesDir, ignore }).sort().forEach((rel) => {
427
432
  framework.push(path.join(frameworkSuitesDir, rel));
@@ -430,9 +435,10 @@ function discoverTestFiles(target) {
430
435
 
431
436
  // Consumer project suites — CWD/test/**/*.js. Skip when running from inside the
432
437
  // framework's own dist tree (where consumer-tests-dir === framework-tests-parent).
438
+ // Excludes `_`-prefixed files and directories (see DISCOVERY_IGNORE).
433
439
  const projectTestsDir = path.join(process.cwd(), 'test');
434
440
  if (jetpack.exists(projectTestsDir) && projectTestsDir !== path.dirname(frameworkSuitesDir)) {
435
- glob('**/*.js', { cwd: projectTestsDir, ignore: ['_**'] }).sort().forEach((rel) => {
441
+ glob('**/*.js', { cwd: projectTestsDir, ignore: [...DISCOVERY_IGNORE] }).sort().forEach((rel) => {
436
442
  project.push(path.join(projectTestsDir, rel));
437
443
  });
438
444
  }
@@ -508,4 +514,4 @@ async function runInitSetups() {
508
514
  }
509
515
  }
510
516
 
511
- module.exports = { run, SkipError };
517
+ module.exports = { run, SkipError, DISCOVERY_IGNORE };
@@ -0,0 +1,63 @@
1
+ // Build-layer tests for test-suite discovery — specifically the
2
+ // "underscore = not a suite" convention: `_`-prefixed files and everything
3
+ // under `_`-prefixed directories (at ANY depth) must be excluded, so consumers
4
+ // can keep helpers and fixture trees (e.g. test/_helpers/harness.js)
5
+ // next to their suites.
6
+
7
+ const path = require('path');
8
+
9
+ module.exports = {
10
+ type: 'suite',
11
+ layer: 'build',
12
+ description: 'test discovery — underscore exclusion convention',
13
+ tests: [
14
+ {
15
+ name: 'runner exports DISCOVERY_IGNORE',
16
+ run: (ctx) => {
17
+ const runner = require(path.join(__dirname, '..', '..', 'runner.js'));
18
+ ctx.expect(Array.isArray(runner.DISCOVERY_IGNORE)).toBe(true);
19
+ ctx.expect(runner.DISCOVERY_IGNORE.length >= 2).toBe(true);
20
+ },
21
+ },
22
+ {
23
+ name: 'glob with DISCOVERY_IGNORE skips _ files and _ dirs at any depth',
24
+ run: (ctx) => {
25
+ const fs = require('fs');
26
+ const os = require('os');
27
+ const glob = require('glob').globSync;
28
+ const { DISCOVERY_IGNORE } = require(path.join(__dirname, '..', '..', 'runner.js'));
29
+
30
+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'ujm-discovery-test-'));
31
+ const write = (rel) => {
32
+ const file = path.join(tmp, rel);
33
+ fs.mkdirSync(path.dirname(file), { recursive: true });
34
+ fs.writeFileSync(file, 'module.exports = {};\n');
35
+ };
36
+
37
+ // Should be DISCOVERED:
38
+ write('build/config.test.js');
39
+ write('page/runner.test.js');
40
+ write('boot/nested/deep.test.js');
41
+
42
+ // Should be EXCLUDED:
43
+ write('_init.js'); // top-level _ file
44
+ write('page/_helper.js'); // nested _ file
45
+ write('_helpers/harness.js'); // file in top-level _ dir
46
+ write('_fixtures/packages/runner/mod/index.js'); // deep inside a _ dir
47
+ write('boot/_private/util.js'); // _ dir below a layer dir
48
+
49
+ const found = glob('**/*.js', { cwd: tmp, ignore: [...DISCOVERY_IGNORE] }).sort();
50
+
51
+ try {
52
+ ctx.expect(found).toEqual([
53
+ 'boot/nested/deep.test.js',
54
+ 'build/config.test.js',
55
+ 'page/runner.test.js',
56
+ ]);
57
+ } finally {
58
+ fs.rmSync(tmp, { recursive: true, force: true });
59
+ }
60
+ },
61
+ },
62
+ ],
63
+ };
@@ -234,7 +234,7 @@ Same protocol as EM (`__EM_TEST__`) and BXM (`__BXM_TEST__`). One marker per fra
234
234
 
235
235
  - **Framework suites**: glob `<ujm>/dist/test/suites/**/*.js` (resolved from `__dirname/suites` in `runner.js`).
236
236
  - **Consumer suites**: glob `<cwd>/test/**/*.js`.
237
- - **Excluded** (`_` underscore convention): any file or directory starting with `_` is excluded from suite discovery. Put shared helpers, fixture data, and non-test support files in `_`-prefixed paths — e.g. `test/_fixtures/`, `test/_helpers/`. The runner still specifically loads `test/_init.js` as the lifecycle hook. Matches the same convention in BEM/EM/BXM.
237
+ - **Excluded** (the `_` underscore convention — `DISCOVERY_IGNORE` in `src/test/runner.js`): `_`-prefixed FILES (`test/_init.js`, `test/page/_helper.js`) and everything under a `_`-prefixed DIRECTORY at **any depth** (`test/_fixtures/**`, `test/boot/_private/**`) are excluded from suite discovery. Put shared helpers, fixture data, and non-test support files in `_`-prefixed paths — e.g. `test/_fixtures/`, `test/_helpers/`. The runner still specifically loads `test/_init.js` as the lifecycle hook. Matches the same convention in BEM/EM/BXM.
238
238
  - **Framework boot suites** are excluded when the cwd's `package.json#name` is not `ultimate-jekyll-manager` — they target UJM's fixture site, not the consumer's. Consumers write their own boot tests in `<cwd>/test/boot/`.
239
239
 
240
240
  ## `test/_init.js` — pre-test lifecycle hook
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ultimate-jekyll-manager",
3
- "version": "1.9.23",
3
+ "version": "1.9.24",
4
4
  "description": "Ultimate Jekyll dependency manager",
5
5
  "main": "dist/index.js",
6
6
  "files": [