rundoc 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89f953193be8aea0831e65e251a1d0cc8a3796573fe5818a6eb4ae2ed0e489d4
4
- data.tar.gz: 9ea2f3a42906fa0c79cbb39862ec5300b4688dcce15df8991cf0a99e2d7c60da
3
+ metadata.gz: 87495a9fcbdf3fa9a146b633d84f62294bd400b32f806d975db0b372ce6c4f31
4
+ data.tar.gz: c50e2b6dbcbb2e313753d1341a17b56208118b10bd20462768348cae56cb3dda
5
5
  SHA512:
6
- metadata.gz: 4aba6794da79ce27d6a4072e0cda4c7e2525030f0bd7c7925aaca8708a3adbd2632a0bb32c2ea451bc5f58ebc4a674ab4012ec6ddaeae7114ffbcefbafb53b35
7
- data.tar.gz: fef87625649965fdd3dd5817e55d73299e1ebf67cfb3f9895c45d2c26b410af566f43540490a7c4ec7198b31f86d9c14079701b25981f7689b99644775f8e55f
6
+ metadata.gz: 3e34467cf37d802daf82bb6fd8e81a4ecb4af426bc1645151e7d420dec131e4493b4e5f8ba78de3393bdc84a4de97dbc908434f4e1f06a895fc9002ca72611a5
7
+ data.tar.gz: 6971fa4915f79d81d1b6e6dd05f10e45e116f7388ae4c5ffd8b8ad1e9dc28be9c7882b11c6f315934b210281508fc17edb722969497fd951780befcb1d66eef2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## HEAD
2
2
 
3
+ ## 3.0.2
4
+
5
+ - Fix: Partial output of the document is now written to disk in a `RUNDOC_FAILED.md` file (https://github.com/zombocom/rundoc/pull/69)
6
+
3
7
  ## 3.0.1
4
8
 
5
9
  - Fix: Save in-progress work in the "failure" directory when the rundoc command is interrupted via a signal such as `SIGTERM` (https://github.com/zombocom/rundoc/pull/67)
data/lib/rundoc/cli.rb CHANGED
@@ -152,7 +152,7 @@ module Rundoc
152
152
  output = begin
153
153
  parser.to_md
154
154
  rescue StandardError, SignalException => e
155
- warn "Received exception: #{e.inspect}, cleaning up before re-raise"
155
+ io.puts "Received exception: #{e.inspect}, cleaning up before re-raise"
156
156
  on_fail
157
157
  raise e
158
158
  end
@@ -190,6 +190,8 @@ module Rundoc
190
190
  from: execution_context.output_dir,
191
191
  to: on_failure_dir
192
192
  )
193
+
194
+ on_failure_dir.join("RUNDOC_FAILED.md").write(Rundoc::CodeSection.partial_result_to_doc)
193
195
  end
194
196
 
195
197
  private def on_success(output)
@@ -30,6 +30,9 @@ module Rundoc
30
30
  AUTOGEN_WARNING = "\n<!-- STOP. This document is autogenerated. Do not manually modify. See the top of the doc for more details. -->"
31
31
  attr_accessor :original, :fence, :lang, :code, :commands, :keyword
32
32
 
33
+ PARTIAL_RESULT = []
34
+ PARTIAL_ENV = {}
35
+
33
36
  def initialize(match, keyword:, context:)
34
37
  @original = match.to_s
35
38
  @commands = []
@@ -40,6 +43,8 @@ module Rundoc
40
43
  @lang = match[:lang]
41
44
  @code = match[:contents]
42
45
  parse_code_command
46
+ PARTIAL_RESULT.clear
47
+ PARTIAL_ENV.clear
43
48
  end
44
49
 
45
50
  def render
@@ -69,10 +74,21 @@ module Rundoc
69
74
  tmp_result << code_output if code_command.render_result?
70
75
 
71
76
  result << tmp_result unless code_command.hidden?
77
+
78
+ PARTIAL_RESULT.replace(result)
79
+ PARTIAL_ENV.replace(env)
72
80
  end
73
81
 
74
82
  return "" if hidden?
75
83
 
84
+ self.class.to_doc(result: result, env: env)
85
+ end
86
+
87
+ def self.partial_result_to_doc
88
+ to_doc(result: PARTIAL_RESULT, env: PARTIAL_ENV)
89
+ end
90
+
91
+ def self.to_doc(result:, env:)
76
92
  array = [env[:before]]
77
93
 
78
94
  result.flatten!
@@ -1,3 +1,3 @@
1
1
  module Rundoc
2
- VERSION = "3.0.1"
2
+ VERSION = "3.0.2"
3
3
  end
@@ -0,0 +1,46 @@
1
+ require "test_helper"
2
+
3
+ class IntegrationFailureTest < Minitest::Test
4
+ def test_writes_to_dir_on_failure
5
+ Dir.mktmpdir do |dir|
6
+ Dir.chdir(dir) do
7
+ dir = Pathname(dir)
8
+
9
+ source_path = dir.join("RUNDOC.md")
10
+ source_path.write <<~EOF
11
+ ```
12
+ :::>> $ mkdir lol
13
+ :::>> $ touch lol/rofl.txt
14
+ :::>> $ touch does/not/exist.txt
15
+ ```
16
+ EOF
17
+
18
+ io = StringIO.new
19
+
20
+ error = nil
21
+ begin
22
+ Rundoc::CLI.new(
23
+ io: io,
24
+ source_path: source_path,
25
+ on_success_dir: dir.join(SUCCESS_DIRNAME)
26
+ ).call
27
+ rescue => e
28
+ error = e
29
+ end
30
+
31
+ assert error
32
+ assert_includes error.message, "exited with non zero status"
33
+
34
+ refute dir.join(SUCCESS_DIRNAME).join("lol").exist?
35
+ refute dir.join(SUCCESS_DIRNAME).join("lol").join("rofl.txt").exist?
36
+
37
+ assert dir.join(FAILURE_DIRNAME).join("lol").exist?
38
+ assert dir.join(FAILURE_DIRNAME).join("lol").join("rofl.txt").exist?
39
+
40
+ doc = dir.join(FAILURE_DIRNAME).join("RUNDOC_FAILED.md").read
41
+ assert_includes doc, "$ mkdir lol"
42
+ assert_includes doc, "$ touch lol/rofl.txt"
43
+ end
44
+ end
45
+ end
46
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rundoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Schneeman
@@ -261,6 +261,7 @@ files:
261
261
  - test/fixtures/screenshot/rundoc.md
262
262
  - test/fixtures/simple_git/rundoc.md
263
263
  - test/integration/after_build_test.rb
264
+ - test/integration/failure_test.rb
264
265
  - test/integration/print_test.rb
265
266
  - test/integration/require_test.rb
266
267
  - test/integration/website_test.rb