@lumjs/tests 1.5.0 → 1.7.0

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
@@ -4,8 +4,53 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ In this document, an identifier of `@tests` is not a real package name, but a
8
+ shorthand form for the real package name of `@lumjs/tests`.
9
+ So a reference to an exported sub-module will be in `@tests/submodule` format,
10
+ and a reference to a property of a module will be in `@tests.propName` format.
11
+
7
12
  ## [Unreleased]
8
13
 
14
+ ## [1.7.0] - 2022-09-29
15
+ #### The *harness* update
16
+ ### Added
17
+ - Implemented `tests.Harness` library.
18
+ - Added a `Tap` grammar using the `peggy` library.
19
+ - Added `.npmignore` file, separate from `.gitignore`.
20
+ - The grammar source is ignored by `npm`, but kept in `git`.
21
+ - The compiled grammar is ignored by `git`, but kept in `npm`.
22
+ - Added `bin/build-grammar.sh` developer-only helper.
23
+ - Added `bin/lumtest.js` package CLI script.
24
+ - Using `lumtest.js` instead of `prove` for `npm test` now.
25
+ ### Changed
26
+ - Split `Test` class into `Stats` (test stats) and `Test` (actual testing methods.)
27
+ - A bunch of restructuring of the internal files:
28
+ - `test.js` → `test/index.js`, `test/stats.js`
29
+ - `log.js` → `test/log.js`
30
+ - `functional.js` → `test/functional.js`
31
+ - `harness.js` → `harness/index.js`
32
+ - Made the default module use *lazy-loading* for anything other than `tests.Test`.
33
+
34
+ ## [1.6.0] - 2022-09-12
35
+ #### The *sub-classes* update
36
+ ### Added
37
+ - `Test.new()` works like the `@lumjs/tests.new()`, but uses `this` so it's sub-classable.
38
+ - `Test.static()`, calls `@lumjs/tests.functional()`, and passes `this` as the `testClass`.
39
+ - `Test#TAP`, read-only accessor alias to `Test#tap()`.
40
+ - `Test.$METHODS.$meta`, a list of properties to skip in `$METHODS.all` output.
41
+ - `Test.$METHODS.extend()`, allow `Test` *sub-classes* to build upon the `$METHODS`
42
+ without changing the list in the original `Test` class.
43
+ ### Changed
44
+ - Reworked a bunch of the DocBlocks to make the docs better.
45
+ - Modified the `functional()` method to accept a `testClass` parameter.
46
+ This allows *sub-classes* to make their own functional APIs.
47
+ - Changed `Log.tap()` to make the `details` structure more flexible.
48
+ The `wanted` property is now optional.
49
+ - The `Test` class saves the test method list for `call()` into `this.$testMethods`
50
+ instead of using the `.$METHODS.test` directly.
51
+ ### Fixed
52
+ - Added some missing functions to the registered list of test methods.
53
+
9
54
  ## [1.5.0] - 2022-08-30
10
55
  ### Added
11
56
  - Sample `data` used in some of the old tests.
@@ -26,7 +71,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
26
71
  - Added `matches` method for using a regular expression to match a string.
27
72
  - Added `callIs()` method that is like `call()` but takes a desired value and passes the function return value to `cmp()`, `isa()`, or other test methods.
28
73
  - A new `test.ran` computed property.
29
-
30
74
  ### Changed
31
75
  - Updated `@lumjs/core` dependency to `^1.0.0` (no more *beta* tags!)
32
76
  - Updated various *docblocks* for documentation.
@@ -85,7 +129,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
85
129
  - Ported from Lum.js v4 library set.
86
130
  - Added a few more features from the PHP version.
87
131
 
88
- [Unreleased]: https://github.com/supernovus/lum.tests.js/compare/v1.5.0...HEAD
132
+ [Unreleased]: https://github.com/supernovus/lum.tests.js/compare/v1.7.0...HEAD
133
+ [1.7.0]: https://github.com/supernovus/lum.tests.js/compare/v1.6.0...v1.7.0
134
+ [1.6.0]: https://github.com/supernovus/lum.tests.js/compare/v1.5.0...v1.6.0
89
135
  [1.5.0]: https://github.com/supernovus/lum.tests.js/compare/v1.4.0...v1.5.0
90
136
  [1.4.0]: https://github.com/supernovus/lum.tests.js/compare/v1.3.0...v1.4.0
91
137
  [1.3.0]: https://github.com/supernovus/lum.tests.js/compare/v1.2.0...v1.3.0
package/TODO.md CHANGED
@@ -6,7 +6,6 @@
6
6
  - `callIs()`
7
7
  - `matches()`
8
8
  - `run()`
9
- - Write the `Harness` class, based of the Lum.php version.
10
- - Add tests for `Harness`.
11
- - Create `lumtest` binary for running the harness without `prove` utility.
9
+ - Test the `harness/parser` and associated `grammar/tap` libraries.
10
+ - Test the *external* test mode in `Harness`.
12
11
 
package/bin/lumtest.js ADDED
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env node
2
+ const process = require('node:process');
3
+ const Harness = require('../lib/harness');
4
+ const core = require('@lumjs/core');
5
+ const {S} = core.types;
6
+
7
+ const args = process.argv.slice(2);
8
+
9
+ const hOpts =
10
+ {
11
+ plannedFailure: true,
12
+ plannedWarning: true,
13
+ }
14
+
15
+ let rPlan = true;
16
+ let aDir = './test';
17
+
18
+ const aOpts =
19
+ {
20
+ ext: '.js',
21
+ }
22
+
23
+ const flags =
24
+ {
25
+ '-d': v => aDir = v,
26
+ '-e': v => aOpts.ext = v,
27
+ '-r': v => aOpts.recurse = parseInt(v),
28
+ }
29
+
30
+ const toggles =
31
+ {
32
+ '-f': () => hOpts.plannedFailure = false,
33
+ '-q': () => hOpts.plannedWarning = false,
34
+ '-R': () => aOpts.recurse = 99, // Never will go this far down
35
+ '-P': () => rPlan = false,
36
+ }
37
+
38
+ let mode = null;
39
+
40
+ for (const arg of args)
41
+ {
42
+ if (flags[arg])
43
+ { // A mode switch
44
+ mode = arg;
45
+ }
46
+ else if (typeof mode === S)
47
+ { // A flag that has a single argument
48
+ const flag = flags[mode];
49
+ flag(arg);
50
+ mode = null;
51
+ }
52
+ else if (toggles[arg])
53
+ { // A toggle that takes no arguments
54
+ toggles[arg]();
55
+ }
56
+ else
57
+ {
58
+ console.warn("unsupported argument", arg);
59
+ }
60
+ }
61
+
62
+ const harness = new Harness(hOpts); // Create our Harness instance.
63
+ module.exports = harness; // Export it as the 'main' module.
64
+ harness.addDir(aDir, aOpts); // Add all the files in the test dir.
65
+ harness.run(rPlan); // Run all the tests.
@@ -0,0 +1,6 @@
1
+ # Note
2
+
3
+ The `.js` files in this directory are dynamically generated from
4
+ files in the source package using the `peggy` grammar compiler.
5
+
6
+ Do not edit any of these files directly.