-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ runCommand | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
raboof
Author
Member
|
||
, callPackage | ||
, jdk | ||
, jre_minimal | ||
}: | ||
|
||
let | ||
hello = callPackage tests/hello.nix { | ||
jdk = jdk; | ||
jre = jre_minimal; | ||
}; | ||
in | ||
runCommand "test" {} '' | ||
${hello}/bin/hello | grep "Hello, world!" | ||
touch $out | ||
'' |
47 changes: 47 additions & 0 deletions
47
pkgs/development/compilers/openjdk/tests/hello-logging.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ jdk | ||
, jre | ||
, pkgs | ||
}: | ||
|
||
/* 'Hello world' Java application derivation for use in tests */ | ||
let | ||
source = pkgs.writeTextDir "src/Hello.java" '' | ||
import java.util.logging.Logger; | ||
import java.util.logging.Level; | ||
class Hello { | ||
static Logger logger = Logger.getLogger(Hello.class.getName()); | ||
public static void main(String[] args) { | ||
logger.log(Level.INFO, "Hello, world!"); | ||
} | ||
} | ||
''; | ||
in | ||
pkgs.stdenv.mkDerivation { | ||
pname = "hello"; | ||
version = "1.0.0"; | ||
|
||
src = source; | ||
|
||
buildPhase = '' | ||
runHook preBuildPhase | ||
${jdk}/bin/javac src/Hello.java | ||
runHook postBuildPhase | ||
''; | ||
installPhase = '' | ||
runHook preInstallPhase | ||
mkdir -p $out/lib | ||
cp src/Hello.class $out/lib | ||
mkdir -p $out/bin | ||
cat >$out/bin/hello <<EOF; | ||
#!/usr/bin/env sh | ||
${jre}/bin/java -cp $out/lib Hello | ||
EOF | ||
chmod a+x $out/bin/hello | ||
runHook postInstallPhase | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ jdk | ||
, jre | ||
, pkgs | ||
}: | ||
|
||
/* 'Hello world' Java application derivation for use in tests */ | ||
let | ||
source = pkgs.writeTextDir "src/Hello.java" '' | ||
class Hello { | ||
public static void main(String[] args) { | ||
System.out.println("Hello, world!"); | ||
} | ||
} | ||
''; | ||
in | ||
pkgs.stdenv.mkDerivation { | ||
pname = "hello"; | ||
version = "1.0.0"; | ||
|
||
src = source; | ||
|
||
buildPhase = '' | ||
runHook preBuildPhase | ||
${jdk}/bin/javac src/Hello.java | ||
runHook postBuildPhase | ||
''; | ||
installPhase = '' | ||
runHook preInstallPhase | ||
mkdir -p $out/lib | ||
cp src/Hello.class $out/lib | ||
mkdir -p $out/bin | ||
cat >$out/bin/hello <<EOF; | ||
#!/usr/bin/env sh | ||
${jre}/bin/java -cp $out/lib Hello | ||
EOF | ||
chmod a+x $out/bin/hello | ||
runHook postInstallPhase | ||
''; | ||
} |
16 changes: 16 additions & 0 deletions
16
pkgs/development/compilers/openjdk/tests/test_jre_minimal.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ runCommand | ||
, callPackage | ||
, jdk | ||
, jre_minimal | ||
}: | ||
|
||
let | ||
hello = callPackage ./hello.nix { | ||
jdk = jdk; | ||
jre = jre_minimal; | ||
}; | ||
in | ||
runCommand "test" {} '' | ||
${hello}/bin/hello | grep "Hello, world!" | ||
touch $out | ||
'' |
21 changes: 21 additions & 0 deletions
21
pkgs/development/compilers/openjdk/tests/test_jre_minimal_with_logging.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ runCommand | ||
, callPackage | ||
, jdk | ||
, jre_minimal | ||
}: | ||
|
||
let | ||
hello-logging = callPackage ./hello-logging.nix { | ||
jdk = jdk; | ||
jre = jre_minimal.override { | ||
modules = [ | ||
"java.base" | ||
"java.logging" | ||
]; | ||
}; | ||
}; | ||
in | ||
runCommand "test" {} '' | ||
${hello-logging}/bin/hello &>/dev/stdout | grep "Hello, world!" | ||
touch $out | ||
'' |
@raboof can you double check if the file is placed correctly?