Commits

ZyX_I committed 0efbc46

@frawor: Some _f.require fixes (missing cons key, olddstatus handling)
tests: Extended require-feature tests

Comments (0)

Files changed (3)

plugin/frawor.vim

     if has_key(a:plugdict.dependencies, dplid)
         return 2
     endif
-    let shadowdict=s:shadow[a:plugdict.id]
     "▶2 Add dependency
     unlockvar 1 a:plugdict.dependencies
     let a:plugdict.dependencies[dplid]=copy(a:dversion)
         let olddstatus=s:pls[dplid].status
         let doload=(olddstatus!=2)
     endif
-    if doload && !s:F.loadplugin(dplid)
-        if a:throw
-            call s:_f.throw('reqfailed', dplid, a:plugdict.id)
+    if doload
+        if s:F.loadplugin(dplid)
+            if olddstatus==0
+                call s:F.runfeatures(a:plugdict, 'depadd', dplid)
+                return 1
+            endif
         else
-            unlockvar 1 a:plugdict.dependencies
-            call remove(a:plugdict.dependencies, dplid)
-            lockvar 1 a:plugdict.dependencies
-            return 0
-        endif
-        if !olddstatus
-            call s:F.runfeatures(a:plugdict, 'depadd')
-            return 1
+            if a:throw
+                call s:_f.throw('reqfailed', dplid, a:plugdict.id)
+            else
+                unlockvar 1 a:plugdict.dependencies
+                call remove(a:plugdict.dependencies, dplid)
+                lockvar 1 a:plugdict.dependencies
+                return 0
+            endif
         endif
     endif
     "▲2
     let dfeatures=s:plfeatures[dplid]
-    let fdicts=s:shadow[a:plugdict.id].features
+    let shadowdict=s:shadow[a:plugdict.id]
+    let fdicts=shadowdict.features
     for feature in filter(values(dfeatures), '!has_key(fdicts, v:val.name)')
         let fdict={}
         let fdicts[feature.name]=fdict
         if has_key(feature, 'register')
             call feature.register(a:plugdict, fdict)
         endif
+        if has_key(feature, 'cons')
+            let a:plugdict.g._f[feature.name]=
+                        \s:F.createcons(a:plugdict, shadowdict, feature)
+        endif
         if a:plugdict.status==2
             if has_key(feature, 'load')
                 call feature.load(a:plugdict, fdict)

