summaryrefslogtreecommitdiffstatshomepage
path: root/tests/bytecode/pylib-tests/stat.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-08-14 12:24:11 +0100
committerDamien George <damien.p.george@gmail.com>2015-08-17 12:51:26 +0100
commit65dc960e3b22a8426e369607e47c19b380ce30ea (patch)
tree5e55ec2861df54e14fdb0eac1d030b34f684743b /tests/bytecode/pylib-tests/stat.py
parent0e978349a5e7696aa44a0faf5d046081a0616ca5 (diff)
downloadmicropython-65dc960e3b22a8426e369607e47c19b380ce30ea.tar.gz
micropython-65dc960e3b22a8426e369607e47c19b380ce30ea.zip
unix-cpy: Remove unix-cpy. It's no longer needed.
unix-cpy was originally written to get semantic equivalent with CPython without writing functional tests. When writing the initial implementation of uPy it was a long way between lexer and functional tests, so the half-way test was to make sure that the bytecode was correct. The idea was that if the uPy bytecode matched CPython 1-1 then uPy would be proper Python if the bytecodes acted correctly. And having matching bytecode meant that it was less likely to miss some deep subtlety in the Python semantics that would require an architectural change later on. But that is all history and it no longer makes sense to retain the ability to output CPython bytecode, because: 1. It outputs CPython 3.3 compatible bytecode. CPython's bytecode changes from version to version, and seems to have changed quite a bit in 3.5. There's no point in changing the bytecode output to match CPython anymore. 2. uPy and CPy do different optimisations to the bytecode which makes it harder to match. 3. The bytecode tests are not run. They were never part of Travis and are not run locally anymore. 4. The EMIT_CPYTHON option needs a lot of extra source code which adds heaps of noise, especially in compile.c. 5. Now that there is an extensive test suite (which tests functionality) there is no need to match the bytecode. Some very subtle behaviour is tested with the test suite and passing these tests is a much better way to stay Python-language compliant, rather than trying to match CPy bytecode.
Diffstat (limited to 'tests/bytecode/pylib-tests/stat.py')
-rw-r--r--tests/bytecode/pylib-tests/stat.py149
1 files changed, 0 insertions, 149 deletions
diff --git a/tests/bytecode/pylib-tests/stat.py b/tests/bytecode/pylib-tests/stat.py
deleted file mode 100644
index 704adfe2e1..0000000000
--- a/tests/bytecode/pylib-tests/stat.py
+++ /dev/null
@@ -1,149 +0,0 @@
-"""Constants/functions for interpreting results of os.stat() and os.lstat().
-
-Suggested usage: from stat import *
-"""
-
-# Indices for stat struct members in the tuple returned by os.stat()
-
-ST_MODE = 0
-ST_INO = 1
-ST_DEV = 2
-ST_NLINK = 3
-ST_UID = 4
-ST_GID = 5
-ST_SIZE = 6
-ST_ATIME = 7
-ST_MTIME = 8
-ST_CTIME = 9
-
-# Extract bits from the mode
-
-def S_IMODE(mode):
- """Return the portion of the file's mode that can be set by
- os.chmod().
- """
- return mode & 0o7777
-
-def S_IFMT(mode):
- """Return the portion of the file's mode that describes the
- file type.
- """
- return mode & 0o170000
-
-# Constants used as S_IFMT() for various file types
-# (not all are implemented on all systems)
-
-S_IFDIR = 0o040000 # directory
-S_IFCHR = 0o020000 # character device
-S_IFBLK = 0o060000 # block device
-S_IFREG = 0o100000 # regular file
-S_IFIFO = 0o010000 # fifo (named pipe)
-S_IFLNK = 0o120000 # symbolic link
-S_IFSOCK = 0o140000 # socket file
-
-# Functions to test for each file type
-
-def S_ISDIR(mode):
- """Return True if mode is from a directory."""
- return S_IFMT(mode) == S_IFDIR
-
-def S_ISCHR(mode):
- """Return True if mode is from a character special device file."""
- return S_IFMT(mode) == S_IFCHR
-
-def S_ISBLK(mode):
- """Return True if mode is from a block special device file."""
- return S_IFMT(mode) == S_IFBLK
-
-def S_ISREG(mode):
- """Return True if mode is from a regular file."""
- return S_IFMT(mode) == S_IFREG
-
-def S_ISFIFO(mode):
- """Return True if mode is from a FIFO (named pipe)."""
- return S_IFMT(mode) == S_IFIFO
-
-def S_ISLNK(mode):
- """Return True if mode is from a symbolic link."""
- return S_IFMT(mode) == S_IFLNK
-
-def S_ISSOCK(mode):
- """Return True if mode is from a socket."""
- return S_IFMT(mode) == S_IFSOCK
-
-# Names for permission bits
-
-S_ISUID = 0o4000 # set UID bit
-S_ISGID = 0o2000 # set GID bit
-S_ENFMT = S_ISGID # file locking enforcement
-S_ISVTX = 0o1000 # sticky bit
-S_IREAD = 0o0400 # Unix V7 synonym for S_IRUSR
-S_IWRITE = 0o0200 # Unix V7 synonym for S_IWUSR
-S_IEXEC = 0o0100 # Unix V7 synonym for S_IXUSR
-S_IRWXU = 0o0700 # mask for owner permissions
-S_IRUSR = 0o0400 # read by owner
-S_IWUSR = 0o0200 # write by owner
-S_IXUSR = 0o0100 # execute by owner
-S_IRWXG = 0o0070 # mask for group permissions
-S_IRGRP = 0o0040 # read by group
-S_IWGRP = 0o0020 # write by group
-S_IXGRP = 0o0010 # execute by group
-S_IRWXO = 0o0007 # mask for others (not in group) permissions
-S_IROTH = 0o0004 # read by others
-S_IWOTH = 0o0002 # write by others
-S_IXOTH = 0o0001 # execute by others
-
-# Names for file flags
-
-UF_NODUMP = 0x00000001 # do not dump file
-UF_IMMUTABLE = 0x00000002 # file may not be changed
-UF_APPEND = 0x00000004 # file may only be appended to
-UF_OPAQUE = 0x00000008 # directory is opaque when viewed through a union stack
-UF_NOUNLINK = 0x00000010 # file may not be renamed or deleted
-UF_COMPRESSED = 0x00000020 # OS X: file is hfs-compressed
-UF_HIDDEN = 0x00008000 # OS X: file should not be displayed
-SF_ARCHIVED = 0x00010000 # file may be archived
-SF_IMMUTABLE = 0x00020000 # file may not be changed
-SF_APPEND = 0x00040000 # file may only be appended to
-SF_NOUNLINK = 0x00100000 # file may not be renamed or deleted
-SF_SNAPSHOT = 0x00200000 # file is a snapshot file
-
-
-_filemode_table = (
- ((S_IFLNK, "l"),
- (S_IFREG, "-"),
- (S_IFBLK, "b"),
- (S_IFDIR, "d"),
- (S_IFCHR, "c"),
- (S_IFIFO, "p")),
-
- ((S_IRUSR, "r"),),
- ((S_IWUSR, "w"),),
- ((S_IXUSR|S_ISUID, "s"),
- (S_ISUID, "S"),
- (S_IXUSR, "x")),
-
- ((S_IRGRP, "r"),),
- ((S_IWGRP, "w"),),
- ((S_IXGRP|S_ISGID, "s"),
- (S_ISGID, "S"),
- (S_IXGRP, "x")),
-
- ((S_IROTH, "r"),),
- ((S_IWOTH, "w"),),
- ((S_IXOTH|S_ISVTX, "t"),
- (S_ISVTX, "T"),
- (S_IXOTH, "x"))
-)
-
-def filemode(mode):
- """Convert a file's mode to a string of the form '-rwxrwxrwx'."""
- perm = []
- for table in _filemode_table:
- for bit, char in table:
- if mode & bit == bit:
- perm.append(char)
- break
- else:
- perm.append("-")
- return "".join(perm)