Code Monkey home page Code Monkey logo

space_test's People

Contributors

xparq avatar

Watchers

 avatar

space_test's Issues

Rename RUN to EXEC(?) and run_cases to run

While EXEC is a perfect counterpart of SH, and it also conveys exactly what it is, but only for devs...
I mean it's all for devs anyway, but for the overall style... It just reads shit. Like the examples in the README:

EXEC something
EXPECT some result

or

EXEC some command
EXEC other command
EXEC command --with-params

EXPECT "some result
....

Perhaps it just looks way too similar to EXPECT. Or is it just me?!

Maybe DO? Or just keep it RUN? Both are subpar for accuracy of meaning, but just taste better. Their genericity is also a plus, from the overall readability aspect (for high-level test authoring/maintenance), not just a minus (from the low-level technical test coding aspect).

  • I think I'll just keep it RUN for now, and revisit this if really becomes untenable.

  • Renaming run_cases is uncontroversial though. The mild crosstalk between RUN and run is kinda still annoying, but nothing that can't be lived with.

Support a more flexible fs layout than embedding _engine within the test root dir

Related ("dependent") issues (decisions that have simplified things a lot):

  • TEST_DIR/run (and run.cmd) has been used as the sole reliable anchor for locating the TEST_DIR.. Where that script is, there's the test stuff. And from there it just also knows that _engine is also there, right underneath.

  • The current logic is too brittle: it relies solely on $0 being in the _engine dir, which is not the case when run is being sourced from a script elsewhere, or if it was run via a symlink (at least on Windows; can't recall if sh resolves that symlink, hopefully not)!

  • Now at least TEST_DIR can be set before calling run (which would then accept it, no questions asked).

  • Support symlinks to _engine/run[.cmd] as anchors of the test dir!
    -> E.g.: https://github.com/cavo789/dos_batch_tips#getsymlinktargetpath

It was a bad idea to exploit BB's support for `if [[ ... ]]`...

Because the shebangs still had to remain #!/bin/sh -- but then it's a manifest inconsistency: sh doesn't support this syntax!

The implementations I encountered on Windows all still did tho, because many are just bashes in disguise.
So, all was well, until actually running in a real Linux shell, which took the shebangs seriously, and so the scripts broke...

Review and sanitize the (mis)use of `export`s

So, it's only needed for bridging over to subprocesses, but not when sourcing scripts:

  • spawned engine (sub)commands
  • support for possibly launched user processes (anywhere) in the given context

I may have extra or missing exports basically anywhere...

Make sure the sh scripts all have only LFs (not CRLFs)

(Originally: xparq/Args#33)

The .gitattributes settings supposedly already ensure that it's that way in the repo.
However, I still had core.autocrlf enabled locally, and either because of that or it was just never changed, (some of?) the scripts still had CRLF (in the work tree at least).

I recently dos2unixed them all, and also did a git add --renormalize (which didn't change anything then, but suppressed Git's really inexplicable "...will change to CRLF" warning); let's see what happens next time I check something out and feed it e.g. to WSL's bash...

Expect files should be UPPER-CASE `EXPECT`, obviously.

Oh yeah, obviously? And then the CASE files, too, obviously, right? And then what about single-file test case scripts with natural text as their names? Should they also be "Startup with defaults.CASE"? I mean not that "Startup with defaults.case" would look any better, but capitals in the extension is a HIGHLY unusual habit, and may be offputting to some.

OK then... Make it configurable! :) See also #12 then!

Consider renaming `$CASE` to `$TEST_CASE`

E.g. these are some of the vars exported for a build, showing what I mean:

export TEST_NAME
export TEST_DIR
export CASE
export TEST_CASE_DIR
...

And... While we are at it:

  • Stop differentiating between the top level and the stuff below!
    This is a tree, and it should just be a purely recursive structure!
    • Or did I mean it specifically for the build support?! Fork the build-specific parts of this issue into another then!

"Bind" to specific bundled `busybox` versions in a designated "tight" mode? Or...?

Not to mention the current feature of also accepting Git's sh!... :-o

The issue is that busybox versions obviously differ vastly, so relying on "found" versions in a host env. is a hit-and-miss.
OTOH, bundling a version for every possible supported env. seems to be both futile and restrictive. (Or is it? First, it's only really necessary on Windows, and second, there seems to be a (32-bit?) "canonical" version at Ron's page anyway!...)

NOTE: now (-> #22) it's actually also being downloaded on-the-fly, too, so that's also an uncontrolled version dependency issue!

So, the tightening, and/or various levels of shell (mostly BB) version control part is still relevant!

Fix `run_cases name*` actually failing to match names with spaces!... ;)

Ehheh, OK, fine, fine... I meant "spaces in explicitly named test case names", it seems... :)

Anyway, it was an easy fix: just replacing $* with $@ in the main runner iterator loop, as per https://linux.die.net/man/1/ash:

 @     Expands to the positional parameters, starting from one. When the expansion occurs within
       double-quotes, each positional parameter expands as a separate argument. If there are
       no positional parameters, the expansion of @ generates zero arguments, even when @ is 
       double-quoted. 
       What this basically means, for example, is if $1 is ''abc'' and $2 is ''def ghi'', then "$@" expands 
       to the two arguments:
       "abc" "def ghi"

