adds executable test with IsolatedScriptingContainer
This commit is contained in:
parent
5271781989
commit
10f3092f96
|
@ -25,7 +25,7 @@ scope :provided do
|
|||
jar 'org.eclipse.jetty:jetty-webapp:${jetty.version}'
|
||||
end
|
||||
|
||||
properties( 'jruby.version' => '1.7.19',
|
||||
properties( 'jruby.version' => '1.7.21',
|
||||
'jetty.version' => '8.1.14.v20131031',
|
||||
'project.build.sourceEncoding' => 'utf-8',
|
||||
'polyglot.dump.pom' => 'pom.xml' )
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -42,7 +42,7 @@ DO NOT MODIFIY - GENERATED CODE
|
|||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<properties>
|
||||
<jruby.version>1.7.19</jruby.version>
|
||||
<jruby.version>1.7.21</jruby.version>
|
||||
<jetty.version>8.1.14.v20131031</jetty.version>
|
||||
<polyglot.dump.pom>pom.xml</polyglot.dump.pom>
|
||||
<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
dependency-reduced-pom.xml
|
||||
pkg
|
|
@ -0,0 +1,51 @@
|
|||
#-*- mode: ruby -*-
|
||||
|
||||
#repository :id => 'rubygems-releases', :url => 'http://rubygems-proxy.torquebox.org/releases'
|
||||
|
||||
#gem 'leafy-logger'
|
||||
|
||||
properties( 'jruby.main' => 'de.saumya.mojo.mains.JarMain',
|
||||
'gem.home' => '${basedir}/../rubygems',
|
||||
'gem.path' => '${gem.home}',
|
||||
# default versions
|
||||
'jruby.version' => '1.7.21',
|
||||
# 'jruby.version' => '9.0.0.0.rc2',
|
||||
'jruby.plugins.version' => '1.0.9' )
|
||||
|
||||
jar 'org.jruby:jruby-complete', '${jruby.version}'
|
||||
|
||||
jar 'de.saumya.mojo:jruby-mains', '${artifact.version}'
|
||||
|
||||
build do
|
||||
directory 'pkg'
|
||||
final_name 'executable'
|
||||
resource :directory => '${basedir}', :includes => ['*.rb']
|
||||
end
|
||||
|
||||
plugin :shade, '2.2' do
|
||||
execute_goals( 'shade',
|
||||
:id => 'pack', :phase => :package,
|
||||
:artifactSet => { :excludes => ['rubygems:*'] },
|
||||
:transformers => [ { :@implementation => 'org.apache.maven.plugins.shade.resource.ManifestResourceTransformer',
|
||||
:mainClass => '${jruby.main}' } ] )
|
||||
end
|
||||
|
||||
# test bits
|
||||
|
||||
phase :'integration-test' do
|
||||
plugin( 'org.codehaus.mojo:exec-maven-plugin:1.2',
|
||||
:executable => 'java',
|
||||
:workingDirectory => '${project.build.directory}',
|
||||
:environmentVariables => {
|
||||
'PATH' => 'path',
|
||||
'HOME' => 'blabla',
|
||||
# 'GEM_PATH' => '${basedir}',
|
||||
# 'GEM_HOME' => '${basedir}'
|
||||
} ) do
|
||||
|
||||
execute_goal( :exec, :id => 'execute the jar',
|
||||
:arguments => [ '-jar', 'executable.jar' ] )
|
||||
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
require_relative 'test'
|
||||
|
||||
other = org.jruby.embed.IsolatedScriptingContainer.new(org.jruby.embed.LocalContextScope::THREADSAFE)
|
||||
other.setCurrentDirectory('uri:classloader:/')
|
||||
|
||||
# HACK for jruby-1.7.21
|
||||
other.runScriptlet("ENV.replace(JRuby.runtime.instance_config.environment)")
|
||||
|
||||
other.runScriptlet("$other = #{JRuby.runtime.object_id}")
|
||||
|
||||
# TODO needs fix in jruby
|
||||
#other.runScriptlet( "require_relative 'test_other'" )
|
||||
other.runScriptlet( "require 'uri:classloader:test_other'" )
|
||||
|
||||
other.terminate
|
|
@ -0,0 +1,102 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
|
||||
DO NOT MODIFIY - GENERATED CODE
|
||||
|
||||
|
||||
-->
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>no_group_id_given</groupId>
|
||||
<artifactId>executable_jar</artifactId>
|
||||
<version>0.0.0</version>
|
||||
<name>executable_jar</name>
|
||||
<properties>
|
||||
<jruby.version>1.7.21</jruby.version>
|
||||
<jruby.main>de.saumya.mojo.mains.JarMain</jruby.main>
|
||||
<gem.path>${gem.home}</gem.path>
|
||||
<jruby.plugins.version>1.0.9</jruby.plugins.version>
|
||||
<gem.home>${basedir}/../rubygems</gem.home>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jruby</groupId>
|
||||
<artifactId>jruby-complete</artifactId>
|
||||
<version>${jruby.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.saumya.mojo</groupId>
|
||||
<artifactId>jruby-mains</artifactId>
|
||||
<version>${artifact.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}</directory>
|
||||
<includes>
|
||||
<include>*.rb</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<directory>pkg</directory>
|
||||
<finalName>executable</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>pack</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<excludes>
|
||||
<exclude>rubygems:*</exclude>
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>${jruby.main}</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>execute the jar</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<arguments>
|
||||
<argument>-jar</argument>
|
||||
<argument>executable.jar</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<executable>java</executable>
|
||||
<workingDirectory>${project.build.directory}</workingDirectory>
|
||||
<environmentVariables>
|
||||
<PATH>path</PATH>
|
||||
<HOME>blabla</HOME>
|
||||
</environmentVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,21 @@
|
|||
require 'minitest/autorun'
|
||||
|
||||
describe 'ENV' do
|
||||
|
||||
it 'has first entry LOAD_PATH' do
|
||||
$LOAD_PATH.first.must_equal 'uri:classloader://'
|
||||
end
|
||||
|
||||
it 'has GEM_HOME set' do
|
||||
ENV['GEM_HOME'].must_equal 'uri:classloader://META-INF/jruby.home/lib/ruby/gems/shared'
|
||||
end
|
||||
|
||||
it 'has GEM_PATH set' do
|
||||
ENV['GEM_PATH'].must_equal 'uri:classloader://'
|
||||
end
|
||||
|
||||
it 'has JARS_HOME set' do
|
||||
ENV['JARS_HOME'].must_equal 'uri:classloader://jars'
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,26 @@
|
|||
require 'minitest/autorun'
|
||||
|
||||
describe 'ENV' do
|
||||
|
||||
it 'has $other' do
|
||||
$other.wont_equal JRuby.runtime.object_id
|
||||
end
|
||||
|
||||
it 'has first entry LOAD_PATH' do
|
||||
# TODO needs trailing /
|
||||
$LOAD_PATH.first.must_equal 'uri:classloader:'
|
||||
end
|
||||
|
||||
it 'has GEM_HOME set' do
|
||||
ENV['GEM_HOME'].must_equal 'uri:classloader://'
|
||||
end
|
||||
|
||||
it 'has GEM_PATH set' do
|
||||
ENV['GEM_PATH'].must_equal 'uri:classloader://'
|
||||
end
|
||||
|
||||
it 'has JARS_HOME set' do
|
||||
ENV['JARS_HOME'].must_equal 'uri:classloader://jars'
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
import java.io.*;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
|
||||
String log = FileUtils.fileRead( new File( basedir, "build.log" ) );
|
||||
String expected = "5 tests, 5 assertions, 0 failures, 0 errors, 0 skips";
|
||||
if ( !log.contains( expected ) )
|
||||
{
|
||||
throw new RuntimeException( "log file does not contain '" + expected + "'" );
|
||||
}
|
||||
|
||||
expected = "4 tests, 4 assertions, 0 failures, 0 errors, 0 skips";
|
||||
if ( !log.contains( expected ) )
|
||||
{
|
||||
throw new RuntimeException( "log file does not contain '" + expected + "'" );
|
||||
}
|
Loading…
Reference in New Issue