| 172 | |
| 173 | |
| 174 | def can_symlink(): |
| 175 | global _can_symlink |
| 176 | if _can_symlink is not None: |
| 177 | return _can_symlink |
| 178 | # WASI / wasmtime prevents symlinks with absolute paths, see man |
| 179 | # openat2(2) RESOLVE_BENEATH. Almost all symlink tests use absolute |
| 180 | # paths. Skip symlink tests on WASI for now. |
| 181 | src = os.path.abspath(TESTFN) |
| 182 | symlink_path = src + "can_symlink" |
| 183 | try: |
| 184 | os.symlink(src, symlink_path) |
| 185 | can = True |
| 186 | except (OSError, NotImplementedError, AttributeError): |
| 187 | can = False |
| 188 | else: |
| 189 | os.remove(symlink_path) |
| 190 | _can_symlink = can |
| 191 | return can |
| 192 | |
| 193 | |
| 194 | def skip_unless_symlink(test): |