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

Test framework #2019

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

Test framework #2019

wants to merge 6 commits into from

Conversation

justinpombrio
Copy link
Collaborator

Pure YSH test framework. Lacks the ability to print the body of the assertion that failed, which is important!

@andychu
Copy link
Contributor

andychu commented Jul 13, 2024

Thanks for sending this out !

I've had some thoughts from working on OSH testing, and I was thinking about this

I posted them on this thread I pinged you on - https://oilshell.zulipchat.com/#narrow/stream/384942-language-design/topic/Interior.20vs.2E.20Exterior.20testing

related to:

  • test discovery across OSH and YSH (and Python and C++) -- shell is inherently very polyglot
  • table-based testing - for test parameters like ASAN/UBSAN, Clang/GCC, bin/osh vs. _bin/cxx-opt/osh
  • test cases as regular procs
  • 2-level structure vs. flat structure

Let me paste and OSH test in the next comment

This is an "ad hoc test" style we've been using for a long time

@andychu
Copy link
Contributor

andychu commented Jul 13, 2024

OK I have been converting our OWN tests to a mini test framework stdlib/osh/no-quotes.sh.

last 2 commits do this - ceffed0


It's only 135 lines now (although another file does test discovery)

The constraint is that these tests must run under bash, and then you can run it under OSH seamlessly.

For example we cannot write

nq-run (&status) {
  echo hi
}

we have to write

nq-run status \
  echo hi

But it is starting to seem like we should make them consistent ... e.g. you can upgrade your OSH tests to YSH with some simple syntactic transformation


We are motivated to do this ourselves because we have like 20K lines of shell tests... we are going to keep many of them in bash/OSH to avoid circular dependencies when bootstrapping (if YSH breaks, we still want to test YSH !)

But it also seems like we should make the OSH and YSH test frameworks roughly consistent

I kinda like "no-quotes" as a name because git's tests look like this

test_expect_success '
  log hi   # shell string with potential quoting issues
' 

Whereas we avoid that in OSH and YSH, with the nq-run style with either \ or { }

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

Successfully merging this pull request may close these issues.

2 participants