OceanSprint / tesh

TEstable SHell sessions in Markdown
https://pypi.org/project/tesh
MIT License
138 stars 8 forks source link

Example for nix-shell #45

Closed garbas closed 1 year ago

garbas commented 1 year ago

I was trying to use tesh to test some of my code example in markdown, but I couldn't get nix-shell to work. I think I'm missing something obvious.

I've added the minimal demo where I try to use nix-shell.

You can run it by:

$ poetry run tesh demo/nix-shell.md
domenkozar commented 1 year ago

It doesn't work yet, because Nix makes it really hard to customize $PS1.

garbas commented 1 year ago

The root of the problem to get nix-shell to work is actually to filter out ASCII escape code.

The solution would also be to include the ASCII escape code in your markdown files, but: 1) I don't expect people to write this 2) code highlighters to show the ASCII escape code correctly (pygments can do this via extension but github for example doesn't)

I think the only sane way is make this work is to filter out ASCII escape code and this is what I did.

I think this should also be the default behavior, but it would be nice to be also able to test colors in your terminal at times. So maybe we should make it possible to not filter out ASCII escape code.

garbas commented 1 year ago

Also... should we be running demos in the CI to make sure they work?

domenkozar commented 1 year ago

Filtering out the colors sounds good, if someone needs it they can implement a selection to turn it on.

Yeah, let's have a test for nix-shell since it's crucial.

garbas commented 1 year ago

@domenkozar I've renamed demo to examples and I've added them to CI. I think you need to click some button to approve CI to run

domenkozar commented 1 year ago
src/tesh/test.py:19:1: D102 Missing docstring in public method
src/tesh/test.py:25:1: D102 Missing docstring in public method
domenkozar commented 1 year ago

2023-07-26T11:59:59.1305122Z yamllint.................................................................Passed 2023-07-26T12:00:05.1128123Z src/tesh/test.py:19: error: Function is missing a type annotation [no-untyped-def] 2023-07-26T12:00:05.1129739Z src/tesh/test.py:29: error: Function is missing a type annotation [no-untyped-def] 2023-07-26T12:00:05.1130528Z src/tesh/test.py:48: error: Skipping analyzing "tesh._async": module is installed, but missing library stubs or py.typed marker [import] 2023-07-26T12:00:05.1132142Z src/tesh/test.py:48: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

garbas commented 1 year ago

I see, code coverage is below 100. Lets add some tests

garbas commented 1 year ago

I'll also add some lines to CHANGELOG

domenkozar commented 1 year ago

Checking examples/nix-shell.md ✨ Running nix-shell ❌ Failed Command: which hello

     Expected:

which: no hello in (*) Got:

garbas commented 1 year ago

This breaks test for me locally, but lets gets CI happy first :)

garbas commented 1 year ago

@domenkozar I don't want to burden you to click "Approve run" all the time. Would it be possible to get me enough permission so that this runs are triggered automatically.

domenkozar commented 1 year ago

I've changed the settings to always run, let's see if it works now.

zupo commented 1 year ago

@domenkozar: Ready for merging to my eyes, anything else I missed?