How to use buildLogStream method in Best

Best JavaScript code snippet using best

svn_adapter.spec.js

Source:svn_adapter.spec.js Github

copy

Full Screen

...148 });149 describe('.logStream()', function() {150 it('returns the svn log as a stream', function() {151 return new Bluebird(function(done) {152 buildLogStream('LOG_OUTPUT');153 var result = '';154 subject.logStream(timePeriod)155 .on('data', function(chunk) {156 result += chunk.toString();157 })158 .on('end', function() {159 expect(result).toEqual('LOG_OUTPUT');160 done();161 });162 expect(command.stream).toHaveBeenCalledWith('svn',163 ['log', '-v', '--xml', '-r{2015-08-22T14:51:42.123Z}:{2015-10-12T11:10:06.456Z}'], {cwd: '/root/dir'});164 });165 });166 });167 describe('.commitMessagesStream()', function() {168 it('returns the svn commit messages as a stream', function() {169 return new Bluebird(function(done) {170 buildLogStream(GENERIC_LOG_OUTPUT);171 var result = '';172 subject.commitMessagesStream(timePeriod)173 .on('data', function(chunk) {174 result += chunk.toString();175 })176 .on('end', function() {177 expect(result).toEqual('test message 123\ntest message 456\ntest message 789\n');178 done();179 });180 expect(command.stream).toHaveBeenCalledWith('svn',181 ['log', '-v', '--xml', '-r{2015-08-22T14:51:42.123Z}:{2015-10-12T11:10:06.456Z}'], {cwd: '/root/dir'});182 });183 });184 it('throws an error if the stream ends before the xml document is complete', function() {185 return expect(new Bluebird(function(resolve, reject) {186 buildLogStream(CORRUPTED_LOG_OUTPUT);187 subject.commitMessagesStream(timePeriod)188 .on('error', reject);189 })).rejects.toMatch('xml parsing');190 });191 });192 describe('.showRevisionStream()', function() {193 it('returns the svn revision content as a stream', function() {194 command.stream.mockReturnValue('output-stream');195 var output = subject.showRevisionStream('qwe123', 'test/file');196 expect(output).toEqual('output-stream');197 expect(command.stream).toHaveBeenCalledWith('svn', ['cat', '-r', 'qwe123', 'test/file'], {cwd: '/root/dir'});198 });199 });200 describe('.revisions()', function() {...

Full Screen

Full Screen

build-benchmark.ts

Source:build-benchmark.ts Github

copy

Full Screen

1/*2 * Copyright (c) 2019, salesforce.com, inc.3 * All rights reserved.4 * SPDX-License-Identifier: MIT5 * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT6*/7import fs from 'fs';8import { rollup, OutputOptions } from 'rollup';9import path from 'path';10import crypto from 'crypto';11import mkdirp from "mkdirp";12import benchmarkRollup from './rollup-plugin-benchmark-import';13import generateHtml from './html-templating';14import { FrozenGlobalConfig, FrozenProjectConfig, ProjectConfigPlugin, BuildConfig } from '@best/types';15import { req } from '@best/utils';16const BASE_ROLLUP_OUTPUT: OutputOptions = { format: 'iife' };17const ROLLUP_CACHE = new Map();18function md5(data: string) {19 return crypto.createHash('md5').update(data).digest('hex');20}21function addResolverPlugins(plugins: ProjectConfigPlugin[]): any[] {22 if (!plugins) {23 return [];24 }25 return plugins.map((plugin: ProjectConfigPlugin) => {26 if (typeof plugin === 'string') {27 return req(plugin)();28 } else if (Array.isArray(plugin)) {29 return req(plugin[0])(plugin[1]);30 } else {31 throw new Error('Invalid plugin config');32 }33 });34}35interface BuildOutputMessager {36 onBenchmarkBuildStart(benchmarkPath: string): void;37 onBenchmarkBuildEnd(benchmarkPath: string): void;38 log(message: string): void;39}40export async function buildBenchmark(entry: string, projectConfig: FrozenProjectConfig, globalConfig: FrozenGlobalConfig, buildLogStream: BuildOutputMessager): Promise<BuildConfig> {41 buildLogStream.onBenchmarkBuildStart(entry);42 const { gitInfo: { lastCommit: { hash: gitHash }, localChanges } } = globalConfig;43 const { projectName, benchmarkOutput } = projectConfig;44 const ext = path.extname(entry);45 const benchmarkName = path.basename(entry, ext);46 const benchmarkJSFileName = benchmarkName + ext;47 const benchmarkProjectFolder = path.join(benchmarkOutput, projectName);48 buildLogStream.log('Bundling benchmark files...');49 const bundle = await rollup({50 input: entry,51 plugins: [benchmarkRollup(), ...addResolverPlugins(projectConfig.plugins)],52 cache: ROLLUP_CACHE.get(projectName),53 manualChunks: function () { /* guarantee one chunk */ return 'main_chunk'; },54 onwarn(warning, warn) {55 // Make compilation fail, if any bare module can't be resolved.56 if (typeof warning === 'object' && warning.code === 'UNRESOLVED_IMPORT') {57 throw new Error(warning.message);58 }59 warn(warning);60 }61 });62 ROLLUP_CACHE.set(projectName, bundle.cache);63 buildLogStream.log('Generating benchmark artifacts...');64 const { output } = await bundle.generate(BASE_ROLLUP_OUTPUT);65 const benchmarkSource = output[0].code; // We don't do code splitting so the first one will be the one we want66 // Benchmark artifacts vars67 const benchmarkSignature = md5(benchmarkSource);68 const benchmarkSnapshotName = localChanges ? `${benchmarkName}_local_${benchmarkSignature.slice(0, 10)}` : `${benchmarkName}_${gitHash}`;69 const benchmarkFolder = path.join(benchmarkProjectFolder, benchmarkSnapshotName);70 const benchmarkArtifactsFolder = path.join(benchmarkFolder, 'artifacts');71 const benchmarkEntry = path.join(benchmarkArtifactsFolder, `${benchmarkName}.html`);72 const htmlTemplate = generateHtml({ benchmarkName, benchmarkJs: `./${benchmarkJSFileName}` });73 mkdirp.sync(benchmarkArtifactsFolder);74 fs.writeFileSync(benchmarkEntry, htmlTemplate, 'utf-8');75 fs.writeFileSync(path.join(benchmarkArtifactsFolder, benchmarkJSFileName), benchmarkSource, 'utf-8');76 buildLogStream.onBenchmarkBuildEnd(entry);77 return {78 benchmarkName,79 benchmarkFolder,80 benchmarkEntry,81 benchmarkSignature,82 projectConfig,83 globalConfig,84 };...

Full Screen

Full Screen

index.ts

Source:index.ts Github

copy

Full Screen

1/*2 * Copyright (c) 2019, salesforce.com, inc.3 * All rights reserved.4 * SPDX-License-Identifier: MIT5 * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT6*/7import { FrozenGlobalConfig, FrozenProjectConfig, BuildConfig } from '@best/types';8import { BuildOutputStream } from "@best/console-stream";9import { isCI } from '@best/utils';10import workerFarm from "worker-farm";11import { buildBenchmark } from "./build-benchmark"12const DEFAULT_FARM_OPTS = {13 maxConcurrentWorkers: isCI ? 2 : require('os').cpus().length,14 maxConcurrentCallsPerWorker: 1,15};16interface ChildMessage { type: string, benchmarkPath: string, message: string }17async function runInBand(benchmarks: string[], projectConfig: FrozenProjectConfig, globalConfig: FrozenGlobalConfig, buildLogStream: BuildOutputStream): Promise<BuildConfig[]> {18 const benchmarkResults: BuildConfig[] = [];19 for (const benchmark of benchmarks) {20 const result = await buildBenchmark(benchmark,projectConfig, globalConfig, buildLogStream);21 benchmarkResults.push(result);22 }23 return benchmarkResults;24}25function runInWorkers(benchmarks: string[], projectConfig: FrozenProjectConfig, globalConfig: FrozenGlobalConfig, buildLogStream: BuildOutputStream): Promise<BuildConfig[]> {26 const opts = {27 ...DEFAULT_FARM_OPTS,28 onChild: (child: NodeJS.Process) => {29 child.on("message", (message: ChildMessage) => {30 if (message.type === 'messager.onBenchmarkBuildStart') {31 buildLogStream.onBenchmarkBuildStart(message.benchmarkPath);32 } else if (message.type === 'messager.log') {33 buildLogStream.log(message.message);34 } else if (message.type === 'messager.onBenchmarkBuildEnd') {35 buildLogStream.onBenchmarkBuildEnd(message.benchmarkPath);36 }37 })38 }39 };40 const workers = workerFarm(opts, require.resolve('./build-benchmark-worker'));41 const jobs = benchmarks.length;42 let jobsCompleted = 0;43 const benchBuild: BuildConfig[] = [];44 return new Promise((resolve, reject) => {45 benchmarks.forEach(benchmark => {46 const buildInfo = {47 benchmark,48 projectConfig,49 globalConfig50 };51 workers(buildInfo, (err: any, result: BuildConfig) => {52 if (err) {53 return reject(err);54 }55 benchBuild.push(result);56 if (++jobsCompleted === jobs) {57 workerFarm.end(workers);58 resolve(benchBuild);59 }60 });61 });62 });63}64export function buildBenchmarks(benchmarks: string[], projectConfig: FrozenProjectConfig, globalConfig: FrozenGlobalConfig, buildLogStream: BuildOutputStream): Promise<BuildConfig[]> {65 if (globalConfig.runInBand) {66 return runInBand(benchmarks, projectConfig, globalConfig, buildLogStream);67 } else {68 return runInWorkers(benchmarks, projectConfig, globalConfig, buildLogStream);69 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestPractice = require('./BestPractice.js');2var bp = new BestPractice();3var logStream = bp.buildLogStream();4logStream.on('data', function(data) {5console.log(data);6});7logStream.on('end', function() {8console.log('End of stream');9});10logStream.on('error', function(err) {11console.log('Error', err);12});13var fs = require('fs');14var path = require('path');15var util = require('util');16var Transform = require('stream').Transform;17var BestPractice = function() {};18util.inherits(BestPractice, Transform);19BestPractice.prototype.buildLogStream = function() {20var logStream = fs.createReadStream(path.join(__dirname, 'test.log'), { encoding: 'utf8' });21logStream = logStream.pipe(new BestPractice());22return logStream;23};24BestPractice.prototype._transform = function(chunk, encoding, callback) {25var data = chunk.toString();26var lines = data.split('27');28var self = this;29lines.forEach(function(line) {30var log = JSON.parse(line);31var msg = {32};33self.push(JSON.stringify(msg));34});35callback();36};37module.exports = BestPractice;38{"timestamp": "2016-01-01T00:00:00.000Z", "message": "This is a test"}39{"timestamp": "2016-01-01T00:00:01.000Z", "message": "This is another test"}40{"timestamp":"2016-01-01T00:00:00.000Z","message":"This is a test"}41{"timestamp":"2016-01-01T00:00:01.000Z","message":"This is another test"}

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestLogStreamBuilder = require('best-log-stream-builder');2var builder = new BestLogStreamBuilder();3var logStream = builder.buildLogStream('test4.log');4logStream.write('Hello World');5logStream.end();6var BestLogStreamBuilder = require('best-log-stream-builder');7var builder = new BestLogStreamBuilder();8var logStream = builder.buildLogStream('test5.log');9logStream.write('Hello World');10logStream.end();11var BestLogStreamBuilder = require('best-log-stream-builder');12var builder = new BestLogStreamBuilder();13var logStream = builder.buildLogStream('test6.log');14logStream.write('Hello World');15logStream.end();16var BestLogStreamBuilder = require('best-log-stream-builder');17var builder = new BestLogStreamBuilder();18var logStream = builder.buildLogStream('test7.log');19logStream.write('Hello World');20logStream.end();21var BestLogStreamBuilder = require('best-log-stream-builder');22var builder = new BestLogStreamBuilder();23var logStream = builder.buildLogStream('test8.log');24logStream.write('Hello World');25logStream.end();26var BestLogStreamBuilder = require('best-log-stream-builder');27var builder = new BestLogStreamBuilder();28var logStream = builder.buildLogStream('test9.log');29logStream.write('Hello World');30logStream.end();31var BestLogStreamBuilder = require('best-log-stream-builder');32var builder = new BestLogStreamBuilder();33var logStream = builder.buildLogStream('test10.log');34logStream.write('Hello World');35logStream.end();36var BestLogStreamBuilder = require('best-log-stream-builder');37var builder = new BestLogStreamBuilder();

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestLogger = require('./BestLogger');2var logger = new BestLogger();3logger.buildLogStream('test4.log', function(err, stream){4 if(err) {5 console.log('Error: ' + err);6 return;7 }8 stream.write('test');9});10var BestLogger = require('./BestLogger');11var logger = new BestLogger();12logger.buildLogStream('test5.log', function(err, stream){13 if(err) {14 console.log('Error: ' + err);15 return;16 }17 stream.write('test');18});19var BestLogger = require('./BestLogger');20var logger = new BestLogger();21logger.buildLogStream('test6.log', function(err, stream){22 if(err) {23 console.log('Error: ' + err);24 return;25 }26 stream.write('test');27});28var BestLogger = require('./BestLogger');29var logger = new BestLogger();30logger.buildLogStream('test7.log', function(err, stream){31 if(err) {32 console.log('Error: ' + err);33 return;34 }35 stream.write('test');36});37var BestLogger = require('./BestLogger');38var logger = new BestLogger();39logger.buildLogStream('test8.log', function(err, stream){40 if(err) {41 console.log('Error: ' + err);42 return;43 }44 stream.write('test');45});46var BestLogger = require('./BestLogger');47var logger = new BestLogger();48logger.buildLogStream('test9.log', function(err, stream){49 if(err) {50 console.log('Error: ' + err);51 return;52 }53 stream.write('test');54});55var BestLogger = require('./BestLogger');56var logger = new BestLogger();57logger.buildLogStream('test10.log', function(err, stream){58 if(err) {59 console.log('Error:

Full Screen

Using AI Code Generation

copy

Full Screen

1const BestLog = require('./bestLog');2const bestLog = new BestLog();3const logStream = bestLog.buildLogStream();4logStream.on('data', (data) => {5console.log(data);6});7logStream.on('end', () => {8console.log('End of the logs');9});10const BestLog = require('./bestLog');11const bestLog = new BestLog();12const logStream = bestLog.buildLogStream();13logStream.on('data', (data) => {14console.log(data);15});16logStream.on('end', () => {17console.log('End of the logs');18});19const BestLog = require('./bestLog');20const bestLog = new BestLog();21const logStream = bestLog.buildLogStream();22logStream.on('data', (data) => {23console.log(data);24});25logStream.on('end', () => {26console.log('End of the logs');27});28const BestLog = require('./bestLog');29const bestLog = new BestLog();30const logStream = bestLog.buildLogStream();31logStream.on('data', (data) => {32console.log(data);33});34logStream.on('end', () => {35console.log('End of the logs');36});37const BestLog = require('./bestLog');38const bestLog = new BestLog();39const logStream = bestLog.buildLogStream();40logStream.on('data', (data) => {41console.log(data);42});43logStream.on('end', () => {44console.log('End of the logs');45});

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestLogger = require('./bestLogger.js');2var logger = new BestLogger();3var stream = logger.buildLogStream('test4.log');4stream.write('This is a test of the log stream');5stream.end();6var fs = require('fs');7fs.readFile('test4.log', function(err, data) {8 if (err) {9 console.log(err);10 } else {11 console.log(data.toString());12 }13});14var BestLogger = require('./bestLogger.js');15var logger = new BestLogger();16var stream = logger.buildLogStream('test5.log');17stream.write('This is a test of the log stream');18stream.end();19var fs = require('fs');20fs.createReadStream('test5.log').pipe(process.stdout);21var BestLogger = require('./bestLogger.js');22var logger = new BestLogger();23var stream = logger.buildLogStream('test6.log');24stream.write('This is a test of the log stream');25stream.end();26var fs = require('fs');27fs.createReadStream('test6.log').pipe(fs.createWriteStream('test6-2.log'));28var BestLogger = require('./bestLogger.js');29var logger = new BestLogger();30var stream = logger.buildLogStream('test7.log');31stream.write('This is a test of the log stream');32stream.end();33var fs = require('fs');34fs.createReadStream('test7.log').pipe(fs.createWriteStream('test7-2.log')).pipe(process.stdout);

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestLogger = require('best-logger');2var logger = new BestLogger();3var logStream = logger.buildLogStream();4logStream.pipe(process.stdout);5logger.log("message 1");6logger.log("message 2");7logger.log("message 3");8logger.log({message: "message 4", data: "data 1"});9logger.log(new Error("message 5"));10logger.log("message 6", "alert");11logger.log({message: "message 7", data: "data 2"}, "alert");12logger.log(new Error("message 8"), "alert");13logger.log("message 9", "alert", true);14logger.log({message: "message 10", data: "data 3"}, "alert", true);15logger.log(new Error("message 11"), "alert", true);16logger.log("message 12", "alert", true, "json");17logger.log({message: "message 13", data: "data 4"}, "alert", true, "json");18logger.log(new Error("message 14"), "alert", true, "json");19logger.log("message 15", "alert", true, "text");20logger.log({message: "message 16", data: "data 5"}, "alert", true, "text");21logger.log(new Error("message 17"), "alert", true,

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestLog = require('./BestLog');2var log = new BestLog();3var stream = log.buildLogStream();4stream.on('data', function(data){5 console.log(data);6});7stream.on('error', function(err){8 console.log(err);9});10stream.on('end', function(){11 console.log('End of stream');12});13{ filename: 'log2014-05-30.txt',142014-05-30 10:00:01, info, everything is ok' }15{ filename: 'log2014-05-31.txt',162014-05-31 10:00:01, info, everything is ok' }17{ filename: 'log2014-06-01.txt',182014-06-01 10:00:01, info, everything is ok' }19{ filename: 'log2014-06-02.txt',202014-06-02 10:00:01, info, everything is ok' }21var BestLog = require('./BestLog');

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Best automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful