livetext 0.9.11 → 0.9.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +4 -4
  2. data/README.lt3 +2 -2
  3. data/lib/cmdargs.rb +93 -0
  4. data/lib/errors.rb +15 -0
  5. data/lib/formatline.rb +59 -88
  6. data/lib/functions.rb +6 -2
  7. data/lib/handler/icanhaz.rb +35 -0
  8. data/lib/handler.rb +1 -0
  9. data/lib/helpers.rb +194 -0
  10. data/lib/html.rb +32 -0
  11. data/lib/livetext/importable.rb +2 -0
  12. data/lib/livetext.rb +35 -152
  13. data/lib/parser/file.rb +8 -0
  14. data/lib/parser/general.rb +38 -0
  15. data/lib/parser/import.rb +15 -0
  16. data/lib/parser/mixin.rb +38 -0
  17. data/lib/parser/set.rb +145 -0
  18. data/lib/parser/string.rb +70 -0
  19. data/lib/parser.rb +5 -0
  20. data/lib/processor.rb +23 -27
  21. data/lib/standard.rb +164 -346
  22. data/lib/userapi.rb +3 -5
  23. data/livetext.gemspec +1 -2
  24. data/plugin/bookish.rb +26 -22
  25. data/plugin/calibre.rb +1 -1
  26. data/plugin/livemagick.rb +10 -10
  27. data/plugin/markdown.rb +13 -11
  28. data/plugin/pyggish.rb +94 -84
  29. data/plugin/tutorial.rb +10 -5
  30. data/test/all.rb +3 -0
  31. data/test/snapshots/OMIT.txt +11 -0
  32. data/test/{data → snapshots}/basic_formatting/expected-error.txt +0 -0
  33. data/test/{data → snapshots}/basic_formatting/expected-output.txt +0 -0
  34. data/test/{data → snapshots}/basic_formatting/source.lt3 +0 -0
  35. data/test/{data → snapshots}/block_comment/expected-error.txt +0 -0
  36. data/test/{data → snapshots}/block_comment/expected-output.txt +0 -0
  37. data/test/{data → snapshots}/block_comment/source.lt3 +0 -0
  38. data/test/snapshots/clusion.txt +70 -0
  39. data/test/{data → snapshots}/comments_ignored_1/expected-error.txt +0 -0
  40. data/test/{data → snapshots}/comments_ignored_1/expected-output.txt +0 -0
  41. data/test/{data → snapshots}/comments_ignored_1/source.lt3 +0 -0
  42. data/test/{data → snapshots}/copy_is_raw/expected-error.txt +0 -0
  43. data/test/{data → snapshots}/copy_is_raw/expected-output.txt +0 -0
  44. data/test/{data → snapshots}/copy_is_raw/rawtext.inc +0 -0
  45. data/test/{data → snapshots}/copy_is_raw/source.lt3 +0 -0
  46. data/test/{data → snapshots}/crap +0 -0
  47. data/test/{data → snapshots}/def_method/expected-error.txt +0 -0
  48. data/test/{data → snapshots}/def_method/expected-output.txt +0 -0
  49. data/test/{data → snapshots}/def_method/source.lt3 +0 -0
  50. data/test/{data → snapshots}/error_inc_line_num/expected-output.txt +0 -0
  51. data/test/{data → snapshots}/error_inc_line_num/file2.lt3 +0 -0
  52. data/test/snapshots/error_inc_line_num/match-error.txt +1 -0
  53. data/test/{data → snapshots}/error_inc_line_num/source.lt3 +0 -0
  54. data/test/{data → snapshots}/error_invalid_name/expected-output.txt +0 -0
  55. data/test/snapshots/error_invalid_name/match-error.txt +1 -0
  56. data/test/{data → snapshots}/error_invalid_name/source.lt3 +0 -0
  57. data/test/{data → snapshots}/error_line_num/expected-output.txt +0 -0
  58. data/test/snapshots/error_line_num/match-error.txt +1 -0
  59. data/test/{data → snapshots}/error_line_num/source.lt3 +0 -0
  60. data/test/{data → snapshots}/error_mismatched_end/expected-output.txt +0 -2
  61. data/test/snapshots/error_mismatched_end/match-error.txt +1 -0
  62. data/test/{data → snapshots}/error_mismatched_end/source.lt3 +0 -0
  63. data/test/{data → snapshots}/error_missing_end/expected-output.txt +0 -0
  64. data/test/snapshots/error_missing_end/match-error.txt +1 -0
  65. data/test/{data → snapshots}/error_missing_end/source.lt3 +0 -0
  66. data/test/{data/error_no_such_mixin → snapshots/error_name_not_permitted}/expected-output.txt +0 -0
  67. data/test/snapshots/error_name_not_permitted/match-error.txt +1 -0
  68. data/test/{data → snapshots}/error_name_not_permitted/source.lt3 +0 -0
  69. data/test/{data → snapshots}/error_no_such_copy/expected-output.txt +0 -5
  70. data/test/snapshots/error_no_such_copy/match-error.txt +1 -0
  71. data/test/{data → snapshots}/error_no_such_copy/source.lt3 +0 -1
  72. data/test/{data → snapshots}/error_no_such_inc/expected-output.txt +0 -4
  73. data/test/snapshots/error_no_such_inc/match-error.txt +1 -0
  74. data/test/{data → snapshots}/error_no_such_inc/source.lt3 +0 -0
  75. data/test/snapshots/error_no_such_mixin/expected-output.txt +5 -0
  76. data/test/snapshots/error_no_such_mixin/match-error.txt +1 -0
  77. data/test/{data → snapshots}/error_no_such_mixin/source.lt3 +0 -0
  78. data/test/{data → snapshots}/example_alpha/expected-error.txt +0 -0
  79. data/test/{data → snapshots}/example_alpha/expected-output.txt +0 -0
  80. data/test/{data → snapshots}/example_alpha/source.lt3 +0 -0
  81. data/test/{data → snapshots}/example_alpha2/expected-error.txt +0 -0
  82. data/test/{data → snapshots}/example_alpha2/expected-output.txt +0 -0
  83. data/test/{data → snapshots}/example_alpha2/source.lt3 +0 -0
  84. data/test/{data → snapshots}/fixit +0 -0
  85. data/test/{data → snapshots}/functions/expected-error.txt +0 -0
  86. data/test/{data → snapshots}/functions/expected-output.txt +0 -0
  87. data/test/{data → snapshots}/functions/source.lt3 +0 -0
  88. data/test/{data → snapshots}/hello_world/expected-error.txt +0 -0
  89. data/test/{data → snapshots}/hello_world/expected-output.txt +0 -0
  90. data/test/{data → snapshots}/hello_world/source.lt3 +0 -0
  91. data/test/snapshots/icanhaz/expected-output.txt +5 -0
  92. data/test/snapshots/icanhaz/match-error.txt +1 -0
  93. data/test/snapshots/icanhaz/simple_import.rb +5 -0
  94. data/test/snapshots/icanhaz/source.lt3 +10 -0
  95. data/test/{data/more_complex_vars → snapshots/icanhaz2}/expected-error.txt +0 -0
  96. data/test/snapshots/icanhaz2/expected-output.txt +6 -0
  97. data/test/snapshots/icanhaz2/simple_canhaz.rb +5 -0
  98. data/test/snapshots/icanhaz2/source.lt3 +6 -0
  99. data/test/{data/predef_vars → snapshots/more_complex_vars}/expected-error.txt +0 -0
  100. data/test/{data → snapshots}/more_complex_vars/expected-output.txt +0 -0
  101. data/test/{data → snapshots}/more_complex_vars/source.lt3 +0 -0
  102. data/test/{data/raw_lines → snapshots/predef_vars}/expected-error.txt +0 -0
  103. data/test/snapshots/predef_vars/match-output.txt +6 -0
  104. data/test/{data → snapshots}/predef_vars/source.lt3 +0 -0
  105. data/test/{data/raw_text_block → snapshots/raw_lines}/expected-error.txt +0 -0
  106. data/test/{data → snapshots}/raw_lines/expected-output.txt +0 -0
  107. data/test/{data → snapshots}/raw_lines/source.lt3 +0 -0
  108. data/test/{data/simple_copy → snapshots/raw_text_block}/expected-error.txt +0 -0
  109. data/test/{data → snapshots}/raw_text_block/expected-output.txt +0 -0
  110. data/test/{data → snapshots}/raw_text_block/rawtext.inc +0 -0
  111. data/test/{data → snapshots}/raw_text_block/source.lt3 +0 -0
  112. data/test/{data/simple_include → snapshots/simple_copy}/expected-error.txt +0 -0
  113. data/test/{data → snapshots}/simple_copy/expected-output.txt +0 -0
  114. data/test/{data → snapshots}/simple_copy/simplefile.inc +0 -0
  115. data/test/{data → snapshots}/simple_copy/source.lt3 +0 -0
  116. data/test/{data/simple_mixin → snapshots/simple_import}/expected-error.txt +0 -0
  117. data/test/snapshots/simple_import/expected-output.txt +7 -0
  118. data/test/snapshots/simple_import/simple_import.rb +5 -0
  119. data/test/snapshots/simple_import/source.lt3 +7 -0
  120. data/test/{data/simple_vars → snapshots/simple_include}/expected-error.txt +0 -0
  121. data/test/{data → snapshots}/simple_include/expected-output.txt +0 -0
  122. data/test/{data → snapshots}/simple_include/simplefile.inc +0 -0
  123. data/test/{data → snapshots}/simple_include/source.lt3 +0 -1
  124. data/test/{data/single_raw_line → snapshots/simple_mixin}/expected-error.txt +0 -0
  125. data/test/{data → snapshots}/simple_mixin/expected-output.txt +0 -0
  126. data/test/{data → snapshots}/simple_mixin/simple_mixin.rb +0 -0
  127. data/test/{data → snapshots}/simple_mixin/source.lt3 +0 -0
  128. data/test/{data/table_with_heredocs → snapshots/simple_vars}/expected-error.txt +0 -0
  129. data/test/{data → snapshots}/simple_vars/expected-output.txt +0 -0
  130. data/test/{data → snapshots}/simple_vars/source.lt3 +0 -0
  131. data/test/{data/subset.txt → snapshots/single_raw_line/expected-error.txt} +0 -0
  132. data/test/{data → snapshots}/single_raw_line/expected-output.txt +0 -0
  133. data/test/{data → snapshots}/single_raw_line/source.lt3 +0 -0
  134. data/test/snapshots/subset.txt +0 -0
  135. data/test/snapshots/table_with_heredocs/expected-error.txt +0 -0
  136. data/test/{data → snapshots}/table_with_heredocs/expected-output.txt +0 -0
  137. data/test/{data → snapshots}/table_with_heredocs/source.lt3 +0 -0
  138. data/test/snapshots.rb +177 -0
  139. data/test/testlines.rb +2 -2
  140. data/test/unit/all.rb +4 -0
  141. data/test/unit/formatline.rb +650 -0
  142. data/test/unit/html.rb +38 -0
  143. data/test/unit/parser/all.rb +3 -0
  144. data/test/unit/parser/general.rb +59 -0
  145. data/test/unit/parser/importable.rb +19 -0
  146. data/test/unit/parser/mixin.rb +19 -0
  147. data/test/unit/parser/set.rb +164 -0
  148. data/test/unit/parser/string.rb +130 -0
  149. data/test/unit/parser.rb +6 -0
  150. data/test/unit/standard.rb +23 -0
  151. data/test/unit/stringparser.rb +140 -0
  152. metadata +137 -100
  153. data/test/data/error_inc_line_num/FOO +0 -21
  154. data/test/data/error_inc_line_num/expected-err-line1match.txt +0 -1
  155. data/test/data/error_invalid_name/expected-err-line1match.txt +0 -1
  156. data/test/data/error_line_num/expected-err-line1match.txt +0 -1
  157. data/test/data/error_mismatched_end/expected-err-line1match.txt +0 -1
  158. data/test/data/error_missing_end/ERR +0 -32
  159. data/test/data/error_missing_end/expected-err-line1match.txt +0 -1
  160. data/test/data/error_name_not_permitted/expected-error.txt +0 -1
  161. data/test/data/error_name_not_permitted/expected-output.txt +0 -4
  162. data/test/data/error_no_such_copy/expected-err-line1match.txt +0 -1
  163. data/test/data/error_no_such_inc/expected-err-line1match.txt +0 -1
  164. data/test/data/error_no_such_mixin/expected-err-line1match.txt +0 -1
  165. data/test/data/lines.txt +0 -124
  166. data/test/data/predef_vars/expected-output.txt +0 -6
  167. data/test/formatting.rb +0 -110
  168. data/test/test.rb +0 -140
