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: refactor tests for mocha #141

Merged
merged 2 commits into from
Nov 27, 2017
Merged

test: refactor tests for mocha #141

merged 2 commits into from
Nov 27, 2017

Conversation

silkentrance
Copy link
Collaborator

@silkentrance silkentrance commented Jul 10, 2017

fix #137

WIP

@silkentrance silkentrance force-pushed the gh-137 branch 4 times, most recently from f6bbf54 to 84b9225 Compare July 11, 2017 14:14
@silkentrance
Copy link
Collaborator Author

silkentrance commented Jul 11, 2017

Tests against the template option (here:effective gid mismatch) failed partly due to the fact that tmp will not join paths with opts.dir nor the default tmpDir. This resulted in the fact that the temporary files and directories will be created in the CWD.
I will file a new issue for this.

The second cause of the failure is more involved as it requires the parent directory to have the setgid bit set, which in turn will set the gid of the file or directory to that of the parent directory and not the effective gid of the current process. While this is not exactly a common requirement, I don't think that we should incorporate this into our tests, as it would involve stat'ing the parent directory and from that get the gid and see whether the gid matches that of the temporary file or directory. Since these are system specific issues, we should not be testing against these.
I'd favor removing the tests for egid and euid altogether as these are features of the underlying operating system which we do not control. In addition, these tests will not be run under the win32 platform.

@raszi
Copy link
Owner

raszi commented Jul 13, 2017

Thank you @silkentrance for the hard work, this will help!

@silkentrance
Copy link
Collaborator Author

@raszi You're welcome. The existing tests that spawn child processes are still missing. I need to go through the code to find out how to do it with mocha...

@silkentrance
Copy link
Collaborator Author

silkentrance commented Aug 16, 2017

rebased to master - failing tests due to #143

What do you think about the new tests?

@silkentrance silkentrance merged commit 26146ef into master Nov 27, 2017
@silkentrance silkentrance deleted the gh-137 branch November 27, 2017 22:38
Copy link
Owner

@raszi raszi left a comment

Choose a reason for hiding this comment

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

I started the review but didn't have time to finish it. Here are my previous comments.


module.exports.assertName = function assertName(name, expected) {
assert.ok(typeof name == 'string');
assert.ok(name.length > 0, 'an empty string is not a valid name');
Copy link
Owner

Choose a reason for hiding this comment

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

I think this should be put in the else branch of the following if condition, since that will be a stricter match and it would not add any value in the true case.

Copy link
Owner

Choose a reason for hiding this comment

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

I meant this:

if (expected) {
  assert.equal(path.basename(name), expected, 'should be the expected name');
} else {
  assert.ok(name.length > 0, 'an empty string is not a valid name');
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done.

module.exports = function spawnChildProcess(configFile, cb) {
var
node_path = process.argv[0],
command_args = [ path.join(__dirname, 'spawn.js') ].concat(configFile),
Copy link
Owner

Choose a reason for hiding this comment

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

Please remove the whitespace after the opening [ and the closing ].

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done.

describe('with invalid tries', function () {
it('should result in an error on negative tries', function () {
try {
tmp.dirSync({tries: -1});
Copy link
Owner

Choose a reason for hiding this comment

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

Please use whitespace after the opening { and before the closing }.

Copy link
Collaborator Author

@silkentrance silkentrance Nov 28, 2017

Choose a reason for hiding this comment

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

@raszi like so?

        it('should result in an error on negative tries', function () {

          try {
            tmp.dirSync({tries: -1});
            assert.fail('should have failed');
          } catch (err) {
            assert.ok(err instanceof Error);
          }

        });

ah, forget the above, I think you mean { tries: -1 }... but then again, there are lot of occurrences in the code where I could change that...

@silkentrance
Copy link
Collaborator Author

@raszi I will look over the existing issues with the code and commit these then as I already merged into master.

silkentrance added a commit that referenced this pull request Nov 28, 2017
@raszi raszi changed the title Refactor tests for mocha test: refactor tests for mocha Aug 29, 2018
@silkentrance silkentrance mentioned this pull request Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace the vows test framework as it is no longer being supported
2 participants