Skip to content

Commit

Permalink
objfw: move passthru test to its own file (NixOS#367625)
Browse files Browse the repository at this point in the history
  • Loading branch information
khaneliman authored Dec 23, 2024
2 parents 5195fb3 + e8c6769 commit 4751b20
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 38 deletions.
39 changes: 1 addition & 38 deletions pkgs/by-name/ob/objfw/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,44 +33,7 @@ clangStdenv.mkDerivation (finalAttrs: {
doCheck = true;

passthru.tests = {
build-hello-world = clangStdenv.mkDerivation {
name = "ObjFW test";
buildInputs = [ objfw ];

src = writeTextDir "helloworld.m" ''
#import <ObjFW/ObjFW.h>
int main() {
OFLog(@"Hello world from objc");
return 0;
}
'';

buildPhase = ''
runHook preBuild
clang -o testbinary \
-x objective-c -Xclang \
-fobjc-runtime=objfw \
-funwind-tables \
-fconstant-string-class=OFConstantString \
-Xclang -fno-constant-cfstrings \
helloworld.m \
-lobjfw -lobjfwrt
runHook postBuild
'';

checkPhase = ''
runHook preCheck
./testbinary
runHook postCheck
'';
doCheck = true;

installPhase = ''
runHook preInstall
touch $out
runHook postInstall
'';
};
build-hello-world = (import ./test-build-and-run.nix) { inherit clangStdenv objfw writeTextDir; };
};

meta = {
Expand Down
44 changes: 44 additions & 0 deletions pkgs/by-name/ob/objfw/test-build-and-run.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
clangStdenv,
objfw,
writeTextDir,
}:

clangStdenv.mkDerivation {
name = "ObjFW test";
buildInputs = [ objfw ];

src = writeTextDir "helloworld.m" ''
#import <ObjFW/ObjFW.h>
int main() {
OFLog(@"Hello world from objc");
return 0;
}
'';

buildPhase = ''
runHook preBuild
clang -o testbinary \
-x objective-c -Xclang \
-fobjc-runtime=objfw \
-funwind-tables \
-fconstant-string-class=OFConstantString \
-Xclang -fno-constant-cfstrings \
helloworld.m \
-lobjfw -lobjfwrt
runHook postBuild
'';

checkPhase = ''
runHook preCheck
./testbinary
runHook postCheck
'';
doCheck = true;

installPhase = ''
runHook preInstall
touch $out
runHook postInstall
'';
}

0 comments on commit 4751b20

Please sign in to comment.