-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously if a command failed you lose the resulting doc, including everything up to that point which might be salvalgable. With this change a partial result is written to disk on failure.
- Loading branch information
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require "test_helper" | ||
|
||
class IntegrationFailureTest < Minitest::Test | ||
def test_writes_to_dir_on_failure | ||
Dir.mktmpdir do |dir| | ||
Dir.chdir(dir) do | ||
dir = Pathname(dir) | ||
|
||
source_path = dir.join("RUNDOC.md") | ||
source_path.write <<~EOF | ||
``` | ||
:::>> $ mkdir lol | ||
:::>> $ touch lol/rofl.txt | ||
:::>> $ touch does/not/exist.txt | ||
``` | ||
EOF | ||
|
||
io = StringIO.new | ||
|
||
error = nil | ||
begin | ||
Rundoc::CLI.new( | ||
io: io, | ||
source_path: source_path, | ||
on_success_dir: dir.join(SUCCESS_DIRNAME) | ||
).call | ||
rescue => e | ||
error = e | ||
end | ||
|
||
assert error | ||
assert_includes error.message, "exited with non zero status" | ||
|
||
refute dir.join(SUCCESS_DIRNAME).join("lol").exist? | ||
refute dir.join(SUCCESS_DIRNAME).join("lol").join("rofl.txt").exist? | ||
|
||
assert dir.join(FAILURE_DIRNAME).join("lol").exist? | ||
assert dir.join(FAILURE_DIRNAME).join("lol").join("rofl.txt").exist? | ||
|
||
doc = dir.join(FAILURE_DIRNAME).join("RUNDOC_FAILED.md").read | ||
assert_includes doc, "$ mkdir lol" | ||
assert_includes doc, "$ touch lol/rofl.txt" | ||
end | ||
end | ||
end | ||
end |