Workaround for the evil path-lookup discrepancy when invoking Git's `sh`

Well, there are two Git shs... Oh, wailt, three even, actually!... :-o And the "wrong" one is on the PATH here.

  1. On the PATH, unusable here: "C:\Program Files\Git\usr\bin\sh.exe"
  2. Not on the PATH, but the one we need: "C:\Program Files\Git\bin\sh.exe"
  3. And I have 0 clue what exactly this one does differently, but unusable too: "C:\Program Files\Git\git-bash.exe"

Test:

set "GITROOT=C:\Program Files\Git"
where sh.exe
rem        -> C:\Program Files\Git\usr\bin\sh.exe
where find
rem        -> C:\Windows\System32\find.exe
rem        -> C:\Program Files\Git\usr\bin\find.exe
@echo.
@echo This will use Windows's find.exe:
sh.exe -c "which find; find . -name '*.*'"
@echo.
@echo This will use Git's find:
"%GITROOT%\bin\sh.exe" -c "which find; find . -name '*.*'"
@echo.
@echo WTF is this trying to do?
"%GITROOT%\git-bash.exe" -c "which find; find . -name '*.*'"

Also, critically: don't forget -c (the error message is horribly misleading)!

>"...\sh.exe" find -- version
find: find: cannot execute binary file

So:

sh -c "find --version"

`run_cases` with wildcards is even more broken than I thought (in #20)

-> #20

$ run_cases *bui*
Riding "...\prj\Space_Test\test\_engine/busybox" sh...
"...\prj\Space_Test\test\_engine\busybox" sh -c ". build.sh \"test-demo\""
realpath: .../prj/Space_Test/test/*bui*: Invalid argument

ERROR: Test case "*bui*" not found!

-------- THERE HAVE BEEN FAILED CASES!

$ run_cases *exe*
Riding "...\prj\Space_Test\test\_engine/busybox" sh...
gnumake: 'test-demo.exe' is up to date.

ERROR: Test case "general.exe" not found!


ERROR: Test case "test-demo.exe" not found!

-------- THERE HAVE BEEN FAILED CASES!

Refine the examples etc.

Esp. this confusing one:

SH "echo Dir list:; ls -r"
SH echo command 3
EXPECT "Dir list:
Hi from the test case dir!
CASE
command 3
"

(And some other things below that.)

Get it back to running on Linux, too!

WSL:

.../prj/Space_Test/test$ ./run_cases
./run_cases: 213: [: gcc: unexpected operator
./run_cases: 280: [: gnumake: unexpected operator
./run_cases: 326: /mnt/c/sz/prj/Space_Test/test/_engine/init_once.sh: gnumake: not found
  • It's probably some bash vs. ash incompatibility regressions, mostly...
  • The direct gnumake dependency in functions.sh is gross... It's not even called "gnumake" by default. ;)
    • Either ship with one (err... for every platform?!... :)) ), or detect before calling!
    • Note: using BB-w32's built-in make would help even less here: a) it's only available there, on Windows, b) it's very limited, and c) there's likely an NMAKE also available there anyway...

Make it run (again) on Linux/WSL!

Currently:

>bash -c ./run_cases general
./run_cases: 12: [: unexpected operator
./run_cases: 48: [: 0: unexpected operator
-------- THERE HAVE BEEN FAILED CASES!  

Is even [ "x" == "y" ] a bashism, with that ==?!

-> shellcheck -s bash ...


Notes copied from a dup. (#48):

WSL:

.../prj/Space_Test/test$ ./run_cases
./run_cases: 213: [: gcc: unexpected operator
./run_cases: 280: [: gnumake: unexpected operator
./run_cases: 326: /mnt/c/sz/prj/Space_Test/test/_engine/init_once.sh: gnumake: not found
  • It's probably some bash vs. ash incompatibility regressions, mostly...
  • The direct gnumake dependency in functions.sh is gross... It's not even called "gnumake" by default. ;)
    • Either ship with one (err... for every platform?!... :)) ), or detect before calling!
    • Note: using BB-w32's built-in make would help even less here: a) it's only available there, on Windows, b) it's very limited, and c) there's likely an NMAKE also available there anyway...
  • Add a Linux GitHub Action, too!

Either give up the fragile Git sh support, or address it more explicitly!

Too much incompatibilities...
E.g. the makefiles can't just glue the build script path uniformly to $_SH_, because under Git sh it's /c/shit/..., while BB.exe has no problem with the normal C:/... paths... :-/

OTOH, if it's too explicit, or supports BB alone, then it may not just run fine in a native sh env as it should!...
But we could still stick to BB on Windows at least... (E.g. in cases where there's no $SHELL yet? Nope: $SHELL doesn't help with the Git sh vs BB_win32 path discrepancy!)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.