Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: test/_common.js

Issue 29616611: Issue 6090 - Allow use of console to be seen during tests (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Nov. 23, 2017, 7:19 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/filterStorage.js » ('j') | test/filterStorage.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 Cr, 412 Cr,
413 XMLHttpRequest, 413 XMLHttpRequest,
414 Date: { 414 Date: {
415 now: () => currentTime 415 now: () => currentTime
416 } 416 }
417 }; 417 };
418 }; 418 };
419 419
420 console.warn = console.log; 420 console.warn = console.log;
421 421
422 exports.maybeExpectError = function(msg, test)
sergei 2017/11/24 10:15:28 What about calling it `silenceAssertionOutput`?
sergei 2017/11/24 13:49:13 JIC, I also thought that we could want to actually
hub 2017/11/24 15:48:59 Done.
hub 2017/11/24 15:48:59 I thought about expecting the output but then I'd
423 {
424 let msgMatch = new RegExp(`^Error: ${msg}[\r\n]`);
425 let errorHandler = globals.console.error;
sergei 2017/11/24 10:15:28 I think it's OK taking into account that `console`
hub 2017/11/24 15:48:59 I'm missing a patch here where we actualle make co
426 globals.console.error = s =>
427 {
428 if (!msgMatch.test(s) && typeof errorHandler === "function")
sergei 2017/11/24 10:15:28 I think we should not test the type of errorHandle
hub 2017/11/24 15:48:59 Acknowledged.
429 errorHandler(s);
430 };
431 try
432 {
433 test();
sergei 2017/11/24 10:15:28 IMO we should return the result of `test()` for th
hub 2017/11/24 15:48:59 Acknowledged.
434 }
435 finally
436 {
437 globals.console.error = errorHandler;
438 }
439 };
440
422 exports.setupRandomResult = function() 441 exports.setupRandomResult = function()
423 { 442 {
424 let randomResult = 0.5; 443 let randomResult = 0.5;
425 Object.defineProperty(this, "randomResult", { 444 Object.defineProperty(this, "randomResult", {
426 get: () => randomResult, 445 get: () => randomResult,
427 set: value => randomResult = value 446 set: value => randomResult = value
428 }); 447 });
429 448
430 return { 449 return {
431 Math: Object.create(Math, { 450 Math: Object.create(Math, {
432 random: { 451 random: {
433 value: () => randomResult 452 value: () => randomResult
434 } 453 }
435 }) 454 })
436 }; 455 };
437 }; 456 };
438 457
439 exports.unexpectedError = function(error) 458 exports.unexpectedError = function(error)
440 { 459 {
441 console.error(error); 460 console.error(error);
442 this.ok(false, "Unexpected error: " + error); 461 this.ok(false, "Unexpected error: " + error);
443 }; 462 };
OLDNEW
« no previous file with comments | « no previous file | test/filterStorage.js » ('j') | test/filterStorage.js » ('J')

Powered by Google App Engine
This is Rietveld