-
Notifications
You must be signed in to change notification settings - Fork 9
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
Refactor CLI, fix tests #58
Conversation
I think this PR gives Should we mention that there is no more default source document in the README or the CHANGELOG? (this feels like losing backwards compatibility and thus a major version bump) |
When I run
|
Whenever I use the
The hi
```
:::>> $ echo 'hi'
``` |
When I run this version against the cnb fixture, I am getting a ruby error at the very end of the execution.
|
The addition of metadata information such as screenshot directory (and friends) meant that every time some new key was added it needed to propagate through many different codepaths. This is solved by introducing a lifecycle "context" object that holds this state and can be extended. - The CLI class has been refactored so it can be tested. - The `Rundoc.project_root=` config option is being removed in favor of directly allowing file manipulation via ruby code in the `after_build` blocks. - Integration tests were not being executed, that's fixed. - Added an integration test for screenshots
The two basically did the same thing but one would show the result and the other would not. We already have a mechanism for hiding results or not via `>>` and `--` so lets use that instead.
Co-authored-by: Stella Yang <43301578+lilacstella@users.noreply.github.com>
Co-authored-by: Stella Yang <43301578+lilacstella@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ bin/rundoc test/fixtures/cnb/ruby/rundoc.md --on-success-dir=yay --force
## Success! sanitizing output
## Writing RUNdoc output to /var/folders/5n/dl9rnvh55t5bndgk2p_bxqx00000gn/T/d20240715-35761-q6esrf/README.md
## Running after build scripts
## Saving to yay
## Cleaning working directory /var/folders/5n/dl9rnvh55t5bndgk2p_bxqx00000gn/T/d20240715-35761-q6esrf
/Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2196:in `lstat': File name too long @ rb_file_s_lstat - /private/var/folders/5n/dl9rnvh55t5bndgk2p_bxqx00000gn/T/d20240715-35761-q6esrf/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/yay/ruby-getting-started/app/models/concerns/.keep (Errno::ENAMETOOLONG)
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2196:in `lstat'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2240:in `copy'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:1048:in `block in copy_entry'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2385:in `wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2388:in `block in wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `each'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2388:in `block in wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `each'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2388:in `block in wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `each'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2388:in `block in wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `each'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2388:in `block in wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `each'
...
... a lot of times
...
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2388:in `block in wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `each'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:1045:in `copy_entry'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:990:in `block in cp_r'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2469:in `block in fu_each_src_dest'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2483:in `fu_each_src_dest0'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2467:in `fu_each_src_dest'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:989:in `cp_r'
from /Users/stella.yang/Documents/rundoc/lib/rundoc/cli.rb:205:in `on_success'
from /Users/stella.yang/Documents/rundoc/lib/rundoc/cli.rb:156:in `block in call'
from /Users/stella.yang/Documents/rundoc/lib/rundoc/cli.rb:144:in `chdir'
from /Users/stella.yang/Documents/rundoc/lib/rundoc/cli.rb:144:in `call'
from bin/rundoc:19:in `<main>'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ bin/rundoc test/fixtures/cnb/ruby/rundoc.md
## Success! sanitizing output
## Writing RUNdoc output to /var/folders/5n/dl9rnvh55t5bndgk2p_bxqx00000gn/T/d20240715-42464-neu7b0/README.md
## Running after build scripts
## Saving to /Users/stella.yang/Documents/rundoc/test/fixtures/cnb/ruby/project
## Cleaning working directory /var/folders/5n/dl9rnvh55t5bndgk2p_bxqx00000gn/T/d20240715-42464-neu7b0
/Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2279:in `initialize': Permission denied @ rb_sysopen - /Users/stella.yang/Documents/rundoc/test/fixtures/cnb/ruby/project/./ruby-getting-started/.git/objects/pack/pack-f166dc4c4a9c5a7cf5d22d8c7887c625bc83560a.pack (Errno::EACCES)
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2279:in `open'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2279:in `block in copy_file'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2278:in `open'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2278:in `copy_file'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2243:in `copy'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:1048:in `block in copy_entry'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2385:in `wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2388:in `block in wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `each'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2388:in `block in wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `each'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2388:in `block in wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `each'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2388:in `block in wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `each'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2388:in `block in wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `each'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2387:in `wrap_traverse'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:1045:in `copy_entry'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:990:in `block in cp_r'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2469:in `block in fu_each_src_dest'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2483:in `fu_each_src_dest0'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:2467:in `fu_each_src_dest'
from /Users/stella.yang/.rubies/ruby-3.3.2/lib/ruby/3.3.0/fileutils.rb:989:in `cp_r'
from /Users/stella.yang/Documents/rundoc/lib/rundoc/cli.rb:216:in `copy_dir_contents'
from /Users/stella.yang/Documents/rundoc/lib/rundoc/cli.rb:206:in `on_success'
from /Users/stella.yang/Documents/rundoc/lib/rundoc/cli.rb:156:in `block in call'
from /Users/stella.yang/Documents/rundoc/lib/rundoc/cli.rb:144:in `chdir'
from /Users/stella.yang/Documents/rundoc/lib/rundoc/cli.rb:144:in `call'
from bin/rundoc:19:in `<main>'
ead40a7
to
6fb74e2
Compare
- `project` to `rundoc_output` - `tmp` to `rundoc_failure`
6fb74e2
to
f53e2ff
Compare
First I added a failing test: ``` SystemsCliTest#test_git: RuntimeError: Command: /Users/rschneeman/Documents/projects/rundoc/bin/rundoc /var/folders/yr/yytf3z3n3q336f1tj2b2j0gw0000gn/T/d20240715-22479-imrfiv/rundoc.md failed: ## Running your docs ## No .env file found /var/folders/yr/yytf3z3n3q336f1tj2b2j0gw0000gn/T/d20240715-22479-imrfiv/.env, skipping dotenv loading ## Working dir is /var/folders/yr/yytf3z3n3q336f1tj2b2j0gw0000gn/T/d20240715-22483-3l6enl Running: $ '(echo "hello world" >> lol.txt) 2>&1' Running: $ '(git init .) 2>&1' Initialized empty Git repository in /private/var/folders/yr/yytf3z3n3q336f1tj2b2j0gw0000gn/T/d20240715-22483-3l6enl/.git/ Running: $ '(git add .) 2>&1' Running: $ '(git commit -m first) 2>&1' [main (root-commit) bde4306] first 1 file changed, 1 insertion(+) create mode 100644 lol.txt Running: $ '(echo "so long and thanks for all the fish" >> lol.txt) 2>&1' Running: $ '(git add . && git commit -m second) 2>&1' [main 831f6dd] second 1 file changed, 1 insertion(+) ## Success! sanitizing output ## Writing RUNdoc output to /var/folders/yr/yytf3z3n3q336f1tj2b2j0gw0000gn/T/d20240715-22483-3l6enl/README.md ## Running after build scripts ## Saving to /var/folders/yr/yytf3z3n3q336f1tj2b2j0gw0000gn/T/d20240715-22479-imrfiv/rundoc_output ## Cleaning on success directory, /var/folders/yr/yytf3z3n3q336f1tj2b2j0gw0000gn/T/d20240715-22479-imrfiv/rundoc_output ## Cleaning working directory /var/folders/yr/yytf3z3n3q336f1tj2b2j0gw0000gn/T/d20240715-22483-3l6enl ## Cleaning tmp working directory, /var/folders/yr/yytf3z3n3q336f1tj2b2j0gw0000gn/T/d20240715-22483-3l6enl /Users/rschneeman/.rubies/ruby-3.3.1/lib/ruby/3.3.0/fileutils.rb:2279:in `initialize': Permission denied @ rb_sysopen - /var/folders/yr/yytf3z3n3q336f1tj2b2j0gw0000gn/T/d20240715-22479-imrfiv/rundoc_output/./.git/objects/3b/18e512dba79e4c8300dd08aeb37f8e728b8dad (Errno::EACCES) ``` Then I fixed it, by: Moving the directory instead of copying it before deleting the working tmpdir. I don't know why this works, but it does.
f53e2ff
to
7babc8f
Compare
Error was related to git and file permissions, this seems to fix it 7babc8f. Tests are passing again. Requesting re-review. |
Rundoc.project_root=
config option is being removed in favor of directly allowing file manipulation via ruby code in theafter_build
blocks.rundoc.depend_on
in favor of::-- rundoc.require