How to use logAboutUselessPatterns method in stryker-parent

Best JavaScript code snippet using stryker-parent

input-file-resolver.ts

Source:input-file-resolver.ts Github

copy

Full Screen

1import path from 'path';2import { promises as fsPromises } from 'fs';3import { isDeepStrictEqual } from 'util';4import { from, lastValueFrom } from 'rxjs';5import { filter, map, mergeMap, toArray } from 'rxjs/operators';6import { File, StrykerOptions, MutationRange } from '@stryker-mutator/api/core';7import { Logger } from '@stryker-mutator/api/logging';8import { commonTokens, tokens } from '@stryker-mutator/api/plugin';9import { SourceFile } from '@stryker-mutator/api/report';10import { isErrnoException, notEmpty } from '@stryker-mutator/util';11import { IMinimatch, Minimatch } from 'minimatch';12import { coreTokens } from '../di';13import { StrictReporter } from '../reporters/strict-reporter';14import { MAX_CONCURRENT_FILE_IO } from '../utils/file-utils';15import { defaultOptions } from '../config/options-validator';16import { FileMatcher } from '../config';17import { InputFileCollection } from './input-file-collection';18function toReportSourceFile(file: File): SourceFile {19 return {20 content: file.textContent,21 path: file.name,22 };23}24const ALWAYS_IGNORE = Object.freeze(['node_modules', '.git', '/reports', '*.tsbuildinfo', '/stryker.log']);25export const IGNORE_PATTERN_CHARACTER = '!';26export const MUTATION_RANGE_REGEX = /(.*?):((\d+)(?::(\d+))?-(\d+)(?::(\d+))?)$/;27export class InputFileResolver {28 private readonly mutatePatterns: readonly string[];29 private readonly ignoreRules: readonly string[];30 public static inject = tokens(commonTokens.logger, commonTokens.options, coreTokens.reporter);31 constructor(private readonly log: Logger, { mutate, tempDirName, ignorePatterns }: StrykerOptions, private readonly reporter: StrictReporter) {32 this.mutatePatterns = mutate;33 this.ignoreRules = [...ALWAYS_IGNORE, tempDirName, ...ignorePatterns];34 }35 public async resolve(): Promise<InputFileCollection> {36 const inputFileNames = await this.resolveInputFiles();37 const mutateFiles = this.resolveMutateFiles(inputFileNames);38 const mutationRange = this.resolveMutationRange();39 const files: File[] = await this.readFiles(inputFileNames);40 const inputFileCollection = new InputFileCollection(files, mutateFiles, mutationRange);41 this.reportAllSourceFilesRead(files);42 inputFileCollection.logFiles(this.log, this.ignoreRules);43 return inputFileCollection;44 }45 private resolveMutateFiles(inputFileNames: string[]) {46 return this.filterPatterns(inputFileNames, this.mutatePatterns, !isDeepStrictEqual(this.mutatePatterns, defaultOptions().mutate));47 }48 private resolveMutationRange(): MutationRange[] {49 return this.mutatePatterns50 .map((fileToMutate) => MUTATION_RANGE_REGEX.exec(fileToMutate))51 .filter(notEmpty)52 .map(([_, fileName, _mutationRange, startLine, startColumn = '0', endLine, endColumn = Number.MAX_SAFE_INTEGER.toString()]) => {53 return {54 fileName: path.resolve(fileName),55 start: { line: parseInt(startLine) - 1, column: parseInt(startColumn) },56 end: { line: parseInt(endLine) - 1, column: parseInt(endColumn) },57 };58 });59 }60 /**61 * Takes a list of globbing patterns and expands them into files.62 * If a patterns starts with a `!`, it negates the pattern.63 * @param fileNames the file names to filter64 * @param patterns The patterns to expand into files65 * @param logAboutUselessPatterns Weather or not to log about useless patterns66 */67 private filterPatterns(fileNames: readonly string[], patterns: readonly string[], logAboutUselessPatterns: boolean): string[] {68 const fileSet = new Set<string>();69 for (const pattern of patterns) {70 if (pattern.startsWith(IGNORE_PATTERN_CHARACTER)) {71 const files = this.filterPattern(fileSet, pattern.substr(1));72 if (logAboutUselessPatterns && files.length === 0) {73 this.log.warn(`Glob pattern "${pattern}" did not exclude any files.`);74 }75 files.forEach((fileName) => fileSet.delete(fileName));76 } else {77 const files = this.filterPattern(fileNames, pattern);78 if (logAboutUselessPatterns && files.length === 0) {79 this.log.warn(`Glob pattern "${pattern}" did not result in any files.`);80 }81 files.forEach((fileName) => fileSet.add(fileName));82 }83 }84 return Array.from(fileSet);85 }86 private filterPattern(fileNames: Iterable<string>, pattern: string): string[] {87 if (MUTATION_RANGE_REGEX.exec(pattern)) {88 pattern = pattern.replace(MUTATION_RANGE_REGEX, '$1');89 }90 const matcher = new FileMatcher(pattern);91 const filteredFileNames = [...fileNames].filter((fileName) => matcher.matches(fileName));92 return filteredFileNames;93 }94 private async resolveInputFiles(): Promise<string[]> {95 const ignoreRules = this.ignoreRules.map((pattern) => new Minimatch(pattern, { dot: true, flipNegate: true, nocase: true }));96 /**97 * Rewrite of: https://github.com/npm/ignore-walk/blob/0e4f87adccb3e16f526d2e960ed04bdc77fd6cca/index.js#L213-L21598 */99 const matchesDirectoryPartially = (entryPath: string, rule: IMinimatch) => {100 // @ts-expect-error Missing overload in type definitions. See https://github.com/isaacs/minimatch/issues/134101 return rule.match(`/${entryPath}`, true) || rule.match(entryPath, true);102 };103 // Inspired by https://github.com/npm/ignore-walk/blob/0e4f87adccb3e16f526d2e960ed04bdc77fd6cca/index.js#L124104 const matchesDirectory = (entryName: string, entryPath: string, rule: IMinimatch) => {105 return (106 matchesFile(entryName, entryPath, rule) ||107 rule.match(`/${entryPath}/`) ||108 rule.match(`${entryPath}/`) ||109 (rule.negate && matchesDirectoryPartially(entryPath, rule))110 );111 };112 // Inspired by https://github.com/npm/ignore-walk/blob/0e4f87adccb3e16f526d2e960ed04bdc77fd6cca/index.js#L123113 const matchesFile = (entryName: string, entryPath: string, rule: IMinimatch) => {114 return rule.match(entryName) || rule.match(entryPath) || rule.match(`/${entryPath}`);115 };116 const crawlDir = async (dir: string, rootDir = dir): Promise<string[]> => {117 const dirEntries = await fsPromises.readdir(dir, { withFileTypes: true });118 const relativeName = path.relative(rootDir, dir);119 const files = await Promise.all(120 dirEntries121 .filter((dirEntry) => {122 let included = true;123 const entryPath = `${relativeName.length ? `${relativeName}/` : ''}${dirEntry.name}`;124 ignoreRules.forEach((rule) => {125 if (rule.negate !== included) {126 const match = dirEntry.isDirectory() ? matchesDirectory(dirEntry.name, entryPath, rule) : matchesFile(dirEntry.name, entryPath, rule);127 if (match) {128 included = rule.negate;129 }130 }131 });132 return included;133 })134 .map(async (dirent) => {135 if (dirent.isDirectory()) {136 return crawlDir(path.resolve(rootDir, relativeName, dirent.name), rootDir);137 } else {138 return path.resolve(rootDir, relativeName, dirent.name);139 }140 })141 );142 return files.flat();143 };144 const files = await crawlDir(process.cwd());145 return files;146 }147 private reportAllSourceFilesRead(allFiles: File[]) {148 this.reporter.onAllSourceFilesRead(allFiles.map(toReportSourceFile));149 }150 private reportSourceFilesRead(textFile: File) {151 this.reporter.onSourceFileRead(toReportSourceFile(textFile));152 }153 private async readFiles(fileNames: string[]): Promise<File[]> {154 const files$ = from(fileNames).pipe(155 mergeMap((fileName) => {156 return this.readFile(fileName);157 }, MAX_CONCURRENT_FILE_IO),158 filter(notEmpty),159 toArray(),160 // Filter the files here, so we force a deterministic instrumentation process161 map((files) => files.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0)))162 );163 return lastValueFrom(files$);164 }165 private async readFile(fileName: string): Promise<File | null> {166 try {167 const content = await fsPromises.readFile(fileName);168 const file = new File(fileName, content);169 this.reportSourceFilesRead(file);170 return file;171 } catch (error) {172 if (isErrnoException(error) && (error.code === 'ENOENT' || error.code === 'EISDIR')) {173 return null; // file is deleted or a directory.174 } else {175 // Rethrow176 throw error;177 }178 }179 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var strykerParent = require('stryker-parent');2strykerParent.logAboutUselessPatterns();3var strykerParent = require('stryker-parent');4strykerParent.logAboutUselessPatterns();5var strykerParent = require('stryker-parent');6strykerParent.logAboutUselessPatterns();7var strykerParent = require('stryker-parent');8strykerParent.logAboutUselessPatterns();9var strykerParent = require('stryker-parent');10strykerParent.logAboutUselessPatterns();11var strykerParent = require('stryker-parent');12strykerParent.logAboutUselessPatterns();13var strykerParent = require('stryker-parent');14strykerParent.logAboutUselessPatterns();15var strykerParent = require('stryker-parent');16strykerParent.logAboutUselessPatterns();17var strykerParent = require('stryker-parent');18strykerParent.logAboutUselessPatterns();19var strykerParent = require('stryker-parent');20strykerParent.logAboutUselessPatterns();21var strykerParent = require('stryker-parent');22strykerParent.logAboutUselessPatterns();23var strykerParent = require('stryker-parent');24strykerParent.logAboutUselessPatterns();

Full Screen

Using AI Code Generation

copy

Full Screen

1var logAboutUselessPatterns = require('stryker-parent').logAboutUselessPatterns;2logAboutUselessPatterns();3var logAboutUselessPatterns = require('stryker-parent').logAboutUselessPatterns;4logAboutUselessPatterns();5var logAboutUselessPatterns = require('stryker-parent').logAboutUselessPatterns;6logAboutUselessPatterns();7var logAboutUselessPatterns = require('stryker-parent').logAboutUselessPatterns;8logAboutUselessPatterns();9var logAboutUselessPatterns = require('stryker-parent').logAboutUselessPatterns;10logAboutUselessPatterns();11var logAboutUselessPatterns = require('stryker-parent').logAboutUselessPatterns;12logAboutUselessPatterns();13var logAboutUselessPatterns = require('stryker-parent').logAboutUselessPatterns;14logAboutUselessPatterns();15var logAboutUselessPatterns = require('stryker-parent').logAboutUselessPatterns;16logAboutUselessPatterns();17var logAboutUselessPatterns = require('stryker-parent').logAboutUselessPatterns;18logAboutUselessPatterns();19var logAboutUselessPatterns = require('stryker-parent').logAboutUselessPatterns;20logAboutUselessPatterns();21var logAboutUselessPatterns = require('stryker-parent').logAboutUselessPatterns;22logAboutUselessPatterns();

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = function(config) {2 config.set({3 mochaOptions: {4 },5 htmlReporter: {6 }7 });8};

Full Screen

Using AI Code Generation

copy

Full Screen

1const { logAboutUselessPatterns } = require('stryker-parent');2logAboutUselessPatterns();3const { logAboutUselessPatterns } = require('stryker-parent');4logAboutUselessPatterns();5const { logAboutUselessPatterns } = require('stryker-parent');6logAboutUselessPatterns();7const { logAboutUselessPatterns } = require('stryker-parent');8logAboutUselessPatterns();9const { logAboutUselessPatterns } = require('stryker-parent');10logAboutUselessPatterns();11const { logAboutUselessPatterns } = require('stryker-parent');12logAboutUselessPatterns();13const { logAboutUselessPatterns } = require('stryker-parent');14logAboutUselessPatterns();15const { logAboutUselessPatterns } = require('stryker-parent');16logAboutUselessPatterns();17const { logAboutUselessPatterns } = require('stryker-parent');18logAboutUselessPatterns();19const { logAboutUselessPatterns } = require('stryker-parent');20logAboutUselessPatterns();21const { logAboutUselessPatterns } = require('stryker-parent');22logAboutUselessPatterns();23const { logAboutUselessPatterns } = require('stryker-parent');24logAboutUselessPatterns();

Full Screen

Using AI Code Generation

copy

Full Screen

1var logAboutUselessPatterns = require('stryker-parent').logAboutUselessPatterns;2logAboutUselessPatterns();3module.exports = {4 logAboutUselessPatterns: function () {5 console.log("About to log about useless patterns");6 }7}8{9}

Full Screen

Using AI Code Generation

copy

Full Screen

1import { logAboutUselessPatterns } from 'stryker-parent';2logAboutUselessPatterns();3export function logAboutUselessPatterns() {4 console.log('This is useless');5}611:17:22 (2500) INFO MutatorFacade 1 Mutant(s) generated711:17:22 (2500) INFO MutatorFacade 0 Mutant(s) survived811:17:22 (2500) INFO MutatorFacade 0 Mutant(s) tested911:17:22 (2500) INFO MutatorFacade 0 Mutant(s) timed out1011:17:22 (2500) INFO MutatorFacade 1 Mutant(s) had compile errors1111:17:22 (2500) INFO MutatorFacade 0 Mutant(s) killed1211:17:22 (2500) INFO MutatorFacade 0 Mutant(s) not covered by tests1311:17:22 (2500) INFO MutatorFacade 0 Mutant(s) marked as runtime error1411:17:22 (2500) INFO MutatorFacade 0 Mutant(s) ignored1511:17:22 (2500) INFO MutatorFacade 0 Mutant(s) no coverage1611:17:22 (2500) INFO MutatorFacade 1 Mutant(s) erro

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 stryker-parent 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