Skip to content

Commit

Permalink
Add fake_gcc to the test case for compile failed.
Browse files Browse the repository at this point in the history
  • Loading branch information
kiyoka committed Nov 23, 2013
1 parent 97c0ca0 commit 24910be
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Rakefile
Expand Up @@ -71,12 +71,18 @@ end
task :default => [:test] do
end

task :test do
task :test => [:fallback_test] do
sh "ruby -I ./lib `which rspec` -b ./test/basic_native_spec.rb" if File.exist?( "./test/basic_native_spec.rb" )
sh "ruby -I ./lib `which rspec` -b ./test/basic_pure_spec.rb"
sh "ruby -I ./lib `which rspec` -b ./test/mutibyte_spec.rb"
end

task :fallback_test => [:clean_dot_rubyinline] do
sh "/bin/mkdir -p /tmp/fake_gcc/"
sh "/bin/cp ./fake_gcc /tmp/fake_gcc/gcc"
sh "export PATH=\"/tmp/fake_gcc:${PATH}\" ; rspec -I ./lib ./test/fallback_pure_spec.rb"
end

task :test_dev do
sh "ruby -I ./lib `which rspec` -b ./test/verify_with_amatch_spec.rb"
end
Expand All @@ -85,3 +91,6 @@ task :bench do
sh "ruby ./benchmark/vs_amatch.rb"
end

task :clean_dot_rubyinline do
sh "/bin/rm -rf ~/.ruby_inline"
end
7 changes: 7 additions & 0 deletions fake_gcc
@@ -0,0 +1,7 @@
#!/bin/bash

echo "fake_gcc: $1 compile failded."
false



32 changes: 32 additions & 0 deletions test/fallback_pure_spec.rb
@@ -0,0 +1,32 @@
#!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
#
# fallback_pure_spec.rb - "Fall back feature into pure ruby mode."
#
# Copyright (c) 2013 Kiyoka Nishiyama <kiyoka@sumibi.org>
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#


require 'inline'

describe Inline, "when c compile failed, fall back into pure " do
it "should" do
lambda { require 'fuzzystringmatch' }.should raise_error( CompilationError )
end
end

0 comments on commit 24910be

Please sign in to comment.