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

Fix File-resolution on Windows #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BlazingTwist
Copy link
Contributor

While trying to use aya-digit I noticed that "model.json" json.load fails on windows.

I've used FileUtils.resolveFile where it seemed appropriate. (relates to #93 )

I initially thought this fix only applied to windows, but after testing on Ubuntu, it appears Aya also behaves oddly on Linux?
(Stop me if the assumptions in my tests are just plain wrong)

The primary cause of Linux weirdness seems to come from my shell having a different working directory than the one I pass to Aya.
'Actual output' indicates the behaviour I am seeing with the current Version of Aya.
'Expected output' is the behaviour using the changes of this PR.


Tests / Affected Instructions

sys.cd, sys.mkdir

test.aya:

"dir1" :{sys.mkdir}
"./dir1" :{sys.cd}
"dir2" :{sys.mkdir}

~/dir3$ java -jar /path/to/aya.jar /path/to/test /path/to/test/test.aya

Expected new directories:

  • /path/to/test/dir1/dir2

Actual new directories:

  • ~/dir3/dir1
  • ~/dir3/dir2

sys.set_ad, sys.readdir

test.aya

"../../" :{sys.set_ad}
"../" :{sys.cd}
"." :{sys.readdir}
"" :{sys.cd}           .# reset working directory to aya directory
"." :{sys.readdir}

~/dir3$ java -jar /path/to/aya.jar /path/to/test /path/to/test/test.aya

Expected output:

  • list of files in /path/to/
  • list of files in /path/

Actual output:

  • list of files in ~/dir3
  • list of files in ~/dir3

fstream.O

test.aya

"data.json" 'r :{fstream.O} :id
id 'a :{fstream.O}

~/dir3$ echo "{\"hello\":123,\"world\":456}" > /path/to/test/data.json
~/dir3$ java -jar /path/to/aya.jar /path/to/test /path/to/test/test.aya

Expected output: 11 "{\"hello\":123,\"world\":456}"

Actual output: 0 0 (failed to read file)


image.read and image.write

test.aya

"in.png" :{image.read} :img
"out.png" img.:filename;
img :{image.write}

echo "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVQI12NQWqIJAAHbAPCVVqDlAAAAAElFTkSuQmCC" | base64 -d > /path/to/test/in.png
~/dir3$ java -jar /path/to/aya.jar /path/to/test /path/to/test/test.aya

Expected output:

{,
  1:width;
  1:height;
  "out.png":filename;
  [ 41 -92 34 ]:data;
}

and /path/to/test/out.png is created.

Actual output:

io_err at :{image.read}: unable to use resource in.png. Can't read input file!


> File '/path/to/test/test.aya', line 1, col 22:
1 | "in.png" :{image.read} :img
    ~~~~~~~~~~~~~~~~~~~~~^
2 | "out.png" img.:filename;

Function call traceback:

…read', 'image.write', 'sys.readdir', 'sys.cd', 'sys.set_ad'
@nick-paul
Copy link
Collaborator

Thanks for always tracking down the platform & filesystem issues, I'm adding some tests on my end to check these cases as well before merging. All of the cases you fixed above look good to me

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.

2 participants