1+ const path = require ( "path" ) ;
2+ const fs = require ( "fs" ) ;
3+
4+ const TestEnv = require ( "../../modules/integration-test/test-env.js" ) ;
5+
16
27class TestSuiteResult {
38
@@ -27,7 +32,7 @@ class TestSuiteResult {
2732
2833
2934 createTestSuiteResult ( ) {
30- // this.#createNewConfig();
35+ this . #createNewConfig( ) ;
3136 this . #testSuiteResults. TIME . END = Math . round ( Date . now ( ) / 1000 ) ;
3237 let duration = this . #testSuiteResults. TIME . END - this . #testSuiteResults. TIME . START ;
3338 this . #cnsl. log ( "\n" + "duration:" . padEnd ( 15 , " " ) + duration + "s" ) ;
@@ -44,54 +49,77 @@ class TestSuiteResult {
4449 this . #cnsl. log ( ( "tests failed:" . padEnd ( 15 , " " ) + this . #testSuiteResults. FAILED . length ) . error ) ;
4550 process . exitCode = 1 ;
4651 this . #testSuiteResults. FAILED . forEach ( testCase => {
47- this . #cnsl. log ( "" . padEnd ( this . #cnsl. getTestStatusPad ( ) + 5 , " " ) + testCase + " http://127.0.0.1:8080/test/integration/manual/?version=localhost&testCase=" + testCase ) ;
52+ this . #cnsl. log ( "" . padEnd ( this . #cnsl. getTestStatusPad ( ) + 5 , " " ) + path . relative ( TestEnv . getTestSuitePath ( ) , path . join ( TestEnv . getWorkspacePath ( ) , testCase ) ) + " http://127.0.0.1:8080/test/integration/manual/?version=localhost&testCase=" + testCase ) ;
4853 } ) ;
4954 } else {
5055 this . #cnsl. log ( "tests failed:" . padEnd ( 15 , " " ) + this . #testSuiteResults. FAILED . length ) ;
5156 }
5257 }
5358
5459
55- /* #createNewConfig() {
60+ #createNewConfig( ) {
5661 if ( this . #createHashes !== "DISABLED" ) {
57- if (this.#createHashes === "ALL" || (this.#createHashes === "FAILED" && (this.#testSuiteResults.FAILED.length !== 0 || this.#testSuiteResults.WARNING !== 0))) {
58- let hashesPath = path.join(TestEnv.getTestSuiteResultsPath(), path.basename(this.#testCasesHashListPath));
59- let rmReady = new Promise((resolve, reject) => {
60- fs.rm(hashesPath, { force: true }, err => {
61- if (err) {
62- return reject(err);
63- }
64- return resolve();
65- });
62+ if ( this . #createHashes === "ALL" || ( this . #createHashes === "FAILED" && ( this . #testSuiteResults. FAILED . length !== 0 || this . #testSuiteResults. WARNING . length !== 0 ) ) ) {
63+ let testCasesConfig = { } ;
64+ this . #testCasesConfig. suites . forEach ( suite => {
65+ let suitePath = "/" + path . relative ( TestEnv . getWorkspacePath ( ) , suite . suite ) ;
66+ testCasesConfig [ suitePath ] = { suite : suitePath , tmp : suite . config , test : { } } ;
6667 } ) ;
67- let mkdirReady = new Promise((resolve, reject) => {
68- fs.mkdir(TestEnv.getTestSuiteResultsPath(), { recursive: true }, err => {
69- if (err) {
70- return reject(err);
68+ for ( const [ key , value ] of Object . entries ( this . #testSuiteResults. RESULTS ) ) {
69+ if ( this . #createHashes === "FAILED" && ( ! this . #testSuiteResults. FAILED . includes ( key ) && ! this . #testSuiteResults. WARNING . includes ( key ) ) ) {
70+ continue ;
71+ }
72+ Object . keys ( testCasesConfig ) . forEach ( suite => {
73+ if ( key . startsWith ( suite ) ) {
74+ let testData = { } ;
75+ if ( this . #testSuiteResults. RESULTS [ key ] [ "animstep" ] ) {
76+ testData [ "animstep" ] = this . #testSuiteResults. RESULTS [ key ] [ "animstep" ] + "%" ;
77+ }
78+ testData [ "refs" ] = [ this . #testSuiteResults. RESULTS [ key ] [ 'hash' ] ]
79+ testCasesConfig [ suite ] . test [ path . relative ( suite , key ) ] = testData ;
7180 }
72- return resolve();
7381 } ) ;
74- });
75- Promise.all([rmReady, mkdirReady]).then(() => {
76- let testCasesData = {};
77- for (const [key, value] of Object.entries(this.#testSuiteResults.RESULTS)) {
78- if (this.#cfgCreateHashes === "FAILED" && (!this.#testSuiteResults.FAILED.includes(key) && !this.#testSuiteResults.WARNING.includes(key))) {
79- continue;
80- }
81- testCasesData[key] = { refs: [this.#testSuiteResults.RESULTS[key]['hash']] };
82+ }
83+
84+ for ( const [ key , value ] of Object . entries ( testCasesConfig ) ) {
85+ if ( Object . keys ( testCasesConfig [ key ] . test ) . length === 0 ) {
86+ continue ;
8287 }
83- if (Object.keys(testCasesData).length !== 0) {
84- testCasesData = JSON.stringify(testCasesData, null, 4);
85- fs.writeFile(hashesPath, testCasesData, (err) => {
88+ let conFigPath = path . join ( TestEnv . getTestSuiteResultsPath ( ) ,
89+ path . relative ( TestEnv . getTestSuitePath ( ) ,
90+ path . join ( TestEnv . getWorkspacePath ( ) ,
91+ key ) ) ,
92+ path . basename ( value . tmp ) ) ;
93+ let rmReady = new Promise ( ( resolve , reject ) => {
94+ fs . rm ( conFigPath , { force : true } , err => {
95+ if ( err ) {
96+ return reject ( err ) ;
97+ }
98+ return resolve ( ) ;
99+ } ) ;
100+ } ) ;
101+ let mkdirReady = new Promise ( ( resolve , reject ) => {
102+ fs . mkdir ( path . dirname ( conFigPath ) , { recursive : true } , err => {
103+ if ( err ) {
104+ return reject ( err ) ;
105+ }
106+ return resolve ( ) ;
107+ } ) ;
108+ } ) ;
109+ Promise . all ( [ rmReady , mkdirReady ] ) . then ( ( ) => {
110+ let configData = value ;
111+ delete configData . tmp ;
112+ configData = JSON . stringify ( configData , null , 4 ) ;
113+ fs . writeFile ( conFigPath , configData , ( err ) => {
86114 if ( err ) {
87115 throw err ;
88116 }
89117 } ) ;
90- }
91- });
118+ } ) ;
119+ }
92120 }
93121 }
94- }*/
122+ }
95123}
96124
97125
0 commit comments