doc/tutorial/basics: make test scripts run again
The test scripts have been silently skipped since
https://cue-review.googlesource.com/c/cue/+/6081 was merged in mid 2020.
The reason is that the following bit of code:
if !info.IsDir() {
return nil
}
was replaced with
if info.IsDir() {
return filepath.SkipDir
}
The old code simply ran testscript on each directory found under the
current directory, which makes sense as we have a handful of directories
containing testscript files.
The new code, however, would skip all directories. Crucially, the walk
begins at the root directory, so it wouldn't do any walking at all.
This wasn't picked up for over two years, as it's hard to notice when
tests stop working completely. They behave almost exactly like passing
tests, except perhaps that they take nearly no time at all.
Fix the test code so that they run again. We could keep using directory
walking, but we don't really need to: ReadDir is enough, combined with a
regexp to match directories that follow the n_ABC naming pattern. It's
also simpler, and we can complain if we find zero directories.
In the process we also fix the tutorial tests that are broken. These
changes fall into a number of categories:
* Whitespace differences in output (indenting, formatting of CUE).
* Simple updates to output; ordering of fields or detail in error
messages.
* Whilst we await a fix for #1786, we drop use of the -i (or --ignore)
flag, output stderr instead of stdout, and expect command failure.
These changes can be undone if/when we fix #1786. Or we can leave
with stderr, on the basis this is the more likely experience for a
user.
Rename doc/tutorial/basics/0_intro/10_json.txtarar =>
doc/tutorial/basics/0_intro/10_json.txtar too.
A number of tutorial entries no longer make sense in the context of
changes that have happened over time, but we leave those semantic and
content changes for later, instead focussing on fixing up broken test
cases for now.
The result of this CL has been previewed for cuelang.org in:
https://github.com/cue-lang/cuelang.org/pull/267
Fixes #1884.
Co-authored-by: Paul Jolly <paul@myitcv.io>
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I662b5c0fee6deb072441e4fe9d2c1c6ec99ea22a
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/542692
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
authored by