@@ -0,0 +1,70 @@
1
+ # This file specifies which snapshots will/won't be run.
2
+
3
+ # Blank lines and comments are ignored.
4
+ # Other lines: name_of_snapshot and any comments here are ignored (no # needed)
5
+
6
+ # i to include, x to exclude
7
+
8
+ x error_no_such_inc # Output BEFORE error doesn't get passed through ("leading" output)
9
+ x error_no_such_copy # ^ Same behavior as error_no_such_inc
10
+ x error_no_such_mixin # ^ Same behavior as error_missing_end
11
+ x error_invalid_name # ^ Same behavior as error_no_such_inc
12
+ x error_missing_end # Output is duplicated somehow. Look for: puts @body or puts @main.body
13
+ x error_inc_line_num # Forgot what's wrong here
14
+
15
+ # Dummy command .icanhaz works like .mixin or .import
16
+
17
+ x icanhaz # "Leading" output doesn't get generated (same as error_no_such_inc)
18
+ icanhaz2
19
+
20
+ # Others (usually passing):
21
+
22
+ # import/include/mixin, others...
23
+
24
+ simple_copy #
25
+ simple_import #
26
+ simple_include #
27
+ simple_mixin #
28
+
29
+ # raw input
30
+
31
+ single_raw_line #
32
+ raw_lines #
33
+ raw_text_block #
34
+ copy_is_raw #
35
+
36
+ # comments
37
+
38
+ block_comment #
39
+ comments_ignored_1 #
40
+
41
+ # variables and heredocs
42
+
43
+ predef_vars #
44
+ simple_vars #
45
+ more_complex_vars #
46
+ table_with_heredocs #
47
+
48
+ # testing def
49
+
50
+ def_method #
51
+
52
+ # intraline formatting
53
+
54
+ basic_formatting #
55
+
56
+ # Errors
57
+
58
+ error_line_num #
59
+ error_mismatched_end #
60
+ error_name_not_permitted #
61
+
62
+ # functions
63
+
64
+ functions #
65
+
66
+ # More/misc...
67
+
68
+ example_alpha #
69
+ example_alpha2 #
70
+ hello_world #
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ 1 /Name 'foobar' is unknown/
@@ -0,0 +1 @@
1
+ 1 /name 'to_s' is invalid/
@@ -0,0 +1 @@
1
+ 1 /Name 'foobar' is unknown/
File without changes
@@ -4,5 +4,3 @@ without something
4
4
  beginning a block:
