<div dir="auto"><div>Juan,<div dir="auto"><br></div><div dir="auto">Thanks for taking the time to point me in the right direction. Much appreciated. Yes, lots I hadn't thought of.</div><div dir="auto"><br></div><div dir="auto">Just one question: in Cuis, do you prefer to not have specific Error subclasses and just call 'self error:' ?</div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jul 27, 2023, 1:27 PM Juan Vuletich <<a href="mailto:juan@cuis.st" rel="noreferrer noreferrer" target="_blank">juan@cuis.st</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Imran,<br>
<br>
There are a few issues with your change set.<br>
- It breaks paths like '../../stuff' .The loop was there for a reason.<br>
- Even with OSProcess it is possible that the $HOME variable is not defined.<br>
- Holding a workaround folder in a class variable can be problematic, <br>
especially if the image is saved. Or if OSProcess is loaded after this. <br>
It can also hide this problem for other code that asks for a folder.<br>
<br>
I pushed instead a different implementation that addresses this issues, <br>
as update #5898.<br>
<br>
To handle the situation you can do something like<br>
<br>
[ '~/Toto' asDirectoryEntry ] on: Error do: [ :error | error description <br>
print. error retryUsing: '/elToto' asDirectoryEntry ]<br>
<br>
Having the description of the error in available in a method lets you <br>
validate the kind of error, to be sure.<br>
<br>
Finally, to test base image functionality, a change set to be loaded in <br>
BaseImageTests is OK. If you also want to test the behavior with <br>
OSProcess loaded, another test for the OSProcess package is an <br>
alternative. In that test, don't forget to test that the HOME variable <br>
can be resolved, and do nothing if not. Otherwise the test will fail in <br>
some environments (I can think of Windows, but I'm sure there are others <br>
where HOME is not an environment variable).<br>
<br>
Thanks,<br>
<br>
On 7/27/2023 11:07 AM, Imran Rafique via Cuis-dev wrote:<br>
> Juan& Hernan,<br>
><br>
> I **think** the attached changeset does what you wanted. I may have<br>
> overcomplicated things somewhat, but in any case, its a great learning<br>
> experience.<br>
><br>
><br>
> Gives an exception if OSProcess is not available:<br>
><br>
> '~/foo' asFileEntry.<br>
><br>
><br>
> Sets a default homedir in case we cannot read environment variables:<br>
><br>
> [ '~/foo' asDirectoryEntry ] on: NeedsPackage do: [ :ex |<br>
> FileIOAccessor homeDirDefault: '/home/guess'. ex retry ]<br>
><br>
><br>
> BTW, whats the preferred way of including tests for changesets like this?<br>
><br>
> --<br>
> Regards,<br>
> Imran Sher Rafique<br>
<br>
-- <br>
Juan Vuletich<br>
<a href="http://cuis.st" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">cuis.st</a><br>
<a href="http://github.com/jvuletich" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">github.com/jvuletich</a><br>
<a href="http://researchgate.net/profile/Juan-Vuletich" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">researchgate.net/profile/Juan-Vuletich</a><br>
<a href="http://independent.academia.edu/JuanVuletich" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">independent.academia.edu/JuanVuletich</a><br>
<a href="http://patents.justia.com/inventor/juan-manuel-vuletich" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">patents.justia.com/inventor/juan-manuel-vuletich</a><br>
<a href="http://linkedin.com/in/juan-vuletich-75611b3" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">linkedin.com/in/juan-vuletich-75611b3</a><br>
<a href="http://twitter.com/JuanVuletich" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">twitter.com/JuanVuletich</a><br>
<br>
</blockquote></div>
</div></div>