@suffolklitlab/alkiln 5.11.2-feat-output-5 → 5.11.2-fix-root-dir-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.
- package/.github/workflows/github_server.yml +15 -44
- package/.github/workflows/playground.yml +8 -3
- package/CHANGELOG.md +1 -17
- package/action.yml +1 -13
- package/action_for_github_server/action.yml +2 -5
- package/lib/run_cucumber.js +9 -27
- package/lib/scope.js +4 -2
- package/lib/steps.js +8 -8
- package/lib/utils/log.js +1 -3
- package/lib/utils/reports.js +27 -72
- package/lib/utils/session_vars.js +1 -1
- package/package.json +1 -1
|
@@ -70,11 +70,11 @@ jobs:
|
|
|
70
70
|
- run: echo "ALKiln finished starting the isolated GitHub docassemble server"
|
|
71
71
|
shell: bash
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
#
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
#### Developer note: You can probably leave this out
|
|
74
|
+
# Optional debugging to explore things like docker issues
|
|
75
|
+
- name: Docker debug tmate session
|
|
76
|
+
if: ${{ github.event.inputs.enable_tmate }}
|
|
77
|
+
uses: mxschmitt/action-tmate@v3
|
|
78
78
|
|
|
79
79
|
#### Developer note: You can probably leave this out
|
|
80
80
|
- name: Run ALKiln - Env vars for our own tests from server output
|
|
@@ -93,54 +93,25 @@ jobs:
|
|
|
93
93
|
|
|
94
94
|
- name: "Run ALKiln tests"
|
|
95
95
|
if: ${{ success() }}
|
|
96
|
-
id: alkiln
|
|
97
96
|
#### Developer note: you'll need to replace `uses: ./`
|
|
98
97
|
#### with the path to ALKiln’s repository name and branch name. For example,
|
|
99
98
|
#### for version 5, use the branch name `v5`: `uses: suffolkLITLab/ALKiln@v5`
|
|
100
99
|
uses: ./
|
|
101
|
-
#### Developer note: You can probably leave
|
|
100
|
+
#### Developer note: You can probably leave this out
|
|
102
101
|
env:
|
|
103
|
-
|
|
104
|
-
# a da problem, not ours. We will trigger these tests manually when we
|
|
105
|
-
# want to check up on this.
|
|
106
|
-
ALKILN_TAG_EXPRESSION: "${{ (github.event.inputs.tags && format('{0}', github.event.inputs.tags)) || '(not @a11y) and (not @error)' }}"
|
|
102
|
+
ALKILN_TAG_EXPRESSION: "${{ (github.event.inputs.tags && format('{0}', github.event.inputs.tags)) || 'not @a11y' }}"
|
|
107
103
|
with:
|
|
108
104
|
#### Developer note: Required inputs. See
|
|
109
105
|
#### https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/alkiln/writing/#sandbox-inputs
|
|
110
106
|
SERVER_URL: "${{ steps.github_server.outputs.SERVER_URL }}"
|
|
111
107
|
DOCASSEMBLE_DEVELOPER_API_KEY: "${{ steps.github_server.outputs.DOCASSEMBLE_DEVELOPER_API_KEY }}"
|
|
112
108
|
INSTALL_METHOD: "server"
|
|
113
|
-
#### Developer note:
|
|
114
|
-
####
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
id: files
|
|
122
|
-
env:
|
|
123
|
-
GH_TOKEN: ${{ github.token }}
|
|
124
|
-
run: |
|
|
125
|
-
# Make an issue with file contents or 'no file' message as part of the body
|
|
126
|
-
|
|
127
|
-
# ex: "alkiln-2024-05-23 at 10h35m08sUTC/"
|
|
128
|
-
FOLDER=$(ls -d */ | grep -E '^alkiln-*')
|
|
129
|
-
|
|
130
|
-
# Tests that failed or had typos in the Step instructions
|
|
131
|
-
UNEXPECTED_RESULTS_PATH="${FOLDER}unexpected_results.txt"
|
|
132
|
-
# Other possibly useful files
|
|
133
|
-
# REPORT_PATH="${FOLDER}report.txt"
|
|
134
|
-
# DEBUG_LOG_PATH="${FOLDER}debug_log.txt"
|
|
135
|
-
|
|
136
|
-
if [ -f "$UNEXPECTED_RESULTS_PATH" ]; then
|
|
137
|
-
UNEXPECTED_RESULTS=$(cat "$UNEXPECTED_RESULTS_PATH")
|
|
138
|
-
else
|
|
139
|
-
UNEXPECTED_RESULTS="unexpected_results.txt does not exist. Something other than the tests may have failed."
|
|
140
|
-
fi
|
|
141
|
-
|
|
142
|
-
gh issue create --body "An ALKiln test run failed. See the action at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}.
|
|
143
|
-
|
|
144
|
-
### Results:
|
|
109
|
+
#### Developer note: See https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/alkiln/writing/#optional-inputs
|
|
110
|
+
#### You can probably leave this out
|
|
111
|
+
# Internal: docassemble changes sometimes break @a11y tests. That is
|
|
112
|
+
# a da problem, not ours. We will trigger these tests manually when we
|
|
113
|
+
# want to check up on this.
|
|
114
|
+
ALKILN_TAG_EXPRESSION: $ALKILN_TAG_EXPRESSION
|
|
115
|
+
#### Developer note: You can probably leave this out
|
|
116
|
+
# ALKILN_VERSION: url
|
|
145
117
|
|
|
146
|
-
$UNEXPECTED_RESULTS" --repo "$GITHUB_REPOSITORY" --label "testing" --title "Parse file in outer workflow: Test if failed tests make issue"
|
|
@@ -55,13 +55,18 @@ jobs:
|
|
|
55
55
|
# Place the root directory in this branch to access relative paths to action files
|
|
56
56
|
- uses: actions/checkout@v4
|
|
57
57
|
|
|
58
|
+
- name: Pause between triggers
|
|
59
|
+
if: (github.event_name == 'pull_request' && ! github.event.pull_request.head.repo.fork)
|
|
60
|
+
shell: bash
|
|
61
|
+
run: sleep 60
|
|
62
|
+
|
|
58
63
|
#### Developer note: you'll need to replace `uses: ./`
|
|
59
64
|
#### with the path to ALKiln’s repository name and branch name. For example,
|
|
60
65
|
#### for version 5, use the branch name `v5`: `uses: suffolkLITLab/ALKiln@v5`
|
|
61
66
|
- uses: ./
|
|
62
67
|
#### Developer note: You can probably leave this out
|
|
63
68
|
env:
|
|
64
|
-
ALKILN_TAG_EXPRESSION: "${{ (github.event.inputs.tags && format('{0}', github.event.inputs.tags)) || '
|
|
69
|
+
ALKILN_TAG_EXPRESSION: "${{ (github.event.inputs.tags && format('{0}', github.event.inputs.tags)) || 'not @a11y' }}"
|
|
65
70
|
with:
|
|
66
71
|
#### Developer note: Required ALKiln inputs. You can read more at
|
|
67
72
|
#### https://suffolklitlab.org/docassemble-AssemblyLine-documentation/docs/alkiln/writing/#githubNyou-inputs
|
|
@@ -72,6 +77,6 @@ jobs:
|
|
|
72
77
|
# Internal: docassemble changes sometimes break @a11y tests. That is
|
|
73
78
|
# a da problem, not ours. We will trigger these tests manually when we
|
|
74
79
|
# want to check up on this.
|
|
75
|
-
ALKILN_TAG_EXPRESSION:
|
|
80
|
+
ALKILN_TAG_EXPRESSION: $ALKILN_TAG_EXPRESSION
|
|
76
81
|
#### Developer note: You can probably leave this out
|
|
77
|
-
ALKILN_VERSION:
|
|
82
|
+
# ALKILN_VERSION: url
|
package/CHANGELOG.md
CHANGED
|
@@ -45,25 +45,9 @@ Format:
|
|
|
45
45
|
|
|
46
46
|
## [Unreleased]
|
|
47
47
|
|
|
48
|
-
### Added
|
|
49
|
-
|
|
50
|
-
- New outputs from the ALKiln action - `REPORT`, `UNEXPECTED_RESULTS_PATH`, and `DEBUG_LOG_PATH`. Authors can choose to use these as they wish. For example, they can put the contents of these in issues they create from their workflow. Closes [#701](https://github.com/SuffolkLITLab/ALKiln/issues/701).
|
|
51
|
-
- New file with just failure results, including cucumber results when possible. It accumulates Scenario info as the tests run. Even if a test run stops early, there will still be some results.
|
|
52
|
-
|
|
53
48
|
### Changed
|
|
54
49
|
|
|
55
|
-
-
|
|
56
|
-
- report.txt includes the cucumber output at the bottom as well.
|
|
57
|
-
|
|
58
|
-
### Fixed
|
|
59
|
-
|
|
60
|
-
- Tag expression not being parsed correctly. Surrounded `ALKILN_TAG_EXPRESSION` with `"`.
|
|
61
|
-
|
|
62
|
-
### Internal
|
|
63
|
-
|
|
64
|
-
- Removed our own workflow's pause between triggers
|
|
65
|
-
- Improved our use of ALKIN_TAG_EXPRESSION env var
|
|
66
|
-
-
|
|
50
|
+
- Use an absolute path for `runtime_config.json`
|
|
67
51
|
|
|
68
52
|
## [5.11.2] - 2024-05-17
|
|
69
53
|
|
package/action.yml
CHANGED
|
@@ -102,7 +102,6 @@ runs:
|
|
|
102
102
|
if: ${{ inputs.INSTALL_METHOD == 'playground' && failure() }}
|
|
103
103
|
shell: bash
|
|
104
104
|
run: |
|
|
105
|
-
# 😞 ALK0028 ERROR: Unable to create a Project
|
|
106
105
|
echo -e "\n\n====\n😞 ALK0028 ERROR: Unable to create a Project on your server's testing account or pull your package into it. Check the messages above this line.\n\n"
|
|
107
106
|
|
|
108
107
|
# Server installations - find folders and save session vars
|
|
@@ -122,7 +121,7 @@ runs:
|
|
|
122
121
|
env:
|
|
123
122
|
ALKILN_TAG_EXPRESSION: ${{ inputs.ALKILN_TAG_EXPRESSION || github.event.inputs.tags && format('{0}', github.event.inputs.tags) }}
|
|
124
123
|
shell: bash
|
|
125
|
-
run: alkiln-run
|
|
124
|
+
run: alkiln-run $ALKILN_TAG_EXPRESSION
|
|
126
125
|
|
|
127
126
|
# on playground, delete project
|
|
128
127
|
- name: "💡 ALK0032 INFO: Delete the Project from the Playground"
|
|
@@ -138,17 +137,6 @@ runs:
|
|
|
138
137
|
name: ${{ env.ARTIFACT_NAME }}
|
|
139
138
|
path: ./alkiln-*
|
|
140
139
|
|
|
141
|
-
# Download artifacts folder internally to create action output
|
|
142
|
-
- name: "💡 ALK0182 INFO: Get uploaded artifacts folder"
|
|
143
|
-
if: ${{ always() }}
|
|
144
|
-
uses: actions/download-artifact@v4
|
|
145
|
-
with:
|
|
146
|
-
name: ${{ env.ARTIFACT_NAME }}
|
|
147
|
-
|
|
148
|
-
# Don't create output from files
|
|
149
|
-
# Cannot properly create outputs with multi-line text. Collapses onto one line.
|
|
150
|
-
|
|
151
140
|
- shell: bash
|
|
152
|
-
if: ${{ always() }}
|
|
153
141
|
run: |
|
|
154
142
|
echo "💡 ALK0034 INFO: ALkiln finished running tests"
|
|
@@ -109,14 +109,12 @@ runs:
|
|
|
109
109
|
if: ${{ env.OUTPUT_DOCKER == 'false' }}
|
|
110
110
|
shell: bash
|
|
111
111
|
run: |
|
|
112
|
-
|
|
113
|
-
echo -e '===\n💡 ALK0007 INFO: ALKiln will now hide docker output to avoid possibly showing details about your config. If you want to get output to see more of what is going on, use "with:" and set the input "SHOW_DOCKER_OUTPUT" to "true". This output will only be visible to those who can already see the action output, like people with admin or write permissions.\n==='
|
|
112
|
+
echo '===\n💡 ALK0007 INFO: ALKiln will now hide docker output to avoid possibly showing details about your config. If you want to get output to see more of what is going on, use "with:" and set the input "SHOW_DOCKER_OUTPUT" to "true". This output will only be visible to those who can already see the action output, like people with admin or write permissions.\n==='
|
|
114
113
|
- name: "💡 ALK0008 INFO: ALKiln will show docker output"
|
|
115
114
|
if: ${{ env.OUTPUT_DOCKER == 'true' }}
|
|
116
115
|
shell: bash
|
|
117
116
|
run: |
|
|
118
|
-
|
|
119
|
-
echo -e '===\n💡 ALK0008 INFO: ALKiln will show docker output. ALKiln cannot control this output. If you want to prevent output, use "with:" and set the input "SHOW_DOCKER_OUTPUT" to "false". This output will only be visible to those who can already see the action output, like people with admin or write permissions.\n==='
|
|
117
|
+
echo '===\n💡 ALK0008 INFO: ALKiln will show docker output. ALKiln cannot control this output. If you want to prevent output, use "with:" and set the input "SHOW_DOCKER_OUTPUT" to "false". This output will only be visible to those who can already see the action output, like people with admin or write permissions.\n==='
|
|
120
118
|
|
|
121
119
|
# TODO: Reduce these to 1 block by putting ` > /dev/null 2>&1` into an env var
|
|
122
120
|
# No docker output
|
|
@@ -158,7 +156,6 @@ runs:
|
|
|
158
156
|
if: ${{ env.OUTPUT_DOCKER == 'false' }}
|
|
159
157
|
shell: bash
|
|
160
158
|
run: |
|
|
161
|
-
# 💡 ALK0011 INFO: The following messages are not docker output
|
|
162
159
|
echo "💡 ALK0011 INFO: The following messages are not docker output, just ALKiln waiting for the server to start"
|
|
163
160
|
|
|
164
161
|
- name: "💡 ALK0012 INFO: Waiting for server to start"
|
package/lib/run_cucumber.js
CHANGED
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const cucumber_api = require('@cucumber/cucumber/api');
|
|
5
5
|
|
|
6
|
-
const log = require('./utils/log');
|
|
6
|
+
const log = require('./utils/log');
|
|
7
7
|
const session_vars = require('./utils/session_vars');
|
|
8
8
|
|
|
9
|
-
const SUMMARY_FILENAME = `cucumber-report.txt`;
|
|
10
|
-
|
|
11
9
|
function build_config( command_args ) {
|
|
12
10
|
// Turn all the paths to the sources folders into paths to the feature files
|
|
13
11
|
let sources_paths = session_vars.get_sources_paths();
|
|
@@ -19,18 +17,14 @@ function build_config( command_args ) {
|
|
|
19
17
|
const config = {
|
|
20
18
|
publishQuiet: true,
|
|
21
19
|
require: `./lib/index.js`,
|
|
22
|
-
format: [`progress`, `summary
|
|
20
|
+
format: [`progress`, `summary:cucumber-report.txt`],
|
|
23
21
|
paths: feature_paths,
|
|
24
22
|
retry: 1,
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
// Normalize tag expressions, if there are any
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
let tags = command_args[`_`].join(` `).split(` `);
|
|
31
|
-
// If there is no tag expression, `tags` is ['']. Ignore those cases.
|
|
32
|
-
// Length test may be unnecessary.
|
|
33
|
-
if ( tags[0] || tags.length > 1 ) {
|
|
26
|
+
let tags = command_args[`_`];
|
|
27
|
+
if (tags.length > 0) {
|
|
34
28
|
let joined_tags = '';
|
|
35
29
|
// Cucumber expects tags in boolean expressions, like (@a0 or @a1) and @random.
|
|
36
30
|
// If we get a list of only tags, then "or" them all together
|
|
@@ -111,20 +105,19 @@ function build_config( command_args ) {
|
|
|
111
105
|
|
|
112
106
|
const { success } = await cucumber_api.runCucumber({...runConfiguration, support});
|
|
113
107
|
if ( success ) {
|
|
114
|
-
log.
|
|
108
|
+
log.info({ type: `run`, code: `ALK0054`, pre: `Cucumber executed correctly` });
|
|
115
109
|
} else {
|
|
116
|
-
log.error({ type: `run`, code: `ALK0055`, pre: `
|
|
110
|
+
log.error({ type: `run`, code: `ALK0055`, pre: `Cucumber ran into an error` });
|
|
117
111
|
}
|
|
118
|
-
|
|
119
|
-
const exitCode = success ? 0 : 2;
|
|
112
|
+
const exitCode = success ? 0 : 1;
|
|
120
113
|
process.exitCode = exitCode;
|
|
121
114
|
|
|
122
115
|
// This is hardcoded information from `provide_config` above.
|
|
123
116
|
// This code isn't used for anything other than detecting and removing color codes.
|
|
124
|
-
let summary_file_name =
|
|
117
|
+
let summary_file_name = 'cucumber-report.txt';
|
|
125
118
|
fs.readFile(summary_file_name, 'utf8', (err, text) => {
|
|
126
119
|
if (err) {
|
|
127
|
-
log.error({ type: `
|
|
120
|
+
log.error({ type: `run`, code: `ALK0056`, pre: `cucumber report`, data: err });
|
|
128
121
|
return;
|
|
129
122
|
}
|
|
130
123
|
|
|
@@ -135,16 +128,5 @@ function build_config( command_args ) {
|
|
|
135
128
|
// Put it in the correct file in the correct folder
|
|
136
129
|
let artifacts_path = session_vars.get_artifacts_path_name();
|
|
137
130
|
fs.appendFileSync( `${ artifacts_path }/${ log.debug_log_file }`, `\n\n${text}`);
|
|
138
|
-
try {
|
|
139
|
-
// Add to a unexpected results file (that should exist already) if needed
|
|
140
|
-
if ( exitCode === 2 ) {
|
|
141
|
-
fs.appendFileSync(
|
|
142
|
-
`${ artifacts_path }/${ log.unexpected_filename }`,
|
|
143
|
-
`\n\n${ text }`
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
} catch ( error ) {
|
|
147
|
-
log.error({ type: `internal run`, code: `ALK0181`, pre: `This is sometimes fine. ALKiln was unable to read ${ log.unexpected_filename }, which might just mean there was an unrelated failure above.`, data: error });
|
|
148
|
-
}
|
|
149
131
|
});
|
|
150
132
|
})();
|
package/lib/scope.js
CHANGED
|
@@ -3228,7 +3228,8 @@ module.exports = {
|
|
|
3228
3228
|
*
|
|
3229
3229
|
* @param expected {array} Arr of strs that should appear in the report.
|
|
3230
3230
|
*/
|
|
3231
|
-
let
|
|
3231
|
+
let current_report_obj = scope.report.get( scope.scenario_id );
|
|
3232
|
+
let scenario = [ scope.scenario_id, current_report_obj ]; // Mimic how loop works with `Map`
|
|
3232
3233
|
let report = reports.getPrintableScenario( scenario );
|
|
3233
3234
|
let all_are_included = true;
|
|
3234
3235
|
for ( let one_expectation of expected ) {
|
|
@@ -3247,7 +3248,8 @@ module.exports = {
|
|
|
3247
3248
|
*
|
|
3248
3249
|
* @param not_expected {array} Arr of strs that should not appear in the report.
|
|
3249
3250
|
*/
|
|
3250
|
-
let
|
|
3251
|
+
let current_report_obj = scope.report.get( scope.scenario_id );
|
|
3252
|
+
let scenario = [ scope.scenario_id, current_report_obj ]; // Mimic how loop works with `Map`
|
|
3251
3253
|
let report = reports.getPrintableScenario( scenario );
|
|
3252
3254
|
let none_included = true;
|
|
3253
3255
|
for ( let one_expectation of not_expected ) {
|
package/lib/steps.js
CHANGED
|
@@ -101,11 +101,8 @@ BeforeAll(async () => {
|
|
|
101
101
|
session_vars.save_artifacts_path_name( scope.paths.artifacts );
|
|
102
102
|
|
|
103
103
|
scope.paths.report = `${ scope.paths.artifacts }/report.txt`;
|
|
104
|
-
scope.paths.failures = `${ scope.paths.artifacts }/${ log.unexpected_filename }`;
|
|
105
104
|
scope.paths.debug_log = `${ scope.paths.artifacts }/${ log.debug_log_file }`;
|
|
106
105
|
fs.writeFileSync( scope.paths.debug_log, "" );
|
|
107
|
-
|
|
108
|
-
reports.create( scope );
|
|
109
106
|
});
|
|
110
107
|
|
|
111
108
|
Before(async (scenario) => {
|
|
@@ -1205,17 +1202,17 @@ After(async function(scenario) {
|
|
|
1205
1202
|
}
|
|
1206
1203
|
|
|
1207
1204
|
if ( scope.failed_pdf_compares.length > 0) {
|
|
1208
|
-
let msg = scope.failed_pdf_compares.reduce((str, new_msg) => `${ str }\n
|
|
1205
|
+
let msg = scope.failed_pdf_compares.reduce((str, new_msg) => `${ str }\n---\n${ new_msg }`)
|
|
1209
1206
|
changeable_test_status = `FAILED`;
|
|
1210
1207
|
reports.addToReport(scope, {
|
|
1211
1208
|
type: `error`,
|
|
1212
1209
|
code: `ALK0093`,
|
|
1213
|
-
value: `PDF comparison failed ${ scope.failed_pdf_compares.length } time(s)\n
|
|
1210
|
+
value: `PDF comparison failed ${ scope.failed_pdf_compares.length } time(s)\n---\n${ msg }\n---\n`
|
|
1214
1211
|
});
|
|
1215
1212
|
}
|
|
1216
1213
|
|
|
1217
1214
|
// Record status before internal report tests can interfere with values
|
|
1218
|
-
reports.
|
|
1215
|
+
reports.setReportScenarioStatus( scope, { status: changeable_test_status });
|
|
1219
1216
|
|
|
1220
1217
|
if (changeable_test_status !== `PASSED`) {
|
|
1221
1218
|
log.debug({
|
|
@@ -1259,11 +1256,11 @@ After(async function(scenario) {
|
|
|
1259
1256
|
} // ends if not passed
|
|
1260
1257
|
|
|
1261
1258
|
// Add report text to Scenario folder after everything has been added to the report
|
|
1262
|
-
let
|
|
1259
|
+
let current_report_obj = scope.report.get( scope.scenario_id );
|
|
1260
|
+
let scenario_report_obj = [ scope.scenario_id, current_report_obj ]; // Mimic how loop works with `Map`
|
|
1263
1261
|
let report = reports.getPrintableScenario( scenario_report_obj );
|
|
1264
1262
|
// Save the report as in the Scenario folder
|
|
1265
1263
|
fs.writeFileSync( scope.paths.scenario_report, report );
|
|
1266
|
-
// TODO: Save any cucumber failure message for the Scenario here (instead of waiting till run_cucumber.js)
|
|
1267
1264
|
|
|
1268
1265
|
// ---------------- Check internal test results ----------------
|
|
1269
1266
|
|
|
@@ -1414,6 +1411,9 @@ AfterAll(async function() {
|
|
|
1414
1411
|
// May need newest version of cucumberjs
|
|
1415
1412
|
console.log( `\n\n${ report }` );
|
|
1416
1413
|
|
|
1414
|
+
// Save/download the report as an artifact
|
|
1415
|
+
fs.writeFileSync( scope.paths.report, report );
|
|
1416
|
+
|
|
1417
1417
|
// If there is a browser open, then close it
|
|
1418
1418
|
if (scope.browser) {
|
|
1419
1419
|
await scope.browser.close();
|
package/lib/utils/log.js
CHANGED
|
@@ -2,7 +2,6 @@ const fs = require('fs');
|
|
|
2
2
|
const session_vars = require( './session_vars' );
|
|
3
3
|
|
|
4
4
|
// ? 🌈 💡 🔎 🤕 🐞
|
|
5
|
-
// Alternatives: 🩹 ❤️🩹 🚑
|
|
6
5
|
// TODO: return full message so it can be passed to manually
|
|
7
6
|
// thrown errors if needed.
|
|
8
7
|
|
|
@@ -92,5 +91,4 @@ log.add_to_debug_log = function(value) {
|
|
|
92
91
|
fs.appendFileSync(log.debug_log_file, value);
|
|
93
92
|
};
|
|
94
93
|
|
|
95
|
-
log.debug_log_file =
|
|
96
|
-
log.unexpected_filename = `unexpected_results.txt`;
|
|
94
|
+
log.debug_log_file = 'debug_log.txt'
|
package/lib/utils/reports.js
CHANGED
|
@@ -7,13 +7,6 @@ const files = require(`./files` );
|
|
|
7
7
|
|
|
8
8
|
module.exports = reports = {};
|
|
9
9
|
|
|
10
|
-
reports.title = `Assembly Line Kiln Automated Testing Report - ${ (new Date()).toUTCString() }\n`;
|
|
11
|
-
reports.failures = [ `\n\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n🤕 Failed scenarios\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n` ];
|
|
12
|
-
reports.successes = [ `\n\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n🌈 Passed scenarios\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n` ];
|
|
13
|
-
// reports.warnings = [ `\n\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n🔎 Scenarios to check\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n` ];
|
|
14
|
-
// reports.undefineds = [ `\n\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n[langs icon] Scenarios with typos\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n` ];
|
|
15
|
-
reports.others = [ `\n\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n🔎 Other scenarios that did not pass\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n` ];
|
|
16
|
-
|
|
17
10
|
reports.addReportHeading = function (scope, { scenario }) {
|
|
18
11
|
/** Return printable heading based on Scenario name and tags.
|
|
19
12
|
* Allow characters from other languages.
|
|
@@ -26,14 +19,14 @@ reports.addReportHeading = function (scope, { scenario }) {
|
|
|
26
19
|
tag_names.push( tag.name );
|
|
27
20
|
}
|
|
28
21
|
|
|
29
|
-
let heading = `\n
|
|
22
|
+
let heading = `\n---------------\n`
|
|
30
23
|
+ `Scenario: ${ scenario.pickle.name }`;
|
|
31
24
|
|
|
32
25
|
if ( tag_names.length > 0 ) {
|
|
33
26
|
heading += `\nTags: ${ tag_names.join(' ') }`;
|
|
34
27
|
}
|
|
35
28
|
|
|
36
|
-
heading += `\n
|
|
29
|
+
heading += `\n---------------`;
|
|
37
30
|
|
|
38
31
|
reports.addToReport( scope, {
|
|
39
32
|
code: `ALK0176`,
|
|
@@ -78,30 +71,21 @@ reports.addToReport = function( scope, { type, code, value }) {
|
|
|
78
71
|
}
|
|
79
72
|
|
|
80
73
|
// Report stuff
|
|
81
|
-
let scenario =
|
|
74
|
+
let scenario = makeSureReportPartsExist( scope );
|
|
82
75
|
scenario.lines.push({ type, code, value });
|
|
83
76
|
|
|
84
77
|
return scenario;
|
|
85
78
|
}; // Ends reports.addToReport()
|
|
86
79
|
|
|
87
|
-
|
|
88
|
-
reports.makeSureReportExists( scope );
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
reports.makeSureReportExists = function( scope ) {
|
|
80
|
+
let makeSureReportPartsExist = function( scope ) {
|
|
92
81
|
/** If a part of the report needs to exist right now, but doesn't exist,
|
|
93
82
|
* create it. */
|
|
94
83
|
if ( !scope.report ) { scope.report = new Map(); }
|
|
95
|
-
return this;
|
|
96
|
-
}; // Ends reports.makeSureReportExists()
|
|
97
|
-
|
|
98
|
-
reports.makeSureScenarioExists = function ( scope ) {
|
|
99
|
-
reports.makeSureReportExists( scope );
|
|
100
84
|
if ( !scope.scenario_id ) {
|
|
101
85
|
scope.scenario_id = `_report_${ Date.now() }`;
|
|
102
86
|
}
|
|
103
87
|
if ( !scope.report.get( scope.scenario_id )) {
|
|
104
|
-
scope.report.set( scope.scenario_id, {} )
|
|
88
|
+
scope.report.set( scope.scenario_id, {} )
|
|
105
89
|
scope.report.get( scope.scenario_id ).status = `in progress`;
|
|
106
90
|
}
|
|
107
91
|
|
|
@@ -109,36 +93,11 @@ reports.makeSureScenarioExists = function ( scope ) {
|
|
|
109
93
|
if ( !scenario.lines ) { scenario.lines = []; }
|
|
110
94
|
|
|
111
95
|
return scenario;
|
|
112
|
-
}; // Ends
|
|
113
|
-
|
|
114
|
-
reports.saveFinalScenarioData = function( scope, { status=`in progress` }) {
|
|
115
|
-
this.setReportScenarioStatus( scope, { status });
|
|
116
|
-
let scenario = scope.report.get( scope.scenario_id );
|
|
117
|
-
let report = this.getPrintableScenario( scenario );
|
|
118
|
-
if ( scenario.status === `FAILED` ) { this.failures.push( report ); }
|
|
119
|
-
else if ( scenario.status === `PASSED` ) { this.successes.push( report ); }
|
|
120
|
-
// else if ( scenario.status === `WARNING` ) { passed_reports += report; this.warnings.push( report ); }
|
|
121
|
-
// else if ( scenario.status === `UNDEFINED` ) { passed_reports += report; this.undefineds.push( report ); }
|
|
122
|
-
else { this.others.push( report ); }
|
|
123
|
-
|
|
124
|
-
// Save to failures.txt (worry about optimization later)
|
|
125
|
-
if ( this.failures.length > 1 || this.others.length > 1 ) {
|
|
126
|
-
fs.writeFileSync(
|
|
127
|
-
scope.paths.failures,
|
|
128
|
-
this.title + this.getPrintableUnexpected( scope )
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
// Save to reports.txt (worry about optimization later)
|
|
132
|
-
fs.writeFileSync( scope.paths.report, this.getPrintableReport( scope ) );
|
|
133
|
-
|
|
134
|
-
return scenario;
|
|
135
|
-
}; // Ends reports.saveFinalScenarioData()
|
|
136
|
-
|
|
96
|
+
}; // Ends makeSureReportPartsExist()
|
|
137
97
|
|
|
138
98
|
reports.setReportScenarioStatus = function( scope, { status=`PASSED` }) {
|
|
139
99
|
/** Add final status of scenario to scenario report object - passed, failed, etc. */
|
|
140
100
|
scope.report.get( scope.scenario_id ).status = status;
|
|
141
|
-
return scope.report.get( scope.scenario_id );
|
|
142
101
|
}; // Ends reports.setReportScenarioStatus()
|
|
143
102
|
|
|
144
103
|
reports.convertToOriginalStoryTableRow = function( scope, { row_data }) {
|
|
@@ -165,38 +124,34 @@ let trimJSON = function( str=`` ) {
|
|
|
165
124
|
}; // Ends trimJSON()
|
|
166
125
|
|
|
167
126
|
reports.getPrintableReport = function( scope ) {
|
|
168
|
-
/** Return a string generated from test report data.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
127
|
+
/** Return a string generated from test report data. */
|
|
128
|
+
let report = `Assembly Line Kiln Automated Testing Report - ${ (new Date()).toUTCString() }\n`;
|
|
129
|
+
|
|
130
|
+
// First list failed scenarios, then non-passed scenarios, then passed scenarios
|
|
131
|
+
let failed_reports = ``;
|
|
132
|
+
let passed_reports = ``;
|
|
133
|
+
let other_reports = ``;
|
|
134
|
+
for ( let scenario of scope.report ) {
|
|
135
|
+
|
|
136
|
+
let report = reports.getPrintableScenario( scenario );
|
|
137
|
+
let [ scenario_id, data ] = scenario;
|
|
138
|
+
if ( data.status === `FAILED` ) { failed_reports += report; }
|
|
139
|
+
else if ( data.status === `PASSED` ) { passed_reports += report; }
|
|
140
|
+
else { other_reports += report; }
|
|
141
|
+
}; // ends for every scenario
|
|
142
|
+
|
|
143
|
+
if ( failed_reports !== `` ) { report += `\n\n===============================\n===============================\n🤕 Failed scenarios:\n${ failed_reports }`; }
|
|
144
|
+
if ( other_reports !== `` ) { report += `\n\n===============================\n===============================\n🔎 Scenarios that did not pass:\n${ other_reports }`; }
|
|
145
|
+
if ( passed_reports !== `` ) { report += `\n\n===============================\n===============================\n🌈 Passed scenarios:\n${ passed_reports }`; }
|
|
178
146
|
|
|
179
147
|
return report;
|
|
180
148
|
}; // Ends reports.getPrintableReport()
|
|
181
149
|
|
|
182
|
-
reports.getTitle = function( scope ) { return this.title; }
|
|
183
|
-
|
|
184
|
-
reports.getPrintableUnexpected = function( scope ) {
|
|
185
|
-
// Note about `> 1`: The first line of the report section always exists
|
|
186
|
-
let output = ``;
|
|
187
|
-
if ( this.failures.length > 1 ) {
|
|
188
|
-
output += this.failures.join(``);
|
|
189
|
-
}
|
|
190
|
-
if ( this.others.length > 1 ) {
|
|
191
|
-
output += this.others.join(``);
|
|
192
|
-
}
|
|
193
|
-
return output;
|
|
194
|
-
}; // Ends reports.getPrintableUnexpected()
|
|
195
|
-
|
|
196
150
|
reports.getPrintableScenario = function( scenario ) {
|
|
197
151
|
/** Return a string generated from scenario list of report items. */
|
|
152
|
+
let [ scenario_id, data ] = scenario;
|
|
198
153
|
let report = ``;
|
|
199
|
-
for ( let line of
|
|
154
|
+
for ( let line of data.lines ) {
|
|
200
155
|
let { type, code, value } = line;
|
|
201
156
|
report += `${ getLineText({ type, code, value }) }\n`;
|
|
202
157
|
}
|
|
@@ -107,7 +107,7 @@ session_vars.get_languages = function () {
|
|
|
107
107
|
}; // Ends session_vars.get_languages()
|
|
108
108
|
|
|
109
109
|
|
|
110
|
-
const runtime_config_path = `runtime_config.json
|
|
110
|
+
const runtime_config_path = path.join(process.cwd(), `runtime_config.json`);
|
|
111
111
|
const project_name_key = `da_project_name`;
|
|
112
112
|
session_vars.save_project_name = function ( project_name ) {
|
|
113
113
|
/* Saves the name of the project to a json obj so deletion can use it later.
|
package/package.json
CHANGED