Unverified Commit 7754699a authored by Benedikt Ritter's avatar Benedikt Ritter
Browse files

gradle: fix toolchains test

The test was incorrectly comparing the full value of the java.version
system property returned by the JVM at runtime with the major version of
the Nix package.

After this change the test does a prefix comparison between the system
property value and the nix package version, e.g. it will check whether
23.0.2+7 (Nix package version) starts with 23.0.2 (system property).

Furthermore the test now logs the expected and actual values in case of
a missmatch.
parent de515c09
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -286,7 +286,8 @@ rec {
            tests = {
              toolchains =
                let
                  javaVersion = lib.versions.major (lib.getVersion jdk23);
                  javaVersion = lib.getVersion jdk23;
                  javaMajorVersion = lib.versions.major javaVersion;
                in
                runCommand "detects-toolchains-from-nix-env"
                  {
@@ -302,10 +303,14 @@ rec {
                  }
                  ''
                    cp -a $src/* .
                    substituteInPlace ./build.gradle --replace-fail '@JAVA_VERSION@' '${javaVersion}'
                    substituteInPlace ./build.gradle --replace-fail '@JAVA_VERSION@' '${javaMajorVersion}'
                    env GRADLE_USER_HOME=$TMPDIR/gradle org.gradle.native.dir=$TMPDIR/native \
                    gradle run --no-daemon --quiet --console plain > $out
                    test "$(<$out)" = "${javaVersion}"
                    actual="$(<$out)"
                    if [[ "${javaVersion}" != "$actual"* ]]; then
                      echo "Error: Expected '${javaVersion}', to start with '$actual'" >&2
                      exit 1
                    fi
                  '';
            } // gradle.tests;
          }