Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore files that did not match specified mask. #9

Merged
merged 2 commits into from
Oct 25, 2016
Merged

Ignore files that did not match specified mask. #9

merged 2 commits into from
Oct 25, 2016

Conversation

seth2810
Copy link
Contributor

Currently, if glob call did not find any file for one of passed to expandPaths masks all execution will be failed. I think it should just ignore this behavior or just warn about this.

@levonet levonet added the review label Oct 11, 2016
const getFilesByMask = (pattern, options) => {
return q.nfcall(glob, pattern, options).then((paths) => {
return _.isEmpty(paths) && !isMask(pattern)
? q.reject(new Error(`Cannot find files by mask ${pattern}`))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут уже message ошибки должен быть другой.

сейчас он не соответствует действительности, так как дословно такой Не могу найти файлы по маске, а мы как раз таки в этом пулл-реквесте реализуем логику, чтобы не ругаться на маски.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

типо надо писать что-то вроде: Не могу найти файлы по пути 'какой-то плохой путь'

const isMask = (pattern) => glob.hasMagic(pattern);

const getFilesByMask = (pattern, options) => {
return q.nfcall(glob, pattern, options).then((paths) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

мы then обычно пишем на новой строке.

exports.isMasks = (paths) => {
return [].concat(paths).every((path) => glob.hasMagic(path));
};
exports.isMasks = (patterns) => [].concat(patterns).every(isMask);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а ты эту штуку, где еще используешь?

ты типо добавил новый метод в модуль globExtra ?

Если да, то я бы отсюда экспортил функцию isMask, а не функцию isMasks (кстати isMasks так себе название, кажется, с точки зрения английского языка)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eGavr так ты разве не видишь, что этот метод там уже был, до моих вмешательств, и все что я сделал, так это сделал из ф-ии однострочник и завернул glob.hasMagis в ф-ию хелпер, потому что она у меня используется уже в 2-х местах. Нейминг и вправду не очень, но к сожалению у меня не достаточно ресурсов, чтобы выяснить где оно может быть использовано.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ну типо давай узнаем, кто ее написал, зачем она нужна ? :)

сс @rostik404

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Судя по blame, это Дима добавил

cc @DudaGod

Copy link
Member

@DudaGod DudaGod Oct 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, это я добавлял. Использовал ее чтобы ускорить запуск тестов в gemini в случае если все сеты указаны масками. Если все сеты - маски, то мне не нужно каждую из них раскрывать (на это уходит дохрена времени, перед запуском 2-4 секунды), тем более если пользователь хочет запустить всего один тест (указанный в командной строке). В этом случае я матчу файл на маски с помощью micromatch-а и определяю запускаем тест или нет.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

экспортить надо просто isMask
Кажется, что писать в коде isMask(path) или paths.every(isMask) не сильно сложно

Нейминг и вправду не очень, но к сожалению у меня не достаточно ресурсов, чтобы выяснить где оно может быть использовано

Поиск по гитхабу дает всего 18 результатов, не так много людей пишут такую фигню с точки зрения английского языка :)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ром, давай поправим

@@ -38,10 +38,28 @@ describe('path-utils', () => {
});
});

it('should throw an error if a mask does not match files', () => {
it('should throw error if mask contains unexistent file path', () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не маска, а путь надо писать

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вообще я бы назвал эту сущность выражением или паттерном, а то получается тафтология - путь содержит несуществующий путь.

return assert.isRejected(globExtra.expandPaths(['bad/mask/file.js']), 'Cannot find files by mask bad/mask/file.js');
});

it('should throw error if mask contains unexistent directory path', () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут тоже

return assert.isRejected(globExtra.expandPaths(['bad/mask']), 'Cannot find files by mask bad/mask');
});

it('should ignore masks that contain magic symbols', () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that –> which

that используется для одушевленных предметов

'bad/mask/*.js',
'some/path/*.js'
]).then((absolutePaths) => {
assert.deepEqual(absolutePaths, ['some/path/file.js']);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а че не в одну строчку?

@eGavr
Copy link

eGavr commented Oct 17, 2016

Если ты еще добавляешь в public API новый метод, то на него отдельно тоже стоит тесты написать.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 8753bfb on seth2810:handle-mismatch into 3dbafc7 on gemini-testing:master.

@seth2810
Copy link
Contributor Author

@eGavr Мной не было добавлено ничего в public API, а на isMasks тесты уже есть - https://github.com/gemini-testing/glob-extra/blob/master/test/index.test.js#L221

@eGavr
Copy link

eGavr commented Oct 17, 2016

хмммм, а где оно используется тогда?

cc @rostik404

@DudaGod
Copy link
Member

DudaGod commented Oct 17, 2016

@eGavr в gemini

return assert.isRejected(globExtra.expandPaths(['bad/mask']), 'Cannot find files by mask bad/mask');
});

it('should ignore masks which contain magic symbols', () => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

здесь проверяется, что игнорятся маски, которые не матчатся на файлы, а в тайтле написано другое

@j0tunn
Copy link

j0tunn commented Oct 21, 2016

/ok

@seth2810 seth2810 merged commit fccb07c into gemini-testing:master Oct 25, 2016
@levonet levonet removed the review label Oct 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants