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

Add unit tests for the bundled compiler and compressor classes #531

Merged
merged 6 commits into from
Feb 22, 2016

Conversation

fdintino
Copy link
Member

In order to write unit tests for my sourcemap pull request (#490) I needed to have a way in the current testing system to run tests against the possible compilers and compressors available (e.g. scss, closure, uglifyjs). If node is available on the system tox installs npm packages into a local node_modules folder, and the settings then use the binaries in that local folder. YUI and closure also check for a java executable in the PATH, and csstidy does not have an npm package so it is the only compiler/compressor that doesn't get bootstrapped in the tox tests.

I noticed that you have made some effort to have the unit tests pass on windows, so I kept that in mind here. In the process of writing these tests I found some bugs, the fixes to which I've included in this pull request as separate commits.

@fdintino fdintino force-pushed the pr/compiler-compressor-unit-tests branch 2 times, most recently from 41865f0 to c8c4f3f Compare January 28, 2016 21:27
@fdintino
Copy link
Member Author

fdintino commented Feb 2, 2016

@jezdez Any feedback on this?

@jezdez
Copy link
Member

jezdez commented Feb 2, 2016

I think @cyberdelia would be better reviewing this from a conceptual point of view. I could only from a Python perspective tbh.

@fdintino
Copy link
Member Author

fdintino commented Feb 8, 2016

@cyberdelia could you give some guidance?

@@ -97,7 +98,7 @@ def __getitem__(self, key):
value = self.settings[key]
if key.endswith(("_BINARY", "_ARGUMENTS")):
if isinstance(value, string_types):
return tuple(shlex.split(value))
return tuple(shlex.split(value, posix=(os.sep == '/')))
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps use (os.name == 'posix') instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

I had done this because I wasn't sure if any of the other possible values for os.name had posix-like paths. But it doesn't appear that they do, so that's functionally equivalent and definitely clearer.

@fdintino fdintino force-pushed the pr/compiler-compressor-unit-tests branch from c8c4f3f to d8af869 Compare February 21, 2016 23:51
davidt added a commit to davidt/django-pipeline that referenced this pull request Feb 22, 2016
Pull request 531, among many other things, includes a similar fix for the use
of `stdout` before it's been assigned. That implementation is a nicer read, so
I've switched over to it.
shlex.split(), without posix=False, strips "\" characters, which is
obviously problematic on windows.
@fdintino fdintino force-pushed the pr/compiler-compressor-unit-tests branch 2 times, most recently from b71dd5e to f03a96a Compare February 22, 2016 19:20
@fdintino
Copy link
Member Author

Rebased out the commit that did the same thing as pr #541 and edited the compiler implementation tests to make it compatible with pr #540

@@ -54,3 +62,12 @@ def relpath(path, start=posixpath.curdir):
if not rel_list:
return posixpath.curdir
return posixpath.join(*rel_list)


def set_std_streams_blocking():
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice if this had a docstring explaining what it does and why it's needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Some nodejs executables set stdout and/or stderr to non-blocking, which
can trigger an IOError when the collectstatic command prints more than
1024 bytes at a time to stdout or stderr
If this environment variable is not set, multiprocessing throws a
NotImplementedError
@fdintino fdintino force-pushed the pr/compiler-compressor-unit-tests branch from f03a96a to c17fd82 Compare February 22, 2016 23:06
@davidt
Copy link
Contributor

davidt commented Feb 22, 2016

Looks good!

davidt added a commit that referenced this pull request Feb 22, 2016
…tests

Add unit tests for the bundled compiler and compressor classes
@davidt davidt merged commit 6346a20 into jazzband:master Feb 22, 2016
@fdintino
Copy link
Member Author

Thanks! I'll get to work adding unit tests and documentation to my source map pull request (#490)

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.

3 participants