Skip to content

Commit 0426347

Browse files
author
Piotr Puszkiewicz
committed
Add log folding in Travis CI
1 parent 91164bd commit 0426347

File tree

6 files changed

+49
-8
lines changed

6 files changed

+49
-8
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ install.*
1212

1313
obj/
1414
bin/
15-
test/**/.vscode
15+
test/**/.vscode
16+
.logs/

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ install:
3333
script:
3434
- npm test --silent
3535

36+
after_failure:
37+
- ./.travis/printLogs.sh
38+
39+
after_success:
40+
- ./.travis/printLogs.sh
41+
3642
deploy:
3743
provider: releases
3844
api_key:

.travis/printLogs.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# ---------------------------------------------------------------------------------------------
4+
# Copyright (c) Microsoft Corporation. All rights reserved.
5+
# Licensed under the MIT License. See License.txt in the project root for license information.
6+
# --------------------------------------------------------------------------------------------
7+
8+
fold_start() {
9+
echo -e "travis_fold:start:$1\033[33;1m$2\033[0m"
10+
}
11+
12+
fold_end() {
13+
echo -e "\ntravis_fold:end:$1\r"
14+
}
15+
16+
fold_start testLogs "Test Logs"
17+
18+
for f in ./.logs/*.log
19+
do
20+
fold_start logFile $f
21+
cat $f
22+
fold_end logFile
23+
done
24+
25+
fold_end testLogs

src/logger.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
5+
56
let Subscriber: (message: string) => void;
67

78
export function SubscribeToAllLoggers(subscriber: (message:string) => void) {

test/integrationTests/index.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import * as fs from "fs";
7+
68
import { SubscribeToAllLoggers } from "../../src/logger";
9+
710
//
811
// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
912
//
@@ -16,7 +19,7 @@ import { SubscribeToAllLoggers } from "../../src/logger";
1619
// to report the results back to the caller. When the tests are finished, return
1720
// a possible error to the callback or null if none.
1821

19-
var testRunner = require('vscode/lib/testrunner');
22+
let testRunner = require('vscode/lib/testrunner');
2023

2124
// You can directly control Mocha options by uncommenting the following lines
2225
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
@@ -27,6 +30,14 @@ testRunner.configure({
2730
useColors: true // colored output from test results
2831
});
2932

30-
SubscribeToAllLoggers(message => console.log(message));
33+
if (process.env.OSVC_SUITE) {
34+
if (!fs.existsSync("./.logs")) {
35+
fs.mkdirSync("./.logs");
36+
}
37+
38+
let logFilePath = `./.logs/${process.env.OSVC_SUITE}.log`;
39+
40+
SubscribeToAllLoggers(message => fs.appendFileSync(logFilePath, message));
41+
}
3142

3243
module.exports = testRunner;

test/unitTests/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { SubscribeToAllLoggers } from "../../src/logger";
76
//
87
// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
98
//
@@ -16,7 +15,7 @@ import { SubscribeToAllLoggers } from "../../src/logger";
1615
// to report the results back to the caller. When the tests are finished, return
1716
// a possible error to the callback or null if none.
1817

19-
var testRunner = require('vscode/lib/testrunner');
18+
let testRunner = require('vscode/lib/testrunner');
2019

2120
// You can directly control Mocha options by uncommenting the following lines
2221
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
@@ -27,6 +26,4 @@ testRunner.configure({
2726
useColors: true // colored output from test results
2827
});
2928

30-
SubscribeToAllLoggers(message => console.log(message));
31-
32-
module.exports = testRunner;
29+
module.exports = testRunner;

0 commit comments

Comments
 (0)