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

test: check for development mode and tests the correct execution of the dist #20

Merged
merged 4 commits into from
Dec 28, 2021

Conversation

gdorsi
Copy link
Contributor

@gdorsi gdorsi commented Dec 27, 2021

No description provided.

@gdorsi gdorsi changed the title test: adds a test for the development mode and adds test: check for development mode and execution test of the dist Dec 27, 2021
@gdorsi gdorsi changed the title test: check for development mode and execution test of the dist test: check for development mode and tests the correct execution of the dist Dec 27, 2021
@@ -52,7 +53,7 @@ test('it should correctly generate all required pino files when the cache is ena
runBuild(distFolder, (err) => {
t.error(err)

runBuild(distFolder, (err, stats) => {
runBuild(distFolder, async (err, stats) => {
Copy link
Member

Choose a reason for hiding this comment

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

never mix callbacks and async. Refactor this to just use promises if you think that's necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've removed the async and changed the await parts to .then

Is it ok now?

})
})

runBuild(distFolder, async (err, stats) => {
Copy link
Member

Choose a reason for hiding this comment

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

don't mix promises and callbacks.

@@ -36,7 +37,7 @@ test('it should correctly generated all required pino files', (t) => {
minimize: false
}
},
(err, stats) => {
async (err, stats) => {
Copy link
Member

Choose a reason for hiding this comment

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

don't mix promises and callbacks.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

Comment on lines +89 to +91
execa(process.argv[0], [secondDistFilePath]).then(({ stdout }) => {
t.match(stdout, /This is second!/)
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's use async/await for a more modern look of this code :) here and elsewhere please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#20 (comment)

With async/await the error management would become different.

Copy link
Collaborator

Choose a reason for hiding this comment

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

There is no error management you're doing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not mine but webpack's

I tried and in both cases when I throw an error inside the onDone callback the result would be an unhandledRejection so no difference here.

Anyway I think that "don't mix promises with callbacks" is a more general rule useful to avoid unintended and difficult to predict behavoirs.

/cc @mcollina

test('should work in webpack development mode', (t) => {
t.plan(3)

const distFolder = resolve(__dirname, '../tmp/pino-transport-bug')
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this folder called "pino-transport-bug"?

@@ -39,7 +40,7 @@ function runBuild(distFolder, onDone) {
}

test('it should correctly generate all required pino files when the cache is enabled on Webpack', (t) => {
t.plan(7)
t.plan(9)

const distFolder = resolve(__dirname, '../tmp/cached-build')
Copy link
Collaborator

Choose a reason for hiding this comment

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

why don't we use tap's testdir feature so we don't have to come up with fancy names for folders?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because i didn't know of it's existence :)

Thanks for pointing this out!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

@ShogunPanda ShogunPanda left a comment

Choose a reason for hiding this comment

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

LGTM!

@mcollina mcollina merged commit eef5583 into pinojs:main Dec 28, 2021
@github-actions github-actions bot mentioned this pull request Dec 29, 2021
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.

4 participants