[SCM] Lisaac compiler branch, mildred-coverage-rebase, updated. lisaac-0.12-642-g4389c6a

Mildred Ki'Lya silkensedai at online.fr
Sat Aug 14 17:22:01 UTC 2010


The following commit has been merged in the mildred-coverage-rebase branch:
commit 6a6f68e34bf4b0a4ee874b3b4e2f4e8530dc12f8
Author: Mildred Ki'Lya <silkensedai at online.fr>
Date:   Fri Jul 30 16:50:47 2010 +0200

    Added Makefile target to run code coverage on cucumber tests automatically

diff --git a/.gitignore b/.gitignore
index 5887732..c018c76 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,10 @@
 /lisaac.c
 /install_lisaac
 /install_lisaac.exe
+/lisaac-cov
+/lisaac-cov.c
+/lisaac-cov.cov
+/lisaac-cov.cov.orig
 /l
 /l.c
 /doc/
diff --git a/Makefile b/Makefile
index 38f2d99..52c3f21 100644
--- a/Makefile
+++ b/Makefile
@@ -182,6 +182,7 @@ clean:
 	-$(RM) -rf bootstrap
 	-$(RM) -f make.lip
 	-$(RM) -f install_lisaac
+	-$(RM) -f lisaac-cov.c lisaac-cov.cov lisaac-cov lisaac-cov.cov.orig
 	-$(RM) -f bin/path.h bin/shorter.c bin/shorter bin/lisaac
 	-$(RM) -f src/path.h src/shorter.c src/shorter src/lisaac src/lisaac.c
 	-$(RM) -f path.h shorter shorter.c lisaac lisaac.c
@@ -195,6 +196,23 @@ clean-spaces:
 src/HACKING.html: src/HACKING Markdown.pl
 	$(MARKDOWN_CMDLINE)
 
