https://rosetta-io.netlify.app/
Working examples of how popular languages handle basic I/O and common serialization formats.
The examples are validated via a test suite that runs the examples in Docker and verifies expected behavior.
This project is not currently meant to be exhaustive in terms of languages, operating systems and I/O operations. The languages and I/O operations, etc are prioritized to support a commercial devtool product currently in stealth mode. That being said, contributions are very welcome.
The name rosetta-io
is an hommage to Rosetta Code but is not affiliated.
Language | Status |
---|---|
Python 3 | ✅ |
Ruby | ✅ |
Javascript, Node.js | ✅ |
PHP | ✅ |
R | ✅ |
Deno | ✅ |
Perl | ✅ |
Java | ✅ |
Bash 3 | ✅ |
Bash 5 | ✅ |
Lua | ✅ |
C# | ✅ |
Golang | ✅ |
Swift | ✅ |
Raku | ✅ |
Rust | ✅ |
… |
pip install -r requirements.txt
DOCKER_HOST
environment variable)Put any environment variables specific for your machine in a .env
file, which will be loaded by pytest
before it runs the test suite.
A few environment variables to consider:
DOCKER_HOST
if you want to run the test suite examples on a different Docker host, or use other Docker settingsPYTEST_XDIST_AUTO_NUM_WORKERS
can be set to the number of worker processes to run the tests in if pytest-xdist
's auto
setting is not what you want.pytest
environment variablesMake sure you Docker host is running
Run pytest
from the command line. If you are using VSCode you'll see the tests in the Testing panel.
Use pytest's -k
to narrow down wich tests to run. Examples:
command | narrows down to |
---|---|
pytest -k ruby |
Ruby tests |
pytest -k 'ruby and null_char' |
Only Ruby's null_char test |
pytest -k 'ruby and json' |
Ruby's JSON tests |
pytest -k java |
java and javascript tests |
pytest -k '[java]' |
only java tests, not javascript tests |
pytest -k '[java] and null_char' |
only java tests, not javascript tests |
Mark a test with @pytest.mark.local
if you want it to run the tested script locally instead of in docker. E.g.
# Will run in docker as
# docker run -i python-rosetta /bin/sh -c 'python encode.py "Hello World!"'
def test_encode(self, script):
script.run("encode", '"Hello, world!"')
assert script.output == 'SGVsbG8sIHdvcmxkIQ==\n'
# Will run on your machine as:
# /bin/sh -c 'python encode.py "Hello World!"'
@pytest.mark.local
def test_encode(self, script):
script.run("encode", '"Hello, world!"')
assert script.output == 'SGVsbG8sIHdvcmxkIQ==\n'
Alternatively, you can set the TEST_LOCAL
environment variable to true
or 1
to run all tests locally without having to mark them with @pytest.mark.local
.
E.g. run all Swift tests locally:
TEST_LOCAL=1 pytest -k swift