5
5
  <p>
6
6
 
7
- foo bar
8
- baz
@@ -0,0 +1 @@
1
+ 1 /found .end with no opening command/
@@ -0,0 +1 @@
1
+ 1 /Expected .end, found end of file/
@@ -0,0 +1 @@
1
+ 1 /Disallowed/
@@ -2,8 +2,3 @@ Make sure a
2
2
  nonexistent file with .copy
3
3
  gives an error.
4
4
  <p>
5
-
6
- <p>
7
-
8
- Nothing to
9
- see here.
@@ -0,0 +1 @@
1
+ 1 /file nosuchfile.txt not found/
@@ -1,4 +1,3 @@
1
- .debug
2
1
  Make sure a
3
2
  nonexistent file with .copy
4
3
  gives an error.
@@ -3,7 +3,3 @@ a nonexistent include
3
3
  will give an error.
4
4
  <p>
5
5
 
6
- <p>
7
-
8
- Nothing to
9
- see here.
@@ -0,0 +1 @@
1
+ 1 /file nosuchinc.lt3 not found/
@@ -0,0 +1,5 @@
1
+ Test that
2
+ we give an error
3
+ when a mixin does not
4
+ exist:
5
+ <p>
@@ -0,0 +1 @@
1
+ 1 /No such mixin 'nosuchthing'/
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ Test fake command .icanhaz:
2
+ we give an error
3
+ when a .rb does not
4
+ exist:
5
+ <p>
@@ -0,0 +1 @@
1
+ 1 /No such mixin 'nonexistent'/
@@ -0,0 +1,5 @@
1
+ module SimpleImport
2
+ def hello_world
3
+ _out "Hello, world."
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ Test fake command .icanhaz:
2
+ we give an error
3
+ when a .rb does not
4
+ exist:
5
+
6
+ .icanhaz nonexistent
7
+
8
+ We shouldn't
9
+ reach this point
10
+ in the file.
@@ -0,0 +1,6 @@
1
+ Testing fake command .icanhaz:
2
+ <p>
3
+
4
+ Now call a method:
5
+ Hello, world.
6
+ That's all.
@@ -0,0 +1,5 @@
1
+ module SimpleImport
2
+ def hello_world
3
+ _out "Hello, world."
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ Testing fake command .icanhaz:
2
+
3
+ .icanhaz simple_canhaz
4
+ Now call a method:
5
+ .hello_world
6
+ That's all.
@@ -0,0 +1,6 @@
1
+ 1 Here we go...
2
+ 2 File = source.lt3
3
+ 3 /FileDir = .*.test.snapshots.predef_vars/
4
+ 4 /User = [A-Za-z][A-Za-z0-9]*/
5
+ 5 /Version = 0\.\d{1,2}\.\d{1,2}/
6
+ 6 NoSuchVar = [NoSuchVar is undefined]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ Here I am
2
+ testing a simple import
3
+ <p>
4
+
5
+ Now call a method:
6
+ Hello, world.
7
+ That's all.
@@ -0,0 +1,5 @@
1
+ module SimpleImport
2
+ def hello_world
3
+ _out "Hello, world."
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ Here I am
2
+ testing a simple import
3
+ .mixin simple_import
4
+
5
+ Now call a method:
6
+ .hello_world
7
+ That's all.
@@ -1,5 +1,4 @@
1
1
  Here I am