test/require-feature.in

 :let &rtp.=",".escape($TESTDIR, ',\').'/rtp'
 :let g:testfile="plugin/".g:curtest.".vim"
 :source test.vim
+:call FraworUnload(g:testfile[:-5])
+:source test.vim

test/require-feature.ok

 throw
 warn
 require xup: 0
+plugin/frawor:reqfailed
+feature-unloadpre: plugin/twoload-plugin-with-feature-1
+feature-unloadpre: plugin/twoload-plugin-with-feature-2
+feature-unloadpre: plugin/twoload-plugin-with-feature-3
+feature-unloadpre: plugin/twoload-plugin-with-feature-after-registration-1
+feature-unloadpre: plugin/twoload-plugin-with-feature-after-registration-2
+feature-unloadpre: plugin/twoload-plugin-with-feature-after-registration-3
+feature-unload: plugin/twoload-plugin-with-feature-1
+feature-unload: plugin/twoload-plugin-with-feature-2
+feature-unload: plugin/twoload-plugin-with-feature-3
+feature-unload: plugin/twoload-plugin-with-feature-after-registration-1
+feature-unload: plugin/twoload-plugin-with-feature-after-registration-2
+feature-unload: plugin/twoload-plugin-with-feature-after-registration-3
+newfeature
+require
+throw
+warn
+Entered s:F.main()
+Has run :runtime
+Has run FraworLoad
+Has run :runtime 2
+Has run FraworLoad 2
+feature-register: plugin/twoload-plugin-with-feature-1
+feature-load: plugin/twoload-plugin-with-feature-1
+feature-depadd: plugin/twoload-plugin-with-feature-1 plugin/twoload-plugin-with-feature-1
+require tpwf1: 1
+feature-register: plugin/twoload-plugin-with-feature-2
+feature-load: plugin/twoload-plugin-with-feature-2
+feature-depadd: plugin/twoload-plugin-with-feature-1 plugin/twoload-plugin-with-feature-2
+feature-depadd: plugin/twoload-plugin-with-feature-2 plugin/twoload-plugin-with-feature-2
+require tpwf2: 1
+feature-register: plugin/twoload-plugin-with-feature-3
+feature-load: plugin/twoload-plugin-with-feature-3
+feature-depadd: plugin/twoload-plugin-with-feature-1 plugin/twoload-plugin-with-feature-3
+feature-depadd: plugin/twoload-plugin-with-feature-2 plugin/twoload-plugin-with-feature-3
+feature-depadd: plugin/twoload-plugin-with-feature-3 plugin/twoload-plugin-with-feature-3
+require tpwf3: 1
+feature-register: plugin/twoload-plugin-with-feature-after-registration-1
+feature-load: plugin/twoload-plugin-with-feature-after-registration-1
+feature-depadd: plugin/twoload-plugin-with-feature-1 plugin/twoload-plugin-with-feature-after-registration-1
+feature-depadd: plugin/twoload-plugin-with-feature-2 plugin/twoload-plugin-with-feature-after-registration-1
+feature-depadd: plugin/twoload-plugin-with-feature-3 plugin/twoload-plugin-with-feature-after-registration-1
+feature-depadd: plugin/twoload-plugin-with-feature-after-registration-1 plugin/twoload-plugin-with-feature-after-registration-1
+require tpwfar1: 1
+feature-register: plugin/twoload-plugin-with-feature-after-registration-2
+feature-load: plugin/twoload-plugin-with-feature-after-registration-2
+feature-depadd: plugin/twoload-plugin-with-feature-1 plugin/twoload-plugin-with-feature-after-registration-2
+feature-depadd: plugin/twoload-plugin-with-feature-2 plugin/twoload-plugin-with-feature-after-registration-2
+feature-depadd: plugin/twoload-plugin-with-feature-3 plugin/twoload-plugin-with-feature-after-registration-2
+feature-depadd: plugin/twoload-plugin-with-feature-after-registration-1 plugin/twoload-plugin-with-feature-after-registration-2
+feature-depadd: plugin/twoload-plugin-with-feature-after-registration-2 plugin/twoload-plugin-with-feature-after-registration-2
+require tpwfar2: 1
+feature-register: plugin/twoload-plugin-with-feature-after-registration-3
+feature-load: plugin/twoload-plugin-with-feature-after-registration-3
+feature-depadd: plugin/twoload-plugin-with-feature-1 plugin/twoload-plugin-with-feature-after-registration-3
+feature-depadd: plugin/twoload-plugin-with-feature-2 plugin/twoload-plugin-with-feature-after-registration-3
+feature-depadd: plugin/twoload-plugin-with-feature-3 plugin/twoload-plugin-with-feature-after-registration-3
+feature-depadd: plugin/twoload-plugin-with-feature-after-registration-1 plugin/twoload-plugin-with-feature-after-registration-3
+feature-depadd: plugin/twoload-plugin-with-feature-after-registration-2 plugin/twoload-plugin-with-feature-after-registration-3
+feature-depadd: plugin/twoload-plugin-with-feature-after-registration-3 plugin/twoload-plugin-with-feature-after-registration-3
+require tpwfar3: 1
+feature-load: plugin/require-feature
+feature-depadd: plugin/twoload-plugin-with-feature-1 plugin/plugin-with-feature
+feature-depadd: plugin/twoload-plugin-with-feature-2 plugin/plugin-with-feature
+feature-depadd: plugin/twoload-plugin-with-feature-3 plugin/plugin-with-feature
+feature-depadd: plugin/twoload-plugin-with-feature-after-registration-1 plugin/plugin-with-feature
+feature-depadd: plugin/twoload-plugin-with-feature-after-registration-2 plugin/plugin-with-feature
+feature-depadd: plugin/twoload-plugin-with-feature-after-registration-3 plugin/plugin-with-feature
+require pwf: 1
+newfeature
+require
+testfeature
+throw
+warn
+require xup: 0
 plugin/frawor:reqfailed