[SCM] Lisaac compiler branch, master, updated. lisaac-0.12-607-g0e9d171
Mildred Ki'Lya
silkensedai at online.fr
Mon Mar 1 19:30:35 UTC 2010
The following commit has been merged in the master branch:
commit 0e9d171f68376e18ba4cc8bdfcb9fe72537f8230
Author: Mildred Ki'Lya <silkensedai at online.fr>
Date: Mon Mar 1 20:30:08 2010 +0100
Add cucumber features for testing
diff --git a/features/README b/features/README
new file mode 100644
index 0000000..53ba563
--- /dev/null
+++ b/features/README
@@ -0,0 +1,23 @@
+Cucumber Test Suite
+===================
+
+
+These .feature files are cucumber tests. Cucumber is a behaviour driven
+developpment tool, see http://cukes.info for more information.
+
+Cucumber is written in ruby and to install it, you can just run:
+
+ gem install cucumber rake
+
+To run the tests, just run cucumber like this:
+
+ cucumber features/bootstrap.feature
+
+or
+
+ cucumber features/*.feature
+
+You can generate an HTMl report using the `html` format:
+
+ cucumber -t html -o report.html features/*.feature
+
diff --git a/features/bootstrap.feature b/features/bootstrap.feature
new file mode 100644
index 0000000..efe40d9
--- /dev/null
+++ b/features/bootstrap.feature
@@ -0,0 +1,27 @@
+Feature: Bootstrapping
+ In order to have a self hosting compiler
+ As a Lisaac devlopper
+ I want to bootstrap the compiler
+
+ Background:
+ Given lisaac/ is in the PATH
+ And make.lip is installed
+ And a file "tmp/path.h" constructed with:
+ """
+ printf '#define LISAAC_DIRECTORY "%s"\n' "`pwd`"
+ """
+
+ Scenario:
+ Given I am in "tmp/"
+ When I run lisaac ../src/make.lip -compiler -optim -o lisaac1
+ Then it should pass
+ And "lisaac1.c" should exist
+ And "lisaac1" should exist
+ When I run ./lisaac1 ../src/make.lip -compiler -optim -o lisaac2
+ Then it should pass
+ And "lisaac2.c" should exist
+ And "lisaac2" should exist
+ When I run ./lisaac2 ../src/make.lip -compiler -optim -o lisaac3
+ Then it should pass
+ And "lisaac3.c" should exist
+ And "lisaac3" should exist
diff --git a/features/step_definitions/steps.rb b/features/step_definitions/steps.rb
new file mode 100644
index 0000000..4aff591
--- /dev/null
+++ b/features/step_definitions/steps.rb
@@ -0,0 +1,116 @@
+# encoding: utf-8
+
+Given /^lisaac\/(.*) is in the PATH$/ do |dir|
+ new_path = $lisaac_path + "/" + dir;
+ ENV['PATH'] = new_path + ":" + ENV['PATH'];
+end
+
+Given /^make.lip is installed$/ do
+ if not File.exists?("#{$lisaac_path}/make.lip") then
+ FileUtils.ln_s("make.lip.sample", "#{$lisaac_path}/make.lip")
+ end
+end
+
+Given /^I am in an empty directory$/ do
+ @oldcwd = FileUtils.pwd();
+ dir = "#{$lisaac_path}/tmp";
+ FileUtils.cd($lisaac_path);
+ FileUtils.remove_dir(dir) rescue nil;
+ FileUtils.mkdir_p(dir);
+ FileUtils.cd(dir);
+end
+
+Given /^I am in "(.*)"$/ do |dir|
+ FileUtils.cd($lisaac_path);
+ @oldcwd = FileUtils.pwd();
+ FileUtils::mkdir_p(dir);
+ FileUtils.cd(dir);
+end
+
+Given /^a file "(.*)":?$/ do |filename, filecontent|
+ FileUtils::mkdir_p(File.dirname(filename));
+ f = File.new(filename, "w");
+ f.write(filecontent);
+ f.close();
+end
+
+Given /^a file "(.*)" constructed with:?$/ do |filename, script|
+ FileUtils::mkdir_p(File.dirname(filename));
+ f = File.new(filename, "w");
+ f.write(`#{script}`);
+ f.close();
+end
+
+Given /^a file "(.*)" constructed with (.*)$/ do |filename, script|
+ FileUtils::mkdir_p(File.dirname(filename));
+ f = File.new(filename, "w");
+ f.write(`#{script}`);
+ f.close();
+end
+
+When /^I run "([^"]*)"(?: in "([^"]*)")?$/ do |commandline, dir|
+ if dir then
+ olddir = FileUtils.pwd();
+ FileUtils.cd(dir);
+ end
+ @last_command_output = `#{commandline} 2>&1`;
+ @last_exit_code = $?.to_i;
+ if dir then
+ FileUtils.cd(olddir);
+ end
+end
+
+When /^I run ([^"].*)$/ do |commandline|
+ When("I run \"#{commandline}\"")
+end
+
+When /^I print the last command output$/ do
+ puts @last_command_output;
+end
+
+When /^I print the last exit code$/ do
+ puts @last_exit_code;
+end
+
+Then /^it should (fail|pass)$/ do |success|
+ if success == 'fail'
+ @last_exit_code.should_not == 0
+ else
+ if @last_exit_code != 0
+ raise "Failed with exit status #{@last_exit_code}\nOutput:\n#{@last_command_output}\n"
+ end
+ end
+end
+
+Then /^it should (fail|pass) with:?$/ do |success, output|
+ @last_command_output.should == output
+ Then("it should #{success}")
+end
+
+Then /^the output should contains?:?$/ do |text|
+ @last_command_output.should include(text)
+end
+
+Then /^the output should not contains?:?$/ do |text|
+ @last_command_output.should_not include(text)
+end
+
+Then /^the output should be:?$/ do |text|
+ @last_command_output.should == text
+end
+
+Then /^"([^\"]*)" should match "([^\"]*)"$/ do |file, text|
+ File.open(file, Cucumber.file_mode('r')).read.should =~ Regexp.new(text)
+end
+
+Then /^print output$/ do
+ puts @last_command_output
+end
+
+Then /^"([^\"]*)" should exist$/ do |file|
+ File.exists?(file).should be_true
+end
+
+Then /^"([^\"]*)" (?:should not|shouldn't) exist$/ do |file|
+ File.exists?(file).should be_false
+end
diff --git a/features/support/env.rb b/features/support/env.rb
new file mode 100644
index 0000000..7f72a23
--- /dev/null
+++ b/features/support/env.rb
@@ -0,0 +1,15 @@
+# encoding: utf-8
+require 'spec/expectations'
+require 'cucumber/formatter/unicode'
+require 'tempfile'
+
+$lisaac_path = File.expand_path(File.dirname(File.dirname(File.dirname(__FILE__))))
+
+Before do
+ $current_dir = FileUtils::pwd();
+ File.dirname(__FILE__)
+end
+
+After do |scenario|
+ FileUtils::cd($current_dir);
+end
--
Lisaac compiler
More information about the Lisaac-commits
mailing list