@suffolklitlab/alkiln 5.14.0 → 5.15.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/.github/workflows/github_server.yml +1 -1
- package/.github/workflows/playground.yml +2 -1
- package/CHANGELOG.md +29 -0
- package/action.yml +26 -10
- package/action_for_github_server/action.yml +31 -27
- package/docs/4_environments.md +2 -2
- package/docs/artifacts_folder_name.md +121 -71
- package/lib/docassemble/server_install.js +0 -2
- package/lib/docassemble/setup.js +1 -3
- package/lib/docassemble/takedown.js +2 -2
- package/lib/globals.js +10 -0
- package/lib/run_cucumber.js +40 -53
- package/lib/scope.js +32 -0
- package/lib/setup/TestGenerator.js +1757 -0
- package/lib/setup/artifacts.js +20 -0
- package/lib/setup/generate.js +42 -0
- package/lib/setup/get_Gherkin_AST.js +26 -0
- package/lib/setup/validate.js +89 -0
- package/lib/steps.js +53 -19
- package/lib/utils/Log.js +302 -149
- package/lib/utils/get_error_stacks.js +16 -0
- package/lib/utils/reports.js +43 -23
- package/lib/utils/session_vars.js +77 -57
- package/lib/utils/set_sources_paths.js +98 -0
- package/package.json +18 -7
- package/tests/log_codes/check_codes.sh +17 -13
- package/tests/log_codes/log_code_expected_instances.txt +58 -0
- package/tests/unit_tests/constrained_random_answers/invalid.fixtures.js +178 -0
- package/tests/unit_tests/constrained_random_answers/invalid.test.js +251 -0
- package/tests/unit_tests/constrained_random_answers/valid.fixtures.js +957 -0
- package/tests/unit_tests/constrained_random_answers/valid.test.js +563 -0
- package/tests/unit_tests/log.test.js +17 -41
- package/_alkiln_meta/gherkin_parsed_example.json +0 -1546
- package/_alkiln_meta/shift_logs.js +0 -75
- /package/docs/{expected_inernal_results.md → expected_internal_results.md} +0 -0
package/lib/utils/reports.js
CHANGED
|
@@ -26,14 +26,14 @@ reports.addReportHeading = function (scope, { scenario }) {
|
|
|
26
26
|
tag_names.push( tag.name );
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
let heading = `\n
|
|
29
|
+
let heading = `\n━━━━━━━━━━━━━━━\n`
|
|
30
30
|
+ `Scenario: ${ scenario.pickle.name }`;
|
|
31
31
|
|
|
32
32
|
if ( tag_names.length > 0 ) {
|
|
33
33
|
heading += `\nTags: ${ tag_names.join(' ') }`;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
heading += `\n
|
|
36
|
+
heading += `\n━━━━━━━━━━━━━━━`;
|
|
37
37
|
|
|
38
38
|
reports.addToReport( scope, {
|
|
39
39
|
code: `ALK0176`,
|
|
@@ -57,7 +57,7 @@ reports.addToReport = function( scope, { type, code, value }) {
|
|
|
57
57
|
// thrown errors if needed.
|
|
58
58
|
|
|
59
59
|
// Debugging logs
|
|
60
|
-
let debug_line = getDebugLine({ type, code, value });
|
|
60
|
+
let debug_line = getDebugLine({ type, code, value, indent: global_indent });
|
|
61
61
|
if ( session_vars.get_debug() ) {
|
|
62
62
|
console.log( `Report: ${ debug_line }` );
|
|
63
63
|
}
|
|
@@ -85,11 +85,24 @@ reports.addToReport = function( scope, { type, code, value }) {
|
|
|
85
85
|
|
|
86
86
|
// Report stuff
|
|
87
87
|
let scenario = reports.makeSureScenarioExists( scope );
|
|
88
|
-
scenario.lines.push({ type, code, value });
|
|
88
|
+
scenario.lines.push({ type, code, value, indent: global_indent });
|
|
89
89
|
|
|
90
|
-
return getLineText({ type, code, value });
|
|
90
|
+
return getLineText({ type, code, value, indent: global_indent });
|
|
91
91
|
}; // Ends reports.addToReport()
|
|
92
92
|
|
|
93
|
+
|
|
94
|
+
let indent_num = 0;
|
|
95
|
+
let global_indent = ``;
|
|
96
|
+
reports.indent = function() {
|
|
97
|
+
indent_num += 2;
|
|
98
|
+
global_indent = ` `.repeat( indent_num );
|
|
99
|
+
}
|
|
100
|
+
reports.outdent = function() {
|
|
101
|
+
indent_num = Math.max( 0, indent_num - 2 );
|
|
102
|
+
global_indent = ` `.repeat( indent_num );
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
93
106
|
reports.create = function( scope ) {
|
|
94
107
|
reports.makeSureReportExists( scope );
|
|
95
108
|
}
|
|
@@ -244,31 +257,39 @@ reports.getPrintableScenario = function( scenario ) {
|
|
|
244
257
|
/** Return a string generated from scenario list of report items. */
|
|
245
258
|
let report = ``;
|
|
246
259
|
for ( let line of scenario.lines ) {
|
|
247
|
-
let { type, code, value } = line;
|
|
248
|
-
report += `${ getLineText({ type, code, value }) }\n`;
|
|
260
|
+
let { type, code, value, indent } = line;
|
|
261
|
+
report += `${ getLineText({ type, code, value, indent }) }\n`;
|
|
249
262
|
}
|
|
250
263
|
return report;
|
|
251
264
|
}; // Ends reports.getPrintableScenario()
|
|
252
265
|
|
|
253
|
-
let getLineText = function ({ from_log, type=`no type`, code=`ALK00rl`, value=`` }) {
|
|
254
|
-
|
|
266
|
+
let getLineText = function ({ from_log, type=`no type`, code=`ALK00rl`, value=``, indent=`` }) {
|
|
267
|
+
|
|
268
|
+
value = `${ value.replace( /\n/g, `\n` + indent ) }`;
|
|
269
|
+
|
|
270
|
+
if ( type === `as_is` ) { return `${ indent }${ value }`; }
|
|
271
|
+
|
|
272
|
+
let start = indent;
|
|
273
|
+
if ( type.includes(`outcome`) ) { start = `\n`; } // extra new line
|
|
274
|
+
|
|
255
275
|
if ( type.includes(`page_id`) ) { start += `screen id: `; }
|
|
256
|
-
else if ( type.includes(`outcome`) ) { start += `\n`; } // extra new line
|
|
257
276
|
else if ( type.includes(`warning`) && !from_log ) { start += `🔎 ${ code } WARNING: `; }
|
|
258
|
-
else if ( type.includes(`error`) && !from_log ) { start +=
|
|
277
|
+
else if ( type.includes(`error`) && !from_log ) { start += `🤕 ${ code } ERROR: `; } // extra new line
|
|
278
|
+
|
|
259
279
|
return `${ start }${ value }`;
|
|
260
|
-
}; // Ends getLine()
|
|
261
280
|
|
|
262
|
-
|
|
263
|
-
|
|
281
|
+
}; // Ends getLine()
|
|
282
|
+
|
|
283
|
+
let getDebugLine = function ({ from_log, type=``, code=`ALK00rd`, value=``, indent=`` }) {
|
|
284
|
+
/** In debug log lines, include all the information possible. */
|
|
264
285
|
|
|
265
|
-
// `plain` is usually used for visual clarity and shouldn't have
|
|
266
|
-
// codes and such associated with it. Return right away.
|
|
267
|
-
if ( type.includes(`plain`) ) { return value; }
|
|
268
286
|
// Discuss: How to prevent saving in the debug log twice
|
|
269
287
|
if ( from_log ) { return value; }
|
|
288
|
+
// `plain` is usually used for visual clarity and shouldn't have
|
|
289
|
+
// codes and such associated with it. Return right away.
|
|
290
|
+
if ( type.includes(`plain`) ) { return `${ indent }${ value }`; }
|
|
270
291
|
|
|
271
|
-
let start =
|
|
292
|
+
let start = indent;
|
|
272
293
|
|
|
273
294
|
// Get all the relevant emoji
|
|
274
295
|
if ( type.includes(`debug`) ) { start += `🐛`; }
|
|
@@ -277,16 +298,15 @@ let getDebugLine = function ({ from_log, type=``, code=`ALK00rd`, value=`` }) {
|
|
|
277
298
|
if ( type.includes(`warning`) ) { start += `🔎`; }
|
|
278
299
|
if ( type.includes(`error`) ) { start += `🤕`; }
|
|
279
300
|
// Default
|
|
280
|
-
if ( start ===
|
|
301
|
+
if ( start === indent ) { start += `?`; }
|
|
281
302
|
|
|
282
303
|
start += ` ${ code }`;
|
|
283
304
|
|
|
284
|
-
|
|
305
|
+
let description_parts = [];
|
|
285
306
|
let extra_types = type.replace(/debug|info|success|warning|error/i, ``).replace(/ +/g, ' ').trim();
|
|
286
|
-
if ( extra_types.length > 0 ) {
|
|
307
|
+
if ( extra_types.length > 0 ) { description_parts = extra_types.split(` `); }
|
|
287
308
|
|
|
288
|
-
// Get all the
|
|
289
|
-
let description_parts = [];
|
|
309
|
+
// Get all the main descriptive text
|
|
290
310
|
if ( type.includes(`debug`) ) { description_parts.push( `DEBUG` ); }
|
|
291
311
|
if ( type.includes(`info`) ) { description_parts.push( `INFO` ); }
|
|
292
312
|
if ( type.includes(`success`) ) { description_parts.push( `SUCCESS` ); }
|
|
@@ -20,6 +20,17 @@ require('dotenv').config();
|
|
|
20
20
|
* easier to test.
|
|
21
21
|
* */
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Discuss: We don't like logging directly to the console in here. Consider
|
|
25
|
+
* returning most logs (info, error, warning) so that the calling functions
|
|
26
|
+
* can use a `Log` to log them properly instead of logging to the console.
|
|
27
|
+
* Alternatively, move everything in here that `Log` uses into its own file
|
|
28
|
+
* so that `session_vars` can have its own `Log` instance. For example, put
|
|
29
|
+
* artifacts path name related functions in `Log`. That "get/set/delete"
|
|
30
|
+
* behavior would be inconsistent with other similar functions. Other places
|
|
31
|
+
* need to use artifacts path name too.
|
|
32
|
+
* */
|
|
33
|
+
|
|
23
34
|
const session_vars = {};
|
|
24
35
|
|
|
25
36
|
module.exports = session_vars;
|
|
@@ -62,6 +73,18 @@ session_vars.get_setup_timeout_ms = function () {
|
|
|
62
73
|
return timeout;
|
|
63
74
|
};
|
|
64
75
|
|
|
76
|
+
session_vars.get_max_tests_per_template_scenario = function() {
|
|
77
|
+
/** Returns the maximum number of tests to generate for any one generator
|
|
78
|
+
* Scenario.
|
|
79
|
+
*
|
|
80
|
+
* Assumes an average of 30 secs per test with a max of 20 min. for all tests
|
|
81
|
+
* for that one generator Scenario.
|
|
82
|
+
*
|
|
83
|
+
* @returns {int} - Max number of tests for one generator Scenario
|
|
84
|
+
* */
|
|
85
|
+
return process.env.ALKILN_MAX_RANDOM_TESTS_PER_SCENARIO || 40;
|
|
86
|
+
}
|
|
87
|
+
|
|
65
88
|
session_vars.get_da_server_url = function () {
|
|
66
89
|
try {
|
|
67
90
|
let url = process.env.SERVER_URL || process.env.BASE_URL;
|
|
@@ -176,16 +199,18 @@ session_vars.delete_project_name = function () {
|
|
|
176
199
|
const artifacts_path_key = `artifacts_path`;
|
|
177
200
|
session_vars.save_artifacts_path_name = function ( path_name ) {
|
|
178
201
|
/** Save a key with the name of the current artifacts folder
|
|
179
|
-
*
|
|
180
|
-
* if it doesn't exist? Should we reserve this file for getting
|
|
181
|
-
* and setting?
|
|
202
|
+
* in case it doesn't exist.
|
|
182
203
|
* */
|
|
183
204
|
return session_vars.save_runtime_config_var({ key: artifacts_path_key, value: path_name });
|
|
184
205
|
}; // Ends save_artifacts_path_name()
|
|
185
206
|
session_vars.get_artifacts_path_name = function () {
|
|
186
|
-
|
|
207
|
+
/** Get the name of the current artifacts path. */
|
|
187
208
|
return session_vars.get_runtime_config_var( artifacts_path_key );
|
|
188
209
|
}; // Ends get_artifacts_path_name()
|
|
210
|
+
session_vars.delete_artifacts_path_name = function () {
|
|
211
|
+
/** Delete the runtime config value of the artifacts path. */
|
|
212
|
+
return session_vars.delete_runtime_config_var({ key: artifacts_path_key });
|
|
213
|
+
};
|
|
189
214
|
|
|
190
215
|
|
|
191
216
|
/** We use `da_install_method` for temp server vs. author's account (Playground)
|
|
@@ -221,10 +246,11 @@ session_vars.save_runtime_config_var = function ({ key, value }) {
|
|
|
221
246
|
* the json object there. The functions calling this are keeping
|
|
222
247
|
* track of the key, so they're useful to keep around.
|
|
223
248
|
*
|
|
224
|
-
* @param
|
|
225
|
-
* @param
|
|
249
|
+
* @param {object} obj - Named arguments
|
|
250
|
+
* @param {str} obj.key - Key to use to store `value` in runtime config file
|
|
251
|
+
* @param {any} obj.value - Value to store in runtime config object
|
|
226
252
|
*
|
|
227
|
-
* @returns
|
|
253
|
+
* @returns {binary?} file Runtime config file
|
|
228
254
|
*/
|
|
229
255
|
|
|
230
256
|
// Ensure runtime config file exists
|
|
@@ -246,75 +272,69 @@ session_vars.save_runtime_config_var = function ({ key, value }) {
|
|
|
246
272
|
|
|
247
273
|
session_vars.get_runtime_config_var = function ( key ) {
|
|
248
274
|
/** Get the value of the given key from the runtime config file.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
275
|
+
*
|
|
276
|
+
* @param {str} key - Key in runtime config file that contains the desired val
|
|
277
|
+
*
|
|
278
|
+
* @returns {any} - Value of given key in runtime config file or null
|
|
279
|
+
*/
|
|
254
280
|
try {
|
|
255
281
|
let json = JSON.parse( fs.readFileSync( runtime_config_path ));
|
|
256
282
|
let value = json[ key ];
|
|
257
283
|
if ( session_vars.get_debug() ) {
|
|
258
|
-
console.debug( `🐛 ALK0041 DEBUG: Runtime config var "${key}" is "${value}".` );
|
|
284
|
+
console.debug( `🐛 ALK0041 DEBUG: Runtime config var "${ key }" is "${ value }".` );
|
|
259
285
|
}
|
|
260
|
-
|
|
261
286
|
return value;
|
|
262
|
-
} catch (
|
|
287
|
+
} catch ( get_var_error ) {
|
|
288
|
+
|
|
289
|
+
console.debug(`🖊️ ALK0273 NOTE: Skipped getting runtime config var "${ key }".`, get_var_error.stack );
|
|
263
290
|
return null;
|
|
291
|
+
|
|
264
292
|
}
|
|
265
293
|
}; // Ends session_vars.get_runtime_config_var()
|
|
266
294
|
|
|
295
|
+
session_vars.delete_runtime_config_var = function ({ key }) {
|
|
296
|
+
/** Delete the runtime config var of the given `key`
|
|
297
|
+
*
|
|
298
|
+
* @param {object} obj - Named arguments
|
|
299
|
+
* @param {str} obj.key - Key in runtime config file object to delete
|
|
300
|
+
*
|
|
301
|
+
* @returns {null}
|
|
302
|
+
* */
|
|
303
|
+
try {
|
|
304
|
+
if ( !fs.existsSync( runtime_config_path )) { return null; }
|
|
305
|
+
|
|
306
|
+
let json = JSON.parse( fs.readFileSync( runtime_config_path ));
|
|
307
|
+
delete json[ key ];
|
|
308
|
+
fs.writeFileSync( runtime_config_path, JSON.stringify( json, null, 2 ));
|
|
309
|
+
return null;
|
|
267
310
|
|
|
268
|
-
|
|
269
|
-
/** Returns whether at least one of the given path exists. Store
|
|
270
|
-
* a list of the existing paths. Warn of any missing paths. Can be
|
|
271
|
-
* used for getting, e.g .feature files, files to upload, etc.
|
|
272
|
-
*
|
|
273
|
-
* Our code should ensure this gets run before cucumber tests get triggered.
|
|
274
|
-
*
|
|
275
|
-
* @param paths { [str] } List of paths to the 'sources' folder.
|
|
276
|
-
*
|
|
277
|
-
* @returns bool
|
|
278
|
-
*/
|
|
311
|
+
} catch ( delete_var_error ) {
|
|
279
312
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
let missing_paths = [];
|
|
283
|
-
for ( let path of paths ) {
|
|
284
|
-
let dirs = fg.sync(
|
|
285
|
-
[ path ],
|
|
286
|
-
{ onlyFiles: false, suppressErrors: true }
|
|
287
|
-
);
|
|
288
|
-
|
|
289
|
-
if ( dirs.length > 0 ) {
|
|
290
|
-
existing_paths.push( ...dirs );
|
|
291
|
-
} else {
|
|
292
|
-
missing_paths.push( path );
|
|
293
|
-
}
|
|
294
|
-
}
|
|
313
|
+
console.debug( `🖊️ ALK0274 NOTE: Skipped deleting runtime config var "${ key }".`, delete_var_error.stack );
|
|
314
|
+
return null
|
|
295
315
|
|
|
296
|
-
// If no paths were valid
|
|
297
|
-
if ( existing_paths.length <= 0 ) {
|
|
298
|
-
session_vars._sources_paths = null;
|
|
299
|
-
return false;
|
|
300
316
|
}
|
|
317
|
+
}; // Ends session_vars.delete_runtime_config_var()
|
|
301
318
|
|
|
302
|
-
console.info(
|
|
303
|
-
`🌈 ALK0042 SUCCESS: Did find "sources" file(s) at "${ existing_paths.join('", "') }".`
|
|
304
|
-
)
|
|
305
319
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
320
|
+
session_vars.set_sources_paths = function ( paths ) {
|
|
321
|
+
/** Set the globally accessible value of the paths to the sources folder.
|
|
322
|
+
* Saves and returns the argument it was given.
|
|
323
|
+
*
|
|
324
|
+
* @param paths {[string]} List of paths to the 'sources' folder.
|
|
325
|
+
*
|
|
326
|
+
* @returns {null | [string]}
|
|
327
|
+
* */
|
|
328
|
+
session_vars._sources_paths = paths;
|
|
329
|
+
return paths || null;
|
|
309
330
|
}; // End session_vars.set_sources_paths()
|
|
310
331
|
|
|
311
332
|
session_vars.get_sources_paths = function () {
|
|
312
|
-
/** Get the "sources" folder
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
return session_vars._sources_paths;
|
|
333
|
+
/** Get the previously stored "sources" folder paths.
|
|
334
|
+
*
|
|
335
|
+
* @returns {null | [string]}
|
|
336
|
+
* */
|
|
337
|
+
return session_vars._sources_paths || null;
|
|
318
338
|
};
|
|
319
339
|
|
|
320
340
|
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
const fast_glob = require(`fast-glob`);
|
|
2
|
+
|
|
3
|
+
const session_vars = require(`./session_vars`);
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
module.exports = function set_sources_paths({ log }) {
|
|
7
|
+
/** Set the globally accessible value of the paths to the sources folder,
|
|
8
|
+
* where authors store tests and other relevant test files. Can throw an
|
|
9
|
+
* error.
|
|
10
|
+
*
|
|
11
|
+
* @param {object} obj - Named arguments
|
|
12
|
+
* @param {Log} obj.log - Logs and saves useful info for later debugging.
|
|
13
|
+
*
|
|
14
|
+
* @returns {[string]} - All paths found for package sources folders.
|
|
15
|
+
* */
|
|
16
|
+
session_vars.validateEnvironment();
|
|
17
|
+
|
|
18
|
+
let maybe_paths = get_potential_paths();
|
|
19
|
+
|
|
20
|
+
let sources_paths = get_sources_paths({ maybe_paths });
|
|
21
|
+
if ( sources_paths === 0 ) {
|
|
22
|
+
// If we don't throw, it'll be more confusing when no tests run
|
|
23
|
+
log.throw({ code: `ALK0050`, context: `sources`,
|
|
24
|
+
error: new ReferenceError(
|
|
25
|
+
`ALKiln can't find your "sources" folder(s) which should contain tests and their related files.`
|
|
26
|
+
),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
log.info({ code: `ALK0042`, context: `sources` },
|
|
31
|
+
`Did find "sources" file(s) at "${ sources_paths.join('", "') }".`
|
|
32
|
+
);
|
|
33
|
+
session_vars.set_sources_paths( sources_paths );
|
|
34
|
+
|
|
35
|
+
return sources_paths;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
function get_potential_paths() {
|
|
40
|
+
/** Use command line args and session vars to return a list of strings of
|
|
41
|
+
* possible sources files paths.
|
|
42
|
+
*
|
|
43
|
+
* @returns {[string]} - Potential sources paths.
|
|
44
|
+
* */
|
|
45
|
+
// `project` is the name in the server docassemble "Project" page
|
|
46
|
+
let project = session_vars.get_user_project_name();
|
|
47
|
+
let id = session_vars.get_user_id();
|
|
48
|
+
|
|
49
|
+
// process.argv is a list of strings of commands and args.
|
|
50
|
+
// Internal note: If using `npm run cucumber`, use `--` before
|
|
51
|
+
// `--sources=./foo`
|
|
52
|
+
let cli_args = require(`minimist`)( process.argv.slice(2), {
|
|
53
|
+
default: {
|
|
54
|
+
sources: [
|
|
55
|
+
`./docassemble/*/data/sources`, // In GitHub folder
|
|
56
|
+
`/usr/share/docassemble/files/playgroundsources/${id}/${project}/*.feature`, // From playground without S3
|
|
57
|
+
`/tmp/playgroundsources/${id}/${project}/*.feature` // From playground with S3
|
|
58
|
+
],
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Make sure `sources` is always a list
|
|
63
|
+
let potential_paths_list = cli_args.sources;
|
|
64
|
+
if ( !Array.isArray( cli_args.sources )) {
|
|
65
|
+
potential_paths_list = [ cli_args.sources ];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return potential_paths_list;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
function get_sources_paths({ maybe_paths }) {
|
|
73
|
+
/** Of the given possible paths, return the paths that actually exist. Maybe
|
|
74
|
+
* none.
|
|
75
|
+
*
|
|
76
|
+
* @param {object} obj - Named arguments
|
|
77
|
+
* @param {[string]} obj.maybe_paths - All possible paths
|
|
78
|
+
*
|
|
79
|
+
* @returns {[string]} - List of all existing paths
|
|
80
|
+
* */
|
|
81
|
+
// Check every path, tracking which exist and which are missing
|
|
82
|
+
let existing_paths = [];
|
|
83
|
+
let missing_paths = [];
|
|
84
|
+
for ( let path of maybe_paths ) {
|
|
85
|
+
let dirs = fast_glob.sync(
|
|
86
|
+
[ path ],
|
|
87
|
+
{ onlyFiles: false, suppressErrors: true }
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
if ( dirs.length > 0 ) {
|
|
91
|
+
existing_paths.push( ...dirs );
|
|
92
|
+
} else {
|
|
93
|
+
missing_paths.push( path );
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return existing_paths;
|
|
98
|
+
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suffolklitlab/alkiln",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.15.0",
|
|
4
4
|
"description": "Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "npm run unit && npm run codes && npm run cucumber",
|
|
8
|
-
"cucumber": "./lib/run_cucumber.js",
|
|
9
8
|
"local": "npm run setup && npm run cucumber; npm run takedown",
|
|
10
|
-
|
|
11
|
-
"fail": "npm run cucumber '@error'",
|
|
12
|
-
"setup": "./lib/docassemble/setup.js",
|
|
9
|
+
|
|
13
10
|
"takedown": "./lib/docassemble/takedown.js",
|
|
11
|
+
"setup": "./lib/docassemble/setup.js",
|
|
14
12
|
"server_install": "./lib/docassemble/server_install.js",
|
|
15
|
-
|
|
13
|
+
|
|
14
|
+
"pass": "npm run cucumber 'not @error and not @temp_error'",
|
|
15
|
+
"fail": "npm run cucumber '@error'",
|
|
16
|
+
"cucumber": "npm run build && ./lib/run_cucumber.js",
|
|
17
|
+
|
|
18
|
+
"build": "npm run artifacts && npm run validate && npm run generate",
|
|
19
|
+
"validate": "./lib/setup/validate.js",
|
|
20
|
+
"generate": "./lib/setup/generate.js",
|
|
21
|
+
"artifacts": "./lib/setup/artifacts.js",
|
|
22
|
+
|
|
23
|
+
"unit": "npm run artifacts && mocha --recursive 'tests/unit_tests/**/*.test.*'",
|
|
16
24
|
"codes": "tests/log_codes/check_codes.sh ."
|
|
17
25
|
},
|
|
18
26
|
"repository": {
|
|
@@ -57,6 +65,9 @@
|
|
|
57
65
|
"alkiln-server-install": "./lib/docassemble/server_install.js",
|
|
58
66
|
"alkiln-setup": "./lib/docassemble/setup.js",
|
|
59
67
|
"alkiln-takedown": "./lib/docassemble/takedown.js",
|
|
60
|
-
"alkiln-run": "./lib/run_cucumber.js"
|
|
68
|
+
"alkiln-run": "./lib/run_cucumber.js",
|
|
69
|
+
"alkiln-artifacts": "./lib/setup/artifacts.js",
|
|
70
|
+
"alkiln-validate": "./lib/setup/validate.js",
|
|
71
|
+
"alkiln-generate": "./lib/setup/generate.js"
|
|
61
72
|
}
|
|
62
73
|
}
|
|
@@ -11,12 +11,13 @@ exit_code=0
|
|
|
11
11
|
|
|
12
12
|
echo " -------------------------------------------------------
|
|
13
13
|
| Usage: |
|
|
14
|
-
| bash $(basename $0) [dir] [c file] [c folder]
|
|
14
|
+
| bash $(basename $0) [dir] [c file] [c folder] |
|
|
15
15
|
| dir: The directory in which to search for logs |
|
|
16
16
|
| c file: Name of the log instance counter file |
|
|
17
17
|
| c folder: Path to the folder of the log counter file |
|
|
18
|
-
| -l arg: \"1\" prints extra logs |
|
|
19
18
|
-------------------------------------------------------"
|
|
19
|
+
# | bash $(basename $0) [dir] [c file] [c folder] [-l arg]
|
|
20
|
+
# | -l arg: \"1\" prints extra logs |
|
|
20
21
|
|
|
21
22
|
# Get flags and their values
|
|
22
23
|
loudness="0"
|
|
@@ -56,7 +57,7 @@ fi
|
|
|
56
57
|
# removed and are no longer used. Syntax used works with GitHub cli - [[:digit:]]
|
|
57
58
|
# https://stackoverflow.com/a/6901221
|
|
58
59
|
# Exclude files and paths
|
|
59
|
-
instances=$(find "$where_to_look" -type f ! -name "CONTRIBUTING.md" ! -name "$expected_instances_file" ! -name "debug_log.txt" ! -name "cucumber-report.txt" ! -path "*/tests/*" ! -path "*/node_modules/*" ! -path "*/ALKilnTests/*" ! -path "*/alkiln-*/*" ! -path "*/_alkiln*/*" ! -path "*/docs
|
|
60
|
+
instances=$(find "$where_to_look" -type f ! -name "CONTRIBUTING.md" ! -name "$expected_instances_file" ! -name "debug_log.txt" ! -name "cucumber-report.txt" ! -name "_alkiln*" ! -path "*/tests/*" ! -path "*/node_modules/*" ! -path "*/ALKilnTests/*" ! -path "*/alkiln-*/*" ! -path "*/_alkiln*/*" ! -path "*/docs/*" ! -path "*/\.*" -print0 | xargs -0 -P 4 grep -0 -ro 'ALK[[:digit:]][[:digit:]][[:digit:]][[:digit:]]' | grep -v -- '--' )
|
|
60
61
|
|
|
61
62
|
if [[ "$loudness" != "0" ]]; then
|
|
62
63
|
total_instances=$(echo "$instances" | wc -l)
|
|
@@ -101,7 +102,7 @@ fi
|
|
|
101
102
|
indx=0
|
|
102
103
|
too_many=()
|
|
103
104
|
missing=()
|
|
104
|
-
while [ "$indx" -
|
|
105
|
+
while [ "$indx" -le "$highest_code" ]; do
|
|
105
106
|
# Turn the index into a log code by prepending ALK and adding leading zeros
|
|
106
107
|
log_code=$(printf "ALK%04d" "$indx")
|
|
107
108
|
# Count ";" - a stand-in for the number of
|
|
@@ -126,24 +127,27 @@ while [ "$indx" -lt "$highest_code" ]; do
|
|
|
126
127
|
# To add to the list of strings to print later
|
|
127
128
|
short_msg="$log_code $num_paths/$num_expected"
|
|
128
129
|
long_msg="$log_code act/exp "
|
|
129
|
-
long_msg+="$num_paths/$num_expected
|
|
130
|
+
long_msg+="$num_paths/$num_expected"
|
|
131
|
+
if [ "$num_paths" -gt "$num_expected" ]; then
|
|
132
|
+
long_msg+=":"
|
|
133
|
+
fi
|
|
130
134
|
long_msg+=$(echo "${codes_unique_paths[$indx]}" | sed 's/;/\n - /g')
|
|
131
135
|
|
|
132
136
|
# missing
|
|
133
137
|
if [ "$num_paths" -lt "$num_expected" ]; then
|
|
134
|
-
if [[ "$loudness" != "0" ]]; then
|
|
138
|
+
# if [[ "$loudness" != "0" ]]; then
|
|
135
139
|
missing+=("$long_msg")
|
|
136
|
-
else
|
|
137
|
-
|
|
138
|
-
fi
|
|
140
|
+
# else
|
|
141
|
+
# missing+=("$short_msg")
|
|
142
|
+
# fi
|
|
139
143
|
|
|
140
144
|
# too_many
|
|
141
145
|
elif [ "$num_paths" -gt "$num_expected" ]; then
|
|
142
|
-
if [[ "$loudness" != "0" ]]; then
|
|
146
|
+
# if [[ "$loudness" != "0" ]]; then
|
|
143
147
|
too_many+=("$long_msg")
|
|
144
|
-
else
|
|
145
|
-
|
|
146
|
-
fi
|
|
148
|
+
# else
|
|
149
|
+
# too_many+=("$short_msg")
|
|
150
|
+
# fi
|
|
147
151
|
fi
|
|
148
152
|
|
|
149
153
|
let indx++
|
|
@@ -5,8 +5,11 @@ Why we need duplicate codes sometimes: GitHub actions sometimes don't have ways
|
|
|
5
5
|
The script that tests the log codes will ignore this file (or any file with this name), and any file with these names: check_codes.sh, debug_log.txt, cucumber-report.txt. It will also ignore files in folders with these names:, node_modules, ALKilnTests, alkiln-*, _alkiln*. That list might get updated, so for an up-to-date list, always check the file check_codes.sh where we use `--exclude=` and such.
|
|
6
6
|
|
|
7
7
|
Reasons for deletion:
|
|
8
|
+
0000 - unknown
|
|
8
9
|
0053 - duplicate log
|
|
9
10
|
0173 - redundant
|
|
11
|
+
0181 - unknown
|
|
12
|
+
0223 - changed Log behavior ("Only logs that throw should give a value to `error`.")
|
|
10
13
|
|
|
11
14
|
ALK0000:0
|
|
12
15
|
ALK0001:1
|
|
@@ -231,3 +234,58 @@ ALK0219:1
|
|
|
231
234
|
ALK0220:1
|
|
232
235
|
ALK0221:1
|
|
233
236
|
ALK0222:1
|
|
237
|
+
ALK0223:0
|
|
238
|
+
ALK0224:1
|
|
239
|
+
ALK0225:1
|
|
240
|
+
ALK0226:1
|
|
241
|
+
ALK0227:1
|
|
242
|
+
ALK0228:1
|
|
243
|
+
ALK0229:1
|
|
244
|
+
ALK0230:1
|
|
245
|
+
ALK0231:1
|
|
246
|
+
ALK0232:1
|
|
247
|
+
ALK0233:1
|
|
248
|
+
ALK0234:1
|
|
249
|
+
ALK0235:1
|
|
250
|
+
ALK0236:1
|
|
251
|
+
ALK0237:1
|
|
252
|
+
ALK0238:1
|
|
253
|
+
ALK0239:1
|
|
254
|
+
ALK0240:1
|
|
255
|
+
ALK0241:1
|
|
256
|
+
ALK0242:1
|
|
257
|
+
ALK0243:1
|
|
258
|
+
ALK0244:1
|
|
259
|
+
ALK0245:1
|
|
260
|
+
ALK0246:1
|
|
261
|
+
ALK0247:1
|
|
262
|
+
ALK0248:1
|
|
263
|
+
ALK0249:1
|
|
264
|
+
ALK0250:1
|
|
265
|
+
ALK0251:1
|
|
266
|
+
ALK0252:1
|
|
267
|
+
ALK0253:1
|
|
268
|
+
ALK0254:1
|
|
269
|
+
ALK0255:1
|
|
270
|
+
ALK0256:1
|
|
271
|
+
ALK0257:1
|
|
272
|
+
ALK0258:1
|
|
273
|
+
ALK0259:1
|
|
274
|
+
ALK0260:1
|
|
275
|
+
ALK0261:1
|
|
276
|
+
ALK0262:1
|
|
277
|
+
ALK0263:1
|
|
278
|
+
ALK0264:1
|
|
279
|
+
ALK0265:1
|
|
280
|
+
ALK0266:1
|
|
281
|
+
ALK0267:1
|
|
282
|
+
ALK0268:1
|
|
283
|
+
ALK0269:1
|
|
284
|
+
ALK0270:1
|
|
285
|
+
ALK0271:1
|
|
286
|
+
ALK0272:1
|
|
287
|
+
ALK0273:1
|
|
288
|
+
ALK0274:1
|
|
289
|
+
ALK0275:1
|
|
290
|
+
ALK0276:1
|
|
291
|
+
ALK0277:1
|