+### Code coverage ###
+
+lisaac-cov: path.h bin/lisaac
+	bin/lisaac src/make.lip -compiler -optim -coverage -o "`pwd`/$@"
+	cp lisaac-cov.cov lisaac-cov.cov.orig
+
+cov-clean:
+	-$(RM) -f lisaac-cov.cov
+	-cp lisaac-cov.cov.orig lisaac-cov.cov
+cov: lisaac-cov
+	-CUKE_LISAAC_NAME=lisaac-cov cucumber -f progress -t ~@bootstrap features/*.feature
+cov-report:
+	mkdir -p features/coverage-report
+	tools/licoverage --html -o features/coverage-report -e '\.lip$$' -e '/lib/' lisaac-cov.cov
+
+.PHONY: cov cov-clean cov-report
+
 ### Markdown ###
 
 MARKDOWN_URL=http://daringfireball.net/projects/downloads/Markdown_1.0.1.zip
diff --git a/features/.gitignore b/features/.gitignore
new file mode 100644
index 0000000..03f7cee
--- /dev/null
+++ b/features/.gitignore
@@ -0,0 +1 @@
+/coverage-report/
diff --git a/features/bootstrap.feature b/features/bootstrap.feature
index 450ea92..357e744 100644
--- a/features/bootstrap.feature
+++ b/features/bootstrap.feature
@@ -12,6 +12,7 @@ Feature: Bootstrapping
       printf '#define LISAAC_DIRECTORY "%s"\n' "`pwd`"
       """
 
+  @bootstrap
   Scenario:
     Given I am in "tmp/"
     When  I run lisaac ../src/make.lip -compiler -optim -o lisaac1
diff --git a/features/contracts.feature b/features/contracts.feature
index a021957..e053191 100644
--- a/features/contracts.feature
+++ b/features/contracts.feature
@@ -19,9 +19,7 @@ Feature: Execute contracts
   TODO: check this specification (it doesn't work)
 
   Background:
-    Given lisaac/bin is in the PATH
-      And make.lip is installed
-      And I am in an empty directory
+    Given I am in an empty directory
 
   @fail
   Scenario: simple contracts
@@ -96,7 +94,7 @@ Feature: Execute contracts
         ]
       """
 
-     When I run lisaac simple
+     When I compile simple.li
      Then it should pass
 
      When I run ./simple
@@ -117,4 +115,4 @@ Feature: Execute contracts
       POST proc2
       Prototype Invariant SIMPLE2
 
-      """
\ No newline at end of file
+      """
diff --git a/features/cyclic-inheritance.feature b/features/cyclic-inheritance.feature
index b14a7fa..7ac3ca9 100644
--- a/features/cyclic-inheritance.feature
+++ b/features/cyclic-inheritance.feature
@@ -3,8 +3,7 @@ Feature: Cyclic inheritance
   I want to detect cyclin inheritance and tell the programmer this is an error
 
   Background:
-    Given Lisaac is available
-    And   I am in an empty directory
+    Given I am in an empty directory
 
   Scenario: Basic
     Given a file "cyclic.li":
@@ -42,9 +41,9 @@ Feature: Cyclic inheritance
           tell_me;
         );
       """
-    When I run lisaac main
+    When I compile main.li
     Then it should fail
     And the output should contain
       """
       Cyclic inheritance
-      """
\ No newline at end of file
+      """
diff --git a/features/dynamic-inheritance.feature b/features/dynamic-inheritance.feature
index d2d4ef3..61cc6ee 100644
--- a/features/dynamic-inheritance.feature
+++ b/features/dynamic-inheritance.feature
@@ -1,9 +1,5 @@
 Feature: Dynamic Inheritance
 
-  Background:
-    Given lisaac/bin is in the PATH
-    And   make.lip is installed
-
   Scenario:
     Given I am in an empty directory
     And   a file "hello.li":
@@ -62,7 +58,7 @@ Feature: Dynamic Inheritance
         );
       """
 
-    When I run lisaac hello
+    When I compile hello.li
     Then it should pass
 
     When I run ./hello
diff --git a/features/expanded.feature b/features/expanded.feature
index 3977a38..0b7bd1b 100644
--- a/features/expanded.feature
+++ b/features/expanded.feature
@@ -11,9 +11,7 @@ Feature: Expanded Objects
     | Reference -> Reference | Copy reference                  |
 
   Background:
-    Given lisaac/bin is in the PATH
-      And make.lip is installed
-      And I am in an empty directory
+    Given I am in an empty directory
 
   Scenario:
     Given a file "aa.li"
@@ -93,7 +91,7 @@ Feature: Expanded Objects
         );
       """
 
-     When I run lisaac main
+     When I compile main.li
      Then it should pass
 
      When I run ./main
diff --git a/features/hello-world.feature b/features/hello-world.feature
index 7514137..5b8ff76 100644
--- a/features/hello-world.feature
+++ b/features/hello-world.feature
@@ -3,10 +3,6 @@ Feature: Hello World
   As a Lisaac programmer
   I want to be able to compile a hello world
 
-  Background: Background title
-    Given lisaac/bin is in the PATH
-    And   make.lip is installed
-
   Scenario: Debug
     Given I am in an empty directory
     When I run pwd
@@ -32,7 +28,7 @@ Feature: Hello World
           );
       """
 
-    When I run lisaac hello
+    When I compile hello.li
     Then it should pass
     And  the output should contain
       """
diff --git a/features/section-header.feature b/features/section-header.feature
index c9c0b09..1278671 100644
--- a/features/section-header.feature
+++ b/features/section-header.feature
@@ -25,9 +25,7 @@ Feature: Section Header
     - default value
 
   Background:
-    Given lisaac/bin is in the PATH
-      And make.lip is installed
-      And I am in an empty directory
+    Given I am in an empty directory
 
   Scenario: Missing Section Header
     Given a file "main.li"
@@ -41,7 +39,7 @@ Feature: Section Header
 
       """
 
-     When I run lisaac main
+     When I compile main.li
      Then it should fail
       And the output should contain
       """
@@ -61,7 +59,7 @@ Feature: Section Header
 
       """
 
-     When I run lisaac main
+     When I compile main.li
      Then it should fail
       And the output should contain
       """
@@ -98,7 +96,7 @@ Feature: Section Header
 
       """
 
-     When I run lisaac main
+     When I compile main.li
      Then it should pass
       And the output should contain
       """
diff --git a/features/step_definitions/steps.rb b/features/step_definitions/steps.rb
index 7ca11db..676dc13 100644
--- a/features/step_definitions/steps.rb
+++ b/features/step_definitions/steps.rb
@@ -68,6 +68,30 @@ When /^I run ([^"].*)$/ do |commandline|
   When("I run \"#{commandline}\"")
 end
 
+When /^I compile ([a-z0-9_]+\.li) using ([a-z0-9_]+\.lip) with (.*)$/ do |li_file, lip_file, options|
+  lisaac_compile(li_file, lip_file, options)
+end
+
+When /^I compile ([a-z0-9_]+\.li) using ([a-z0-9_]+\.lip)$/ do |li_file, lip_file|
+  lisaac_compile(li_file, lip_file)
+end
+
+When /^I compile ([a-z0-9_]+\.li) with (.*)$/ do |li_file, options|
+  lisaac_compile(li_file, "", options)
+end
+
+When /^I compile ([a-z0-9_]+\.lip) with (.*)$/ do |lip_file, options|
+  lisaac_compile("", lip_file, options)
+end
+
+When /^I compile ([a-z0-9_]+\.li)$/ do |li_file|
+  lisaac_compile(li_file)
+end
+
+When /^I compile ([a-z0-9_]+\.lip)$/ do |lip_file|
+  lisaac_compile("", lip_file)
+end
+
 When /^I print the last command output$/ do
   puts @last_command_output;
 end
diff --git a/features/support/env.rb b/features/support/env.rb
index 7f72a23..44fe919 100644
--- a/features/support/env.rb
+++ b/features/support/env.rb
@@ -4,12 +4,36 @@ require 'cucumber/formatter/unicode'
 require 'tempfile'
 
 $lisaac_path = File.expand_path(File.dirname(File.dirname(File.dirname(__FILE__))))
+$global_lisaac_options = ""
+$lisaac_name="lisaac"
+
+ENV['PATH'] = "#{$lisaac_path}/bin:#{$lisaac_path}:#{ENV['PATH']}";
+if ENV['CUKE_LISAAC_PATH'] then
+  ENV['PATH'] = "#{ENV['CUKE_LISAAC_PATH']}:#{ENV['PATH']}";
+end
+if ENV['CUKE_LISAAC_NAME'] then
+  $lisaac_name = ENV['CUKE_LISAAC_NAME'];
+end
+
+FileUtils.mkdir_p("#{$lisaac_path}/lib/extra")
+FileUtils.mkdir_p("#{$lisaac_path}/lib/unstable")
 
 Before do
   $current_dir = FileUtils::pwd();
   File.dirname(__FILE__)
+  if not File.exists?("#{$lisaac_path}/make.lip") then
+    FileUtils.ln_s("make.lip.sample", "#{$lisaac_path}/make.lip")
+  end
 end
 
 After do |scenario|
   FileUtils::cd($current_dir);
 end
+
+def lisaac_compile(li="", lip="", options="")
+  commandline = "#{$lisaac_name} #{lip} #{li} #{$global_lisaac_options} #{options}"
+  # puts "#{commandline}\n"
+  @last_command_output = `#{commandline} 2>&1`;
+  @last_exit_code = $?.to_i;
+end
+
diff --git a/tools/licoverage b/tools/licoverage
index 4c4e87d..bbbbe72 100755
--- a/tools/licoverage
+++ b/tools/licoverage
@@ -290,7 +290,8 @@ sub generate_html {
     files       => [],
   };
   my $i = 0;
-  while (my ($id, $file) = each(%all_files)) {
+  foreach my $id (sort (keys(%all_files))) {
+    my $file = $all_files{$id};
     my $html_file = "coverage_".$file->{id}.".html";
     $vars_index->{files}->[$i++] = {
       shortname              => phtml(substr($file->{filename}, length($common_dir))),
@@ -359,7 +360,8 @@ sub generate_html {
 }
 
 sub generate_summary {
-  while (my ($id, $file) = each(%all_files)) {
+  foreach my $id (sort (keys(%all_files))) {
+    my $file = $all_files{$id};
     my $proto_file = $file->{filename};
     print substr($proto_file, length($common_dir));
     my $percent = 100 * $file->{covered}/$file->{count};
@@ -368,9 +370,19 @@ sub generate_summary {
   }
 }
 
+# sub sort_all_files {
+#   my %tmp = %all_files;
+#   %all_files = ();
+#   foreach my $key (sort (keys(%tmp))) {
+#     $all_files{$key} = $tmp{$key};
+#   }
+# }
+
+
 process_files(@cov_files);
 
 if ($gen_html) {
+  print "Generate HTML ...\n";
   generate_html();
 }
 
@@ -497,4 +509,4 @@ __END__
     <h1>Code coverage for [% shortname %]</h1>
     <code>[% code %]</code>
   </body>
-</html>
\ No newline at end of file
+</html>

-- 
Lisaac compiler



More information about the Lisaac-commits mailing list