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

getsize difference #412

Closed
agroce opened this issue Jun 5, 2018 · 12 comments
Closed

getsize difference #412

agroce opened this issue Jun 5, 2018 · 12 comments
Labels

Comments

@agroce
Copy link

agroce commented Jun 5, 2018

May be related to the tell bug?

import shutil
import pyfakefs.fake_filesystem
import os

ROOT_PATH = "/Volumes/ramdisk/test"

fs = pyfakefs.fake_filesystem.FakeFilesystem()
fs.CreateDirectory('/Volumes')
fs.CreateDirectory('/Volumes/ramdisk')
fs.CreateDirectory('/Volumes/ramdisk/test')
os0 = pyfakefs.fake_filesystem.FakeOsModule(fs)
opener0 = pyfakefs.fake_filesystem.FakeFileOpen(fs)

if False:
    os0 = os
    shutil.rmtree(ROOT_PATH)
    os.mkdir(ROOT_PATH)
    opener0 = open

component0 = "alpha" 
path0 = ROOT_PATH 
path0 += os.path.sep + component0 
bytes0 = 0 
str0 = "" 
str0 += 'a' 
file0 = opener0(path0,'a') 
file0.write(str0) 
file0.seek(bytes0) 
file0.truncate() 
file0.write(str0) 
file0.truncate() 
result = os0.path.getsize(path0) 

print result

OS gives 1, pyfakefs gives 2.

@agroce
Copy link
Author

agroce commented Jun 5, 2018

On reflection, no, this is probably not related to the tell issue, despite the append. It's a truncate problem, I'd bet.

@agroce
Copy link
Author

agroce commented Jun 5, 2018

no symlinks, no weird extra slashes, no rename. just a nice, simple, basic POSIX thing.

@mrbean-bremen
Copy link
Member

mrbean-bremen commented Jun 5, 2018

I don't think so either, I will check later. I had a go at the tell problem earlier, and it looks tough. I may actually revert a fix for another more obscure bug to fix this one - I may have another look at the weekend.

@agroce
Copy link
Author

agroce commented Jun 5, 2018

This and tell seem more important than symlinks + weird extra slashes, to me. I will probably remove extra slashes and add back in symlinks when I get a chance.

Running a bunch of new tests, since I have a cool new test generation heuristic I want to test out, anyway (count times every call has appeared in testing, and if I can call a seldom-called operation, make that highly probable, vs. the normal pure random selection)

@mrbean-bremen
Copy link
Member

Yes, I'm already tired of the exta slashes :P
Sounds interesting, may be I will have a closer look at tstl again later (but only after the temparatures are going a bit down here, I have trouble getting something into my head at the moment).

@agroce
Copy link
Author

agroce commented Jun 5, 2018

Symlinks included but extra slashes lost seems ok-ish. 2116 tests so far with no failures. So maybe we are mostly down to multi-slash nonsense as problems (I'm ignoring renames for now)

@mrbean-bremen
Copy link
Member

Ok, that sounds not so bad.

@agroce
Copy link
Author

agroce commented Jun 7, 2018

Many hours of testing seems to just show this issue, when extra slashes and rename aren't in the mix. You can detect it with readline, readlines, getsize, or st.size, but they all look like the same fancy footwork with truncate.

@mrbean-bremen
Copy link
Member

I tested only with getsize() - hopefully the other ones will also be fixed...

@agroce
Copy link
Author

agroce commented Jun 7, 2018

Variant still fails:

import shutil
import pyfakefs.fake_filesystem
import os

ROOT_PATH = "/Volumes/ramdisk/test"

fs = pyfakefs.fake_filesystem.FakeFilesystem()
fs.CreateDirectory('/Volumes')
fs.CreateDirectory('/Volumes/ramdisk')
fs.CreateDirectory('/Volumes/ramdisk/test')
os0 = pyfakefs.fake_filesystem.FakeOsModule(fs)
opener0 = pyfakefs.fake_filesystem.FakeFileOpen(fs)

if False:
    os0 = os
    shutil.rmtree(ROOT_PATH)
    os.mkdir(ROOT_PATH)
    opener0 = open

component0 = "alpha" 
path0 = ROOT_PATH 
path0 += os.path.sep + component0 
str0 = "" 
str0 += 'a' 
file0 = opener0(path0,'a') 
file0.write(str0) 
file0.truncate() 
file0.write(str0) 
file0.truncate() 
stat0 = os0.stat(path0) 
result = stat0.st_size 
print result

@mrbean-bremen
Copy link
Member

Reopen according to last comment.

@agroce
Copy link
Author

agroce commented Jun 8, 2018

Looks clean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants