fiat 0.0.2 → 0.0.3
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 +27 -9
- data/bin/fiat +6 -0
- data/fiat.gemspec +2 -2
- data/lib/fiat.rb +17 -19
- data/lib/fiat/version.rb +1 -1
- metadata +7 -7
data/Readme.md
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
# Fiat: an auto-Make-er
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
## What?
|
|
2
6
|
|
|
3
7
|
Fiat's a bit like [autotest](http://www.zenspider.com/ZSS/Products/ZenTest/) for `make`-managed projects.
|
|
4
8
|
|
|
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.
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
- [Ruby](http://www.ruby-lang.org/)
|
|
14
|
+
- [RubyGems](https://rubygems.org/)
|
|
6
15
|
|
|
7
16
|
## Installation
|
|
8
17
|
|
|
9
|
-
|
|
18
|
+
gem install fiat
|
|
10
19
|
|
|
11
|
-
|
|
20
|
+
If you haven't installed any gems before, you *may* need to add rubygems' directory to your `$PATH`.
|
|
12
21
|
|
|
13
|
-
|
|
22
|
+
## Usage
|
|
14
23
|
|
|
15
|
-
|
|
24
|
+
fiat [task]**
|
|
25
|
+
|
|
26
|
+
## An Example
|
|
16
27
|
|
|
17
28
|
Suppose we're developing a little C program, and we'd like to automatically run it each time we make changes.
|
|
18
29
|
|
|
@@ -30,14 +41,15 @@ We can execute:
|
|
|
30
41
|
gcc -o hello hello_world.c
|
|
31
42
|
./hello
|
|
32
43
|
Hello, world!
|
|
44
|
+
|
|
33
45
|
######################################## // <- this line should be green =)
|
|
34
46
|
...
|
|
35
47
|
|
|
36
48
|
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
49
|
|
|
38
|
-
If the output of a task includes one of the defined key terms (`failure_terms`), fiat interprets that run
|
|
50
|
+
If the output of a task includes one of the defined key terms (`failure_terms`), fiat interprets that run as a failure and prints the end-of-run bar in red.
|
|
39
51
|
|
|
40
|
-
##
|
|
52
|
+
## .fiatrc
|
|
41
53
|
|
|
42
54
|
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
55
|
|
|
@@ -56,6 +68,7 @@ Since we're not using a testing package, there's (probably) no reason to define
|
|
|
56
68
|
gcc -o hello hello_world.c
|
|
57
69
|
./hello
|
|
58
70
|
Hello, world!
|
|
71
|
+
|
|
59
72
|
########################################
|
|
60
73
|
...
|
|
61
74
|
|
|
@@ -65,4 +78,9 @@ So, our `.fiatrc` is just:
|
|
|
65
78
|
|
|
66
79
|
failure_terms = ["Failed:"]
|
|
67
80
|
|
|
68
|
-
Easy-peasy.
|
|
81
|
+
Easy-peasy.
|
|
82
|
+
|
|
83
|
+
## Feedback
|
|
84
|
+
|
|
85
|
+
This thing's still very much a work-in-progress, so please feel free to shoot me an email if you love it/hate it/want me to fix something about it. =)
|
|
86
|
+
|
data/bin/fiat
CHANGED
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
|
4
4
|
require 'fiat'
|
|
5
5
|
|
|
6
|
+
# Default values
|
|
6
7
|
instruction = "test"
|
|
7
8
|
failure_terms = ["failed", "error"]
|
|
8
9
|
poll_interval = 0.5 # seconds
|
|
9
10
|
|
|
11
|
+
# Overwrite the defaults if there's a .fiatrc in this directory
|
|
10
12
|
if File.exists? ".fiatrc"
|
|
11
13
|
eval File.open(".fiatrc").read
|
|
12
14
|
end
|
|
13
15
|
|
|
16
|
+
# Overwrite the instruction if one's given on the cmd line
|
|
14
17
|
instruction = ARGV.length == 1 ? ARGV[0] : instruction
|
|
15
18
|
|
|
16
19
|
unless File.exists? "Makefile"
|
|
@@ -27,8 +30,11 @@ puts "Running \"make #{instruction}\" on changes..."
|
|
|
27
30
|
|
|
28
31
|
dependencies = Fiat::deps(instruction, Fiat::dep_tree)
|
|
29
32
|
ctimes = Fiat::file_ctimes(dependencies)
|
|
33
|
+
|
|
34
|
+
# Initial test run
|
|
30
35
|
Fiat::run_tests(dependencies, ctimes, instruction, failure_terms)
|
|
31
36
|
|
|
37
|
+
# Main loop
|
|
32
38
|
begin
|
|
33
39
|
while true
|
|
34
40
|
if Fiat::anything_changed?(dependencies, ctimes)
|
data/fiat.gemspec
CHANGED
|
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
|
|
|
8
8
|
s.authors = ["Harry Schwartz"]
|
|
9
9
|
s.email = ["hrs@cs.wm.edu"]
|
|
10
10
|
s.homepage = "https://github.com/hrs/fiat"
|
|
11
|
-
s.summary = %q{The "auto-
|
|
12
|
-
s.description = %q{
|
|
11
|
+
s.summary = %q{The "auto-Make-er."}
|
|
12
|
+
s.description = %q{Like autotest for Makefiles: fiat automatically and repeatedly executes a given make task every time one of the task's dependencies is saved.}
|
|
13
13
|
|
|
14
14
|
s.rubyforge_project = "fiat"
|
|
15
15
|
|
data/lib/fiat.rb
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'fiat/version'
|
|
2
2
|
require 'colorize'
|
|
3
3
|
|
|
4
4
|
module Fiat
|
|
5
5
|
def self.dep_tree
|
|
6
6
|
tree = {}
|
|
7
|
-
IO.readlines("Makefile").
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
task_headers = IO.readlines("Makefile").select{ |l| l.include? ":" }
|
|
8
|
+
|
|
9
|
+
task_headers.each do |line|
|
|
10
|
+
k = line.split(":").first
|
|
11
|
+
reqs = line.split(":")[1..-1].join(":")
|
|
12
|
+
tree[k] = reqs.strip.split
|
|
13
13
|
end
|
|
14
|
+
|
|
14
15
|
tree
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
def self.deps(key, tree)
|
|
18
19
|
if tree.include? key
|
|
19
|
-
tree[key].map
|
|
20
|
+
tree[key].map{ |d| deps(d, tree) }.flatten.uniq
|
|
20
21
|
else
|
|
21
22
|
key
|
|
22
23
|
end
|
|
@@ -24,11 +25,12 @@ module Fiat
|
|
|
24
25
|
|
|
25
26
|
def self.file_ctimes(filenames)
|
|
26
27
|
hash = {}
|
|
27
|
-
filenames.
|
|
28
|
-
|
|
28
|
+
real_files = filenames.select{ |f| File.exists? f }
|
|
29
|
+
|
|
30
|
+
real_files.each do |f|
|
|
29
31
|
hash[f] = File.ctime(f)
|
|
30
|
-
end
|
|
31
32
|
end
|
|
33
|
+
|
|
32
34
|
hash
|
|
33
35
|
end
|
|
34
36
|
|
|
@@ -37,12 +39,7 @@ module Fiat
|
|
|
37
39
|
end
|
|
38
40
|
|
|
39
41
|
def self.passed_tests?(result_string, failure_terms)
|
|
40
|
-
failure_terms.
|
|
41
|
-
if result_string.include? f
|
|
42
|
-
return false
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
true
|
|
42
|
+
failure_terms.select{ |term| result_string.include? term }.empty?
|
|
46
43
|
end
|
|
47
44
|
|
|
48
45
|
def self.crashed?(process)
|
|
@@ -53,10 +50,11 @@ module Fiat
|
|
|
53
50
|
results = `make #{instruction}`
|
|
54
51
|
puts results + "\n"
|
|
55
52
|
|
|
53
|
+
bar = "#" * 40
|
|
56
54
|
if crashed?($?) or not passed_tests?(results, failure_terms)
|
|
57
|
-
puts
|
|
55
|
+
puts bar.red
|
|
58
56
|
else
|
|
59
|
-
puts
|
|
57
|
+
puts bar.green
|
|
60
58
|
end
|
|
61
59
|
end
|
|
62
60
|
end
|
data/lib/fiat/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.0.3
|
|
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-
|
|
12
|
+
date: 2011-11-08 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: colorize
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &70143896551360 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
@@ -21,9 +21,9 @@ dependencies:
|
|
|
21
21
|
version: '0'
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
25
|
-
description: ! '
|
|
26
|
-
a given make task every time one of the task''s dependencies
|
|
24
|
+
version_requirements: *70143896551360
|
|
25
|
+
description: ! 'Like autotest for Makefiles: fiat automatically and repeatedly executes
|
|
26
|
+
a given make task every time one of the task''s dependencies is saved.'
|
|
27
27
|
email:
|
|
28
28
|
- hrs@cs.wm.edu
|
|
29
29
|
executables:
|
|
@@ -62,5 +62,5 @@ rubyforge_project: fiat
|
|
|
62
62
|
rubygems_version: 1.8.6
|
|
63
63
|
signing_key:
|
|
64
64
|
specification_version: 3
|
|
65
|
-
summary: The "auto-
|
|
65
|
+
summary: The "auto-Make-er."
|
|
66
66
|
test_files: []
|