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

Refactor CLI, fix tests #58

Merged
merged 24 commits into from
Jul 16, 2024
Merged

Refactor CLI, fix tests #58

merged 24 commits into from
Jul 16, 2024

Conversation

schneems
Copy link
Member

  • 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
  • Remove rundoc.depend_on in favor of ::-- rundoc.require

@schneems schneems marked this pull request as ready for review July 10, 2024 20:28
@lilacstella lilacstella self-requested a review July 10, 2024 21:02
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@lilacstella
Copy link
Contributor

lilacstella commented Jul 11, 2024

I think this PR gives rundoc so much QoL that I imagined there to exist when I was introduced to the idea of this tool. These changes are amazing and I just have a few things to smooth over.

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)

@lilacstella
Copy link
Contributor

lilacstella commented Jul 11, 2024

When I run rundoc build I get a ruby error instead of a nice shell help message.

$ bin/rundoc build

bin/rundoc:59:in `exist?': no implicit conversion of nil into String (TypeError)

    if !File.exist?(@path)
                    ^^^^^
	from bin/rundoc:59:in `build'
	from .../ruby/3.3.2/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
	from .../ruby/3.3.2/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
	from .../ruby/3.3.2/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
	from .../ruby/3.3.2/gems/thor-1.3.1/lib/thor/base.rb:584:in `start'
	from bin/rundoc:76:in `<main>'

@lilacstella
Copy link
Contributor

lilacstella commented Jul 11, 2024

Whenever I use the --on-successful-dir and --on-failure-dir arguments, I get ruby errors.

$ bin/rundoc build --path=rundoc.md --on-success-dir=yay --on-failure-dir=sad

## Running your docs
## No .env file found /Users/stella.yang/Documents/rundoc/.env, skipping dotenv loading
## Clearing on failure directory sad
## Cleaning working directory /var/folders/5n/dl9rnvh55t5bndgk2p_bxqx00000gn/T/d20240711-18299-vms2hf
/Users/stella.yang/Documents/rundoc/lib/rundoc/cli.rb:121:in `ensure in call': undefined method `exist?' for an instance of String (NoMethodError)

        FileUtils.remove_entry_secure(execution_context.output_dir) if on_failure_dir.exist?
                                                                                     ^^^^^^^
	from /Users/stella.yang/Documents/rundoc/lib/rundoc/cli.rb:121:in `call'
	from bin/rundoc:72:in `build'
	from /Users/stella.yang/.gem/ruby/3.3.2/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
	from /Users/stella.yang/.gem/ruby/3.3.2/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/stella.yang/.gem/ruby/3.3.2/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
	from /Users/stella.yang/.gem/ruby/3.3.2/gems/thor-1.3.1/lib/thor/base.rb:584:in `start'
	from bin/rundoc:76:in `<main>'
/Users/stella.yang/Documents/rundoc/lib/rundoc/cli.rb:93:in `call': undefined method `exist?' for an instance of String (NoMethodError)

      FileUtils.remove_entry_secure(on_failure_dir) if on_failure_dir.exist?
                                                                     ^^^^^^^
	from bin/rundoc:72:in `build'
	from /Users/stella.yang/.gem/ruby/3.3.2/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
	from /Users/stella.yang/.gem/ruby/3.3.2/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/stella.yang/.gem/ruby/3.3.2/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
	from /Users/stella.yang/.gem/ruby/3.3.2/gems/thor-1.3.1/lib/thor/base.rb:584:in `start'

The rundoc.md is a hello world document. The content is as follows:

hi

```
:::>> $ echo 'hi'
```

@lilacstella
Copy link
Contributor

lilacstella commented Jul 12, 2024

When I run this version against the cnb fixture, I am getting a ruby error at the very end of the execution.

$ bin/rundoc build --path=test/fixtures/cnb/ruby/rundoc.md

...
...
## Rundoc was successful, sanitizing output
## Writing RUNdoc output to /var/folders/5n/dl9rnvh55t5bndgk2p_bxqx00000gn/T/d20240711-37789-qcibrm/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/d20240711-37789-qcibrm
/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:168:in `copy_dir_contents'
	from /Users/stella.yang/Documents/rundoc/lib/rundoc/cli.rb:158:in `on_success'
	from /Users/stella.yang/Documents/rundoc/lib/rundoc/cli.rb:108:in `block in call'
	from /Users/stella.yang/Documents/rundoc/lib/rundoc/cli.rb:96:in `chdir'
	from /Users/stella.yang/Documents/rundoc/lib/rundoc/cli.rb:96:in `call'
	from bin/rundoc:72:in `build'
	from /Users/stella.yang/.gem/ruby/3.3.2/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
	from /Users/stella.yang/.gem/ruby/3.3.2/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/stella.yang/.gem/ruby/3.3.2/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
	from /Users/stella.yang/.gem/ruby/3.3.2/gems/thor-1.3.1/lib/thor/base.rb:584:in `start'
	from bin/rundoc:76:in `<main>'

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@schneems schneems requested a review from lilacstella July 15, 2024 16:48
schneems and others added 16 commits July 15, 2024 13:00
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>
Copy link
Contributor

@lilacstella lilacstella left a 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>'

Copy link
Contributor

@lilacstella lilacstella left a 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>'

@schneems schneems force-pushed the schneems/refactor-cli branch from ead40a7 to 6fb74e2 Compare July 15, 2024 18:26
- `project` to `rundoc_output`
- `tmp` to `rundoc_failure`
@schneems schneems force-pushed the schneems/refactor-cli branch from 6fb74e2 to f53e2ff Compare July 15, 2024 19:53
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.
@schneems schneems force-pushed the schneems/refactor-cli branch from f53e2ff to 7babc8f Compare July 15, 2024 19:54
@schneems
Copy link
Member Author

Error was related to git and file permissions, this seems to fix it 7babc8f. Tests are passing again. Requesting re-review.

@schneems schneems requested a review from lilacstella July 15, 2024 19:59
@schneems schneems merged commit a30de2a into main Jul 16, 2024
13 checks passed
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