@suffolklitlab/alkiln 5.1.0-sources-4 → 5.1.0-sources-6
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 +3 -1
- package/lib/run_cucumber.js +32 -17
- package/lib/scope.js +14 -7
- package/lib/utils/session_vars.js +48 -18
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -41,7 +41,9 @@ Format:
|
|
|
41
41
|
### Internal
|
|
42
42
|
-
|
|
43
43
|
-->
|
|
44
|
-
|
|
44
|
+
## [Unreleased]
|
|
45
|
+
### Added
|
|
46
|
+
- Can now take the location of the "sources" folder or folders as an argument in the command line. The formats are `npm run cucumber @tags -- --sources=./foo` and `alkiln-run @tags --sources=./foo`.
|
|
45
47
|
|
|
46
48
|
## [5.1.0] - 2023-08-12
|
|
47
49
|
### Added
|
package/lib/run_cucumber.js
CHANGED
|
@@ -6,18 +6,28 @@ const session_vars = require('./utils/session_vars');
|
|
|
6
6
|
|
|
7
7
|
const cucumber_api = require('@cucumber/cucumber/api');
|
|
8
8
|
|
|
9
|
-
function build_config(
|
|
10
|
-
//
|
|
11
|
-
|
|
9
|
+
function build_config( command_args ) {
|
|
10
|
+
// Turn all the paths to the sources folders into paths to the feature files
|
|
11
|
+
let sources_paths = session_vars.get_sources_paths();
|
|
12
|
+
let feature_paths = [];
|
|
13
|
+
for ( let source of sources_paths ) {
|
|
14
|
+
feature_paths.push( `${ source }/*.feature` );
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const config = {
|
|
12
18
|
publishQuiet: true,
|
|
13
19
|
require: `./lib/index.js`,
|
|
14
20
|
format: [`progress`, `summary:cucumber-report.txt`],
|
|
15
|
-
paths:
|
|
21
|
+
paths: feature_paths,
|
|
16
22
|
retry: 1,
|
|
17
23
|
}
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
// Normalize tag expressions, if there are any
|
|
26
|
+
let tags = command_args[`_`];
|
|
27
|
+
// Avoid breaking old versions of ALKilnInThePlayground
|
|
28
|
+
if ( tags.length === 0 && session_vars.get_origin() === `playground` ) {
|
|
29
|
+
tags = session_vars.get_tags();
|
|
30
|
+
}
|
|
21
31
|
if (tags.length > 0) {
|
|
22
32
|
let joined_tags = '';
|
|
23
33
|
// Cucumber expects tags in boolean expressions, like (@a0 or @a1) and @random.
|
|
@@ -34,10 +44,10 @@ function build_config(argv) {
|
|
|
34
44
|
joined_tags = tags.join(` `);
|
|
35
45
|
}
|
|
36
46
|
|
|
37
|
-
|
|
38
|
-
}
|
|
47
|
+
config.tags = joined_tags;
|
|
48
|
+
}
|
|
39
49
|
|
|
40
|
-
return
|
|
50
|
+
return config;
|
|
41
51
|
}; // Ends build_config()
|
|
42
52
|
|
|
43
53
|
|
|
@@ -48,25 +58,30 @@ function build_config(argv) {
|
|
|
48
58
|
console.log("alkiln-run: environment: %o", environment);
|
|
49
59
|
|
|
50
60
|
// process.argv is a list of strings of commands and args.
|
|
61
|
+
// If using `npm run cucumber`, use `--` before `--sources=./foo`
|
|
51
62
|
let argv = require(`minimist`)( process.argv.slice(2), {
|
|
52
63
|
default: {
|
|
53
64
|
// Testing from GitHub. TODO: Do we want to allow multiple sources paths?
|
|
54
|
-
sources: `./docassemble/*/data/sources
|
|
65
|
+
sources: [ `./docassemble/*/data/sources` ],
|
|
55
66
|
// From playground: `/usr/share/docassemble/files/playgroundsources/<user_id>/<project>/*.feature`
|
|
56
67
|
// From playground with S3: `/tmp/playgroundsources/<user_id>/<project>/*.feature`
|
|
57
68
|
}
|
|
58
69
|
});
|
|
70
|
+
|
|
71
|
+
// Make sure `sources` is always a list
|
|
72
|
+
let sources_list = argv.sources;
|
|
73
|
+
if ( typeof argv.sources === `string` ) {
|
|
74
|
+
sources_list = [ argv.sources ];
|
|
75
|
+
}
|
|
59
76
|
|
|
60
|
-
let
|
|
61
|
-
if ( !
|
|
77
|
+
let one_dir_exists = session_vars.set_sources_paths( sources_list );
|
|
78
|
+
if ( !one_dir_exists ) {
|
|
62
79
|
// If we don't throw, it'll be more confusing when no tests run
|
|
63
|
-
throw new ReferenceError( `
|
|
80
|
+
throw new ReferenceError( `ALKiln ERROR: ALKiln can't find your "sources" folder(s). See above for details.`);
|
|
64
81
|
}
|
|
65
|
-
|
|
66
|
-
const provided_config = build_config( argv );
|
|
67
|
-
|
|
82
|
+
|
|
68
83
|
const { runConfiguration } = await cucumber_api.loadConfiguration({
|
|
69
|
-
provided:
|
|
84
|
+
provided: build_config( argv ),
|
|
70
85
|
}, environment);
|
|
71
86
|
|
|
72
87
|
console.log("alkiln-run: runConfiguration: %o", runConfiguration);
|
package/lib/scope.js
CHANGED
|
@@ -1794,16 +1794,23 @@ module.exports = {
|
|
|
1794
1794
|
return false; // The row wasn't used
|
|
1795
1795
|
}
|
|
1796
1796
|
|
|
1797
|
-
let
|
|
1797
|
+
let sources_dirs = session_vars.get_sources_paths();
|
|
1798
1798
|
// Get the full paths of all the existing files
|
|
1799
1799
|
let paths = [];
|
|
1800
1800
|
let missing_files = []; // For any user warnings
|
|
1801
1801
|
for ( let name of uploads_names ) {
|
|
1802
|
+
|
|
1802
1803
|
let trimmed_name = name.trim();
|
|
1803
|
-
let matching_paths =
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1804
|
+
let matching_paths = [];
|
|
1805
|
+
// Look for the file in all "sources" folders
|
|
1806
|
+
for ( let one_dir of sources_dirs ) {
|
|
1807
|
+
let new_paths = fg.sync(
|
|
1808
|
+
[ `${ one_dir }/${ trimmed_name }` ],
|
|
1809
|
+
{ suppressErrors: true }
|
|
1810
|
+
);
|
|
1811
|
+
matching_paths.push( ...new_paths );
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1807
1814
|
if ( matching_paths.length === 0 ) {
|
|
1808
1815
|
missing_files.push( trimmed_name );
|
|
1809
1816
|
} else {
|
|
@@ -1814,7 +1821,7 @@ module.exports = {
|
|
|
1814
1821
|
if ( missing_files.length > 0 ) {
|
|
1815
1822
|
await scope.addToReport( scope, {
|
|
1816
1823
|
type: `warning`,
|
|
1817
|
-
value: `ALKiln could not find "${ missing_files.join('", "') }" in "${
|
|
1824
|
+
value: `ALKiln could not find "${ missing_files.join('", "') }" in the folder(s) at "${ sources_dirs.join('", "') }".`
|
|
1818
1825
|
});
|
|
1819
1826
|
}
|
|
1820
1827
|
|
|
@@ -2046,7 +2053,7 @@ module.exports = {
|
|
|
2046
2053
|
}
|
|
2047
2054
|
if ( num_unused_rows > 0 ) {
|
|
2048
2055
|
let { id } = await scope.examinePageID( scope, 'none to match' );
|
|
2049
|
-
let msg = `
|
|
2056
|
+
let msg = `Error on page "${id}". See screenshot and see text above for more details.`;
|
|
2050
2057
|
await scope.addToReport(scope, { type: `error`, value: msg });
|
|
2051
2058
|
expect( num_unused_rows, msg ).to.equal( 0 );
|
|
2052
2059
|
}
|
|
@@ -38,6 +38,14 @@ session_vars.get_origin = function () {
|
|
|
38
38
|
};
|
|
39
39
|
session_vars.get_user_project_name = function () { return process.env._PROJECT_NAME || null; };
|
|
40
40
|
session_vars.get_user_id = function () { return process.env._USER_ID || null; };
|
|
41
|
+
// Avoid breaking old versions of ALKilnInThePlayground
|
|
42
|
+
session_vars.get_tags = function () {
|
|
43
|
+
if ( process.env._TAGS ) {
|
|
44
|
+
return process.env._TAGS.split(` `);
|
|
45
|
+
} else {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
};
|
|
41
49
|
|
|
42
50
|
// More complex logic
|
|
43
51
|
session_vars.get_server_reload_timeout = function () {
|
|
@@ -204,37 +212,59 @@ session_vars.get_artifacts_path_name = function () {
|
|
|
204
212
|
}
|
|
205
213
|
}; // Ends get_artifacts_path_name()
|
|
206
214
|
|
|
207
|
-
session_vars.
|
|
208
|
-
/** Returns whether the given path exists
|
|
209
|
-
*
|
|
210
|
-
* .feature files, files to upload, etc.
|
|
211
|
-
* for some local testing.
|
|
215
|
+
session_vars.set_sources_paths = function ( paths ) {
|
|
216
|
+
/** Returns whether at least one of the given path exists. Store
|
|
217
|
+
* a list of the existing paths. Warn of any missing paths. Can be
|
|
218
|
+
* used for getting, e.g .feature files, files to upload, etc.
|
|
212
219
|
*
|
|
213
|
-
* Our code should ensure this gets run before cucumber
|
|
220
|
+
* Our code should ensure this gets run before cucumber tests get triggered.
|
|
214
221
|
*
|
|
215
|
-
* @
|
|
222
|
+
* @param paths { [str] } List of paths to the 'sources' folder.
|
|
223
|
+
*
|
|
224
|
+
* @returns bool
|
|
225
|
+
*/
|
|
216
226
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
)
|
|
227
|
+
// Check every path, tracking which exist and which are missing
|
|
228
|
+
let existing_paths = [];
|
|
229
|
+
let missing_paths = [];
|
|
230
|
+
for ( let path of paths ) {
|
|
231
|
+
let dirs = fg.sync(
|
|
232
|
+
[ path ],
|
|
233
|
+
{ onlyFiles: false, suppressErrors: true }
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
if ( dirs.length > 0 ) {
|
|
237
|
+
existing_paths.push( ...dirs );
|
|
238
|
+
} else {
|
|
239
|
+
missing_paths.push( path );
|
|
240
|
+
}
|
|
241
|
+
}
|
|
221
242
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
243
|
+
// Warn about missing paths
|
|
244
|
+
if ( missing_paths.length > 0 ) {
|
|
245
|
+
console.warn(
|
|
246
|
+
`ALKiln WARNING: ALKiln can't find folders at "${ paths.join(", ") }".`
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// If no paths were valid
|
|
251
|
+
if ( existing_paths.length <= 0 ) {
|
|
252
|
+
session_vars._sources_paths = null;
|
|
227
253
|
return false;
|
|
228
254
|
}
|
|
255
|
+
|
|
256
|
+
// Otherwise, store valid paths
|
|
257
|
+
session_vars._sources_paths = existing_paths;
|
|
258
|
+
return true;
|
|
229
259
|
};
|
|
230
260
|
|
|
231
|
-
session_vars.
|
|
261
|
+
session_vars.get_sources_paths = function () {
|
|
232
262
|
/** Get the "sources" folder path. Should never be undefined during
|
|
233
263
|
* a run of the test. run_cucumber.js should make sure it has
|
|
234
264
|
* a default value.
|
|
235
265
|
*
|
|
236
266
|
* @returns str || null */
|
|
237
|
-
return session_vars.
|
|
267
|
+
return session_vars._sources_paths;
|
|
238
268
|
};
|
|
239
269
|
|
|
240
270
|
session_vars.validateEnvironment = function() {
|
package/package.json
CHANGED