From 992e9e79afa39d553e518bf6cae57736a8971f37 Mon Sep 17 00:00:00 2001 From: Jan Kobersky Date: Mon, 9 Sep 2024 12:06:22 +0200 Subject: [PATCH] Adding comments --- gulpfile.js | 16 +++++++++++++++ test-listener.js | 40 +++++++++++++++++++++++++++++-------- testapp-cordova/gulpfile.js | 16 +++++++++++++++ 3 files changed, 64 insertions(+), 8 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 8e58a86..bb2b931 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,3 +1,19 @@ +// +// Copyright 2024 Wultra s.r.o. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + // Dependencies const gulp = require("gulp"); // gulp itself const ts = require("gulp-typescript"); // to be able to compiles typescript diff --git a/test-listener.js b/test-listener.js index a890a48..3d3df64 100644 --- a/test-listener.js +++ b/test-listener.js @@ -1,19 +1,42 @@ +// +// Copyright 2024 Wultra s.r.o. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// #################### +// #### Test listener is a node.js script that is running a HTTP server that recieves data from test application. +// #### Based on the data, it can either exit with success or error to give a hint that test ended up as a success or a failure. +// #################### + const http = require('http'); const { exit } = require('process'); const port = 8083 -const maxDurationSeconds = 150 +const maxDurationSeconds = 180 // Test aer usually taking 60-90 seconds -console.log(`Starting test listener @ localhost ${port}`) -console.log(`If the test wont finish in ${maxDurationSeconds} seconds, this script will exit with error exit code`) +console.log(`Starting test listener @ localhost:${port}`) +console.log(`If the tests won't finish in ${maxDurationSeconds} seconds, this script will exit with the error exit code.`) +// Fail-safe in case the test won't finish so we don't wait indefinitely setTimeout(() => { - console.log("Tick time, time for test run out, exiting with 1"); + console.log(`Tick tock, time for tests run out (${maxDurationSeconds} seconds). Exiting with the error code.`); exit(1); }, maxDurationSeconds * 1000); http.createServer(function (req, res) { + // the app is sending the status report in the `reportStatus` endpoint. const isStatusReport = req.url.endsWith("reportStatus"); let body = ''; @@ -21,16 +44,17 @@ http.createServer(function (req, res) { body += chunk; }); req.on('end', () => { - console.log(body); + + console.log(body); // print whatever came from the server if (isStatusReport) { const report = JSON.parse(body); if (report.total == report.progress) { // all tests finished if (report.failed == 0) { - console.log("Finished with success - exit") + console.log("Tests went OK - exiting with the success code.") exit(0) } else { - console.log("Finished with failures - error exit") + console.log("Some tests failed - exiting with the error code.") exit(1) } } @@ -39,4 +63,4 @@ http.createServer(function (req, res) { res.write('OK'); res.end(); }); - }).listen(port); \ No newline at end of file + }).listen(port); diff --git a/testapp-cordova/gulpfile.js b/testapp-cordova/gulpfile.js index 3a92c2c..bc94819 100644 --- a/testapp-cordova/gulpfile.js +++ b/testapp-cordova/gulpfile.js @@ -1,3 +1,19 @@ +// +// Copyright 2024 Wultra s.r.o. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + const gulp = require("gulp"); const replace = require('gulp-replace'); const { build } = require("esbuild");