2
- .debug
3
2
  trying to
4
3
  include
5
4
  .include simplefile.inc
File without changes
File without changes
File without changes
File without changes
data/test/snapshots.rb ADDED
@@ -0,0 +1,177 @@
1
+ require 'minitest/autorun'
2
+
3
+ require_relative '../lib/livetext'
4
+
5
+ =begin
6
+ Snapshots...
7
+
8
+ NOTE that the external_files method has been replaced by the Snapshot class.
9
+
10
+ You can add any ordinary test method above. But so far, most of these tests simply
11
+ call Snapshot.new
12
+
13
+ It works this way:
14
+ - If the test (caller) method is test_my_silly_feature, then we will
15
+ look for a directory called snapshots/my_silly_feature
16
+ - In here, there must be a source.lt3
17
+ - ...and also either expected-output.txt OR match-output.txt (not both)
18
+ - ...and also either expected-error.txt OR match-error.txt (not both)
19
+ - Technically, any existing file can be empty
20
+ - The expected-* files are "literal" data
21
+ * compared byte-for-byte
22
+ * watch spaces and bad regexes, etc. #duh
23
+ * each of these files corresponds to a single assertion
24
+ - A match-* file has two entries per line:
25
+ * a ONE-BASED line number (in actual-* file)
26
+ * a String OR a Regexp (to match against that line)
27
+ * If there is nonsense here, it currently isn't caught
28
+ * each of these files MAY correspond to many assertions
29
+ - We run livetext on the source and compare actual vs expected (stdout, stderr)
30
+ - The error output gets checked first (expected or match), THEN standard output
31
+ - Of course, both must compare correctly for the test to pass
32
+ =end
33
+
34
+
35
+ # Just a testing class. Chill.
36
+
37
+ class TestingLivetext < MiniTest::Test
38
+
39
+ class Snapshot
40
+ SOURCE = "source.lt3"
41
+ # Will now keep "actual" output in same dir?
42
+ ACTUAL_OUT, ACTUAL_ERR = "actual-output.txt", "actual-error.txt"
43
+ EXP_OUT, EXP_ERR = "expected-output.txt", "expected-error.txt"
44
+ MATCH_OUT, MATCH_ERR = "match-output.txt", "match-error.txt"
45
+
46
+ def initialize(base, assertion = nil)
47
+ @assertion = assertion
48
+ @base = base
49
+ @errors = false
50
+ Dir.chdir(base) do
51
+ @literal_out = File.exist?(EXP_OUT)
52
+ @literal_err = File.exist?(EXP_ERR)
53
+ @match_out = File.exist?(MATCH_OUT)
54
+ @match_err = File.exist?(MATCH_ERR)
55
+ end
56
+ bad_files = (@literal_out && @match_out) || (@literal_err && @match_err) ||
57
+ (! @literal_out && ! @match_out)
58
+ raise "Inconsistent structure for #@base" if bad_files
59
+ end
60
+
61
+ def check_matches(actual, control)
62
+ controls = File.readlines(control).map(&:chomp)
63
+ lines = File.readlines(actual).map(&:chomp)
64
+ lines.unshift("DUMMY LINE") # 1-based index! (for when I'm editing)
65
+ controls.each do |line|
66
+ line_num, item = line.split(" ", 2)
67
+ item = Regexp.new(item[1..-2]) if item[0] == "/" # Hmm, string can't start with /...
68
+ line_num = line_num.to_i
69
+ info = "Expected line #{line_num} of #{actual.inspect} to match #{item.inspect} (was: #{lines[line_num].inspect})"
70
+ good = item === lines[line_num]
71
+ @errors = true unless good
72
+ @assertion.call item === lines[line_num], info # string or regex
73
+ end
74
+ end
75
+
76
+ def sdiff(f1, f2, out)
77
+ File.open(out, "w") {|file| file.puts "#{'%-60s'% 'ACTUAL'}| #{'%-60s'% 'EXPECTED'}" }
78
+ system("/usr/bin/sdiff -t -w 121 #{f1} #{f2} >>#{out}")
79
+ end
80
+
81
+ def check_stdout
82
+ if @literal_out
83
+ actual, expected = File.read(ACTUAL_OUT), File.read(EXP_OUT)
84
+ same = actual == expected
85
+ @errors = true if not same
86
+ file = "out-sdiff.txt"
87
+ sdiff(ACTUAL_OUT, EXP_OUT, file)
88
+ @assertion.call same, "Discrepancy in STDOUT - see #{file} in test/snapshots/#@base"
89
+ else
90
+ check_matches(ACTUAL_OUT, MATCH_OUT)
91
+ end
92
+ end
93
+
94
+ def check_stderr
95
+ if @literal_err
96
+ actual, expected = File.read(ACTUAL_ERR), File.read(EXP_ERR)
97
+ same = actual == expected
98
+ @errors = true if not same
99
+ file = "err-sdiff.txt"
100
+ sdiff(ACTUAL_ERR, EXP_ERR, file)
101
+ @assertion.call same, "Discrepancy in STDERR - see #{file} in test/snapshots/#@base"
102
+ else
103
+ check_matches(ACTUAL_ERR, MATCH_ERR)
104
+ end
105
+ end
106
+
107
+ def cleanup
108
+ return if @errors
109
+ system("rm -f #{ACTUAL_OUT} #{ACTUAL_ERR} *sdiff.txt")
110
+ end
111
+
112
+ def filter # TODO move subset/omit logic here??
113
+ end
114
+
115
+ def run
116
+ @errors = false # oops, need to reset
117
+ Dir.chdir(@base) do
118
+ cmd = "../../../bin/livetext #{SOURCE} >#{ACTUAL_OUT} 2>#{ACTUAL_ERR}"
119
+ system(cmd)
120
+ check_stderr
121
+ check_stdout
122
+ cleanup
123
+ end
124
+ end
125
+ end
126
+
127
+ def self.get_dir # FIXME - uh what?
128
+ cmdline = ARGV.first == "cmdline" # FIXME remove??
129
+ if cmdline
130
+ dir = "../"
131
+ Dir.chdir `livetext --path`.chomp.chomp
132
+ else
133
+ dir = ""
134
+ end
135
+ end
136
+
137
+ TTY = File.open("/dev/tty","w")
138
+
139
+ args = ARGV - ["cmdline"]
140
+
141
+ dir = self.get_dir
142
+
143
+ Data = "#{dir}test/snapshots"
144
+ Dir.chdir(Data)
145
+
146
+ TestDirs = Dir.entries(".").reject {|fname| ! File.directory?(fname) } - %w[. ..]
147
+
148
+ if args.empty?
149
+ selected = File.readlines("subset.txt").map(&:chomp)
150
+ omitfile = "OMIT.txt"
151
+ omitted = File.readlines(omitfile).map(&:chomp)
152
+ omitted.reject! {|line| line.start_with?("#") }
153
+ omit_names = omitted.map {|line| line.split.first }
154
+ STDERR.puts
155
+ STDERR.puts " >>> Warning: Omitting #{omitted.size} snapshot tests:\n "
156
+ indented = " "*7
157
+ omitted.each do |line|
158
+ STDERR.print indented
159
+ name, info = line.split(" ", 2)
160
+ STDERR.printf "%-20s %s\n", name, info
161
+ end
162
+ STDERR.puts
163
+ wanted = selected.empty? ? TestDirs : selected
164
+ Subset = wanted - omit_names
165
+ else
166
+ Subset = args
167
+ end
168
+
169
+
170
+ Subset.each do |tdir|
171
+ define_method("test_#{tdir}") do
172
+ myproc = Proc.new {|bool, info| assert bool, info }
173
+ this = Snapshot.new(tdir, myproc)
174
+ this.run
175
+ end
176
+ end
177
+ end
data/test/testlines.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'livetext'
2
- require 'formatline'
1
+ require '../lib/livetext'
2
+ require '../lib/formatline'
3
3
 
4
4
  def red(str)
5
5
  "" + str + ""
data/test/unit/all.rb ADDED
@@ -0,0 +1,4 @@
1
+
2
+ require_relative 'standard'
3
+ require_relative 'parser' # nested
4
+ require_relative 'formatline'