Commits

Jan-Jaap Driessen  committed 01490bd

The mode resource should have the same dependencies (possibly in another mode) as the parent resource.

  • Participants
  • Parent commits 7352f44
  • Branches compilers-n-minifiers2

Comments (0)

Files changed (2)

File fanstatic/core.py

             self.renderer = renderer
             # If we do not know about the filename extension inclusion
             # order, we render the resource after all others.
-            # XXX cleanup this API.
             self.order = inclusion_renderers.get(self.ext, (sys.maxint, None))[0]
         else:
             # No custom, ad-hoc renderer for this Resource, so lookup
                 # If we have a compiler, we have already calculated the relpath.
                 if self.compiler is None:
                     self.relpath = self.minifier.target_path(self.relpath)
-                # In non-devmode, the compiled file should be there.
+                # In devmode, the minifier should be available.
                 if self.library.devmode:
                     # XXX memoize this call.
                     if not self.minifier.available():
                     # Calculate the supersedes information in minified mode.
                     minified_resource = self.mode_clone(MINIFIED, source=minified)
                 else:
-                    # XXX -> same
                     # The dependencies of a mode resource should be the same 
-                    # or a subset of the dependencies this mode replaces.
+                    # as the dependencies this mode replaces.
                     mode_depends = set([resource.mode(MINIFIED) for resource in self.depends])
-                    if len(minified.depends - mode_depends) > 0:
+                    if minified.depends != mode_depends:
                         raise ModeResourceDependencyError
                     minified_resource = minified 
                     minified_resource._mode = MINIFIED
                 debug_resource = self.mode_clone(DEBUG, source=debug)
             else:
                 # The dependencies of a mode resource should be the same 
-                # or a subset of the dependencies this mode replaces.
+                # as the dependencies this mode replaces.
                 mode_depends = set([resource.mode(DEBUG) for resource in self.depends])
-                if len(debug.depends - mode_depends) > 0:
-                    raise ModeResourceDependencyError
+                if debug.depends != mode_depends:
+                    raise ModeResourceDependencyError('%s is not %s' % (debug.depends, mode_depends))
                 debug_resource = debug
         elif self.compiler and self.compiler.debug and self._mode is None:
             debug_resource = self.mode_clone(DEBUG)

File fanstatic/test_core.py

     assert needed.resources()[0].source == 'k-debug.js'
 
 
-def test_mode_inherit_dependency_nr():
-    foo = Library('foo', '')
-    k = Resource(foo, 'k.js')
-    l_debug = Resource(foo, 'l-debug.js')
-    assert l_debug.dependency_nr == 0
-    l = Resource(foo, 'l.js', debug=l_debug, depends=[k])
-    assert l_debug.dependency_nr == 1
-
-
 def test_rollup():
     foo = Library('foo', '')
     b1 = Resource(foo, 'b1.js')