fiat 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Readme.md ADDED
@@ -0,0 +1,68 @@
1
+ ## Fiat: the auto-`make`-er
2
+
3
+ Fiat's a bit like [autotest](http://www.zenspider.com/ZSS/Products/ZenTest/) for `make`-managed projects.
4
+
5
+ Fiat monitors a `make` task's dependencies. Each time one of those dependencies changes, fiat executes the task, prints the results, and reports whether the process succeeded or failed. It can be used to check program output or run tests without having to manually execute the task.
6
+
7
+ ## Installation
8
+
9
+ Fiat depends on ruby and rubygems, so make sure they're installed. Then:
10
+
11
+ $ gem install fiat
12
+
13
+ If you haven't installed any gems before, you *may* need to add rubygems' installation directory to your `$PATH`.
14
+
15
+ ## A Usage Example
16
+
17
+ Suppose we're developing a little C program, and we'd like to automatically run it each time we make changes.
18
+
19
+ Sample Makefile:
20
+
21
+ all: hello_world.c
22
+ gcc -o hello hello_world.c
23
+ run: my_proj
24
+ ./hello
25
+
26
+ We can execute:
27
+
28
+ $ fiat run
29
+ Running "make run" on changes...
30
+ gcc -o hello hello_world.c
31
+ ./hello
32
+ Hello, world!
33
+ ######################################## // <- this line should be green =)
34
+ ...
35
+
36
+ Each time we save changes to `my_proj.c`, fiat will execute `make run` and print the results, followed by a line of hashes. This line is <span style="color: green;">green</span> if the program exited cleanly (with exit status == 0) and didn't include one of the failure terms (see below) or <span style="color: red;">red</span> if the program failed in some way. This makes it easy to tell at a glance whether our tests succeeded or failed.
37
+
38
+ If the output of a task includes one of the defined key terms (`failure_terms`), fiat interprets that run to have been a failure and prints the end-of-run bar in red.
39
+
40
+ ## `.fiatrc`
41
+
42
+ In the same directory as the Makefile, we can optionally define a `.fiatrc` file which is interpreted when fiat is executed. In it we can set two variables:
43
+
44
+ - `instruction` -- the `make` task to be run. Defaults to `"test"`.
45
+ - `failure_terms` -- a list of strings that imply failure if any of them appear in the program's output. Defaults to `["failed", "error"]`.
46
+
47
+ For example, the `.fiatrc` for the sample project above might look like:
48
+
49
+ failure_terms = []
50
+ instruction = "run"
51
+
52
+ Since we're not using a testing package, there's (probably) no reason to define `failure_terms`; we'll only get a red end-of-run bar when the program returns a non-zero exit status. However, the `make` task we're using is `run`, so setting `instruction = "run"` allows us to run fiat without arguments:
53
+
54
+ $ fiat
55
+ Running "make run" on changes...
56
+ gcc -o hello hello_world.c
57
+ ./hello
58
+ Hello, world!
59
+ ########################################
60
+ ...
61
+
62
+ Alternately, suppose we're using `make` to manage an Erlang project with EUnit tests, and we'd like to know when our tests fail. The `make` task to execute our tests is fiat's default, `test`. For fiat's purposes, we'd like to define a failed test to be one in which the term "Failed:" appears.
63
+
64
+ So, our `.fiatrc` is just:
65
+
66
+ failure_terms = ["Failed:"]
67
+
68
+ Easy-peasy.
data/bin/fiat CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
4
4
  require 'fiat'
5
5
 
6
6
  instruction = "test"
7
- failing_words = ["Failed"]
7
+ failure_terms = ["failed", "error"]
8
8
  poll_interval = 0.5 # seconds
9
9
 
10
10
  if File.exists? ".fiatrc"
@@ -27,12 +27,12 @@ puts "Running \"make #{instruction}\" on changes..."
27
27
 
28
28
  dependencies = Fiat::deps(instruction, Fiat::dep_tree)
29
29
  ctimes = Fiat::file_ctimes(dependencies)
30
- Fiat::run_tests(dependencies, ctimes, instruction)
30
+ Fiat::run_tests(dependencies, ctimes, instruction, failure_terms)
31
31
 
32
32
  begin
33
33
  while true
34
34
  if Fiat::anything_changed?(dependencies, ctimes)
35
- Fiat::run_tests(dependencies, ctimes, instruction)
35
+ Fiat::run_tests(dependencies, ctimes, instruction, failure_terms)
36
36
  ctimes = Fiat::file_ctimes(dependencies)
37
37
  end
38
38
  sleep poll_interval
data/fiat.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = Fiat::VERSION
8
8
  s.authors = ["Harry Schwartz"]
9
9
  s.email = ["hrs@cs.wm.edu"]
10
- s.homepage = ""
10
+ s.homepage = "https://github.com/hrs/fiat"
11
11
  s.summary = %q{The "auto-Maker."}
12
12
  s.description = %q{Autotest for Makefiles: fiat automatically and repeatedly executes a given make task every time one of the task's dependencies changes.}
13
13
 
data/lib/fiat/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fiat
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/fiat.rb CHANGED
@@ -36,8 +36,8 @@ module Fiat
36
36
  ctimes != file_ctimes(filenames)
37
37
  end
38
38
 
39
- def self.passed_tests?(result_string)
40
- $failing_words.each do |f|
39
+ def self.passed_tests?(result_string, failure_terms)
40
+ failure_terms.each do |f|
41
41
  if result_string.include? f
42
42
  return false
43
43
  end
@@ -49,11 +49,11 @@ module Fiat
49
49
  process.exitstatus != 0
50
50
  end
51
51
 
52
- def self.run_tests(dependencies, ctimes, instruction)
52
+ def self.run_tests(dependencies, ctimes, instruction, failure_terms)
53
53
  results = `make #{instruction}`
54
54
  puts results + "\n"
55
55
 
56
- if crashed?($?) or not passed_tests?(results)
56
+ if crashed?($?) or not passed_tests?(results, failure_terms)
57
57
  puts ("#" * 40).red
58
58
  else
59
59
  puts ("#" * 40).green
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fiat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-06 00:00:00.000000000Z
12
+ date: 2011-11-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize
16
- requirement: &70336088014720 !ruby/object:Gem::Requirement
16
+ requirement: &70327233685920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70336088014720
24
+ version_requirements: *70327233685920
25
25
  description: ! 'Autotest for Makefiles: fiat automatically and repeatedly executes
26
26
  a given make task every time one of the task''s dependencies changes.'
27
27
  email:
@@ -34,11 +34,12 @@ files:
34
34
  - .gitignore
35
35
  - Gemfile
36
36
  - Rakefile
37
+ - Readme.md
37
38
  - bin/fiat
38
39
  - fiat.gemspec
39
40
  - lib/fiat.rb
40
41
  - lib/fiat/version.rb
41
- homepage: ''
42
+ homepage: https://github.com/hrs/fiat
42
43
  licenses: []
43
44
  post_install_message:
44
45
  rdoc_options: []