The second test changes the script, it overwrites it with a new value.
The way the checksum works addition and deletion will trigger a
recompile but I'll add a test to be sure.

On Sep 11, 10:25 pm, "Ayende Rahien" <[EMAIL PROTECTED]> wrote:
> script additionscript removal
> changing the DSL itself (not sure how to change that)
>
>
>
> On Fri, Sep 12, 2008 at 6:23 AM, webpaul <[EMAIL PROTECTED]> wrote:
>
> > Ok, all tests green, here are the two I added. Let me know if you
> > think additional scenarios need to be covered.
>
> >        [Test]
> >        public void engine_reuses_first_compile()
> >        {
> >            string path =
> > Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
> > @"DslFactoryFixture\MyFirstCustom.boo"));
> >            File.WriteAllText(path, "print 0");
>
> >            try
> >            {
> >                engine.Compile(path);
> >                Assert.IsFalse(engine.IsLastCompileCached);
>
> >                engine.Compile(path);
> >                Assert.IsTrue(engine.IsLastCompileCached);
> >            }
> >            finally
> >            {
> >                //clean up cached output so next test is clean
> >                string filePath =
> > engine.CompilerContextCache.LastCachedFilePath;
> >                if (File.Exists(filePath))
> >                    File.Delete(filePath);
>
> >                if (File.Exists(path))
> >                    File.Delete(path);
> >            }
> >        }
>
> >        [Test]
> >        public void engine_recompiles_on_script_change()
> >        {
> >            string path =
> > Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
> > @"DslFactoryFixture\MyCustom.boo"));
> >            string filePath1 = null, filePath2 = null;
>
> >            try
> >            {
> >                File.WriteAllText(path, "print 1");
> >                engine.Compile(path);
> >                Assert.IsFalse(engine.IsLastCompileCached);
> >                filePath1 =
> > engine.CompilerContextCache.LastCachedFilePath;
>
> >                File.WriteAllText(path, "print 2");
> >                engine.Compile(path);
> >                Assert.IsFalse(engine.IsLastCompileCached);
> >                filePath2 =
> > engine.CompilerContextCache.LastCachedFilePath;
> >            }
> >            finally
> >            {
> >                //clean up cached output so next test is clean
> >                if (File.Exists(filePath1))
> >                    File.Delete(filePath1);
>
> >                if (File.Exists(filePath2))
> >                    File.Delete(filePath2);
>
> >                //cleanup dynamic script
> >                if (File.Exists(path))
> >                    File.Delete(path);
> >             }
> >        }
>
> > On Sep 11, 9:58 pm, webpaul <[EMAIL PROTECTED]> wrote:
> > > Ok, nevermind file locking issue resolved onto the caching.
>
> > > On Sep 11, 9:37 pm, webpaul <[EMAIL PROTECTED]> wrote:
>
> > > > It also appears that the boo compiler itself is hanging onto the file
> > > > once it is compiled. If I compile to memory I haven't been able to
> > > > find a way to save the in memory assembly, no save method on the
> > > > object and serializing doesn't work though I've found some posts on
> > > > people doing that. I'll keep looking.
>
> > > > On Sep 11, 9:28 pm, "Ayende Rahien" <[EMAIL PROTECTED]> wrote:
>
> > > > > Yes, persistent in this case means surviving application restar.
>
> > > > > On Fri, Sep 12, 2008 at 5:06 AM, webpaul <[EMAIL PROTECTED]> wrote:
>
> > > > > > On the storage interface there is a notify on change event. Any
> > reason
> > > > > > you can think of to not just use that instead of the checksum?
>
> > > > > > On Sep 11, 8:37 pm, "Ayende Rahien" <[EMAIL PROTECTED]> wrote:
> > > > > > > Yeah :-)Load it using Assembly.Load(File.ReadAllBytes(file))
>
> > > > > > > Nasty, but works.
>
> > > > > > > On Fri, Sep 12, 2008 at 4:12 AM, webpaul <[EMAIL PROTECTED]>
> > wrote:
>
> > > > > > > > Ok, it was compiling to memory, was able to get it to compile
> > to a
> > > > > > > > file and cache it after that. The file is getting locked though
> > so I
> > > > > > > > can't clean it up in the tests without closing mbunit. Looks
> > like this
> > > > > > > > is going to take longer than I thought. :)
>
> > > > > > > > On Sep 11, 3:22 pm, webpaul <[EMAIL PROTECTED]> wrote:
> > > > > > > > > That's what I was trying to do but that wasn't working out
> > for me,
> > > > > > the
> > > > > > > > > file wasn't there for some reason. I'll try again later,
> > maybe I'm
> > > > > > > > > missing something.
>
> > > > > > > > > On Sep 11, 2:05 pm, "Ayende Rahien" <[EMAIL PROTECTED]>
> > wrote:
>
> > > > > > > > > > Sorry, the cache is persistent, it has to survive app
> > restarts.
> > > > > > > > > > We already have transient cache. I am not sure that I
> > follow why
> > > > > > > > serializing
> > > > > > > > > > the context is good. You can just start a new one with the
> > cached
> > > > > > > > generated
> > > > > > > > > > assembly
>
> > > > > > > > > > On Thu, Sep 11, 2008 at 9:21 PM, webpaul <
> > [EMAIL PROTECTED]>
> > > > > > wrote:
>
> > > > > > > > > > > From my first look at the code that seemed to be the
> > easiest way
> > > > > > to
> > > > > > > > do
> > > > > > > > > > > the caching. The last thing I tried was accessing the DLL
> > > > > > location
> > > > > > > > > > > created by the compiler context and when retrieving the
> > cached
> > > > > > copy
> > > > > > > > to
> > > > > > > > > > > populate the object with the info but that didn't work
> > either,
> > > > > > that
> > > > > > > > is
> > > > > > > > > > > in fact how the code is as-posted right now. So I tried
> > > > > > serializing
> > > > > > > > > > > the whole object and that, but neither seemed to work.
> > I'm open
> > > > > > to
> > > > > > > > > > > suggestions if you think there is an easier way to do it.
>
> > > > > > > > > > > On Sep 11, 9:12 am, "Ayende Rahien" <[EMAIL PROTECTED]>
> > wrote:
> > > > > > > > > > > > Why do you need to save the compiler context?
>
> > > > > > > > > > > > On Thu, Sep 11, 2008 at 4:44 PM, webpaul <
> > [EMAIL PROTECTED]>
> > > > > > > > wrote:
>
> > > > > > > > > > > > > Working on doing this as per:
>
> >http://www.ayende.com/Blog/archive/2008/09/10/Persistent-DSL-caching-.
> > > > > > > > > > > ..
>
> > > > > > > > > > > > > Can someone suggest how to serialize or otherwise
> > save a
> > > > > > > > > > > > > CompilerContext instance without modifying the Boo
> > project as
> > > > > > > > well?-
> > > > > > > > > > > Hide quoted text -
>
> > > > > > > > > > > > - Show quoted text -- Hide quoted text -
>
> > > > > > > > > > - Show quoted text -- Hide quoted text -
>
> > > > > > > > > - Show quoted text -- Hide quoted text -
>
> > > > > > > - Show quoted text -- Hide quoted text -
>
> > > > > - Show quoted text -- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino Tools Dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rhino-tools-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to