Skip to content

Commit

Permalink
Merge pull request #407 from Vlatombe/fix-tests-on-macos
Browse files Browse the repository at this point in the history
Fix running tests on MacOS
  • Loading branch information
jglick authored Nov 20, 2024
2 parents 6a3e903 + dbebab8 commit 6ae8123
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import hudson.ExtensionList;
import hudson.Functions;
import hudson.Platform;
import hudson.Util;
import hudson.model.ParametersAction;
import hudson.model.ParametersDefinitionProperty;
import hudson.model.StringParameterDefinition;
Expand Down Expand Up @@ -121,7 +123,8 @@ private static void scriptExitingAcrossRestart2(JenkinsRule r) throws Throwable
r.assertBuildStatusSuccess(r.waitForCompletion(b));
// In the case of Bourne shell, `+ touch …` is printed when the command actually runs.
// In the case of batch shell, the whole command is printed immediately, so we need to assert that the _output_ of `dir` is there.
r.assertLogContains(Functions.isWindows() ? "Directory of " + r.jenkins.getRootDir() : "+ touch " + new File(r.jenkins.getRootDir(), "f"), b);
var file = new File(r.jenkins.getRootDir(), "f");
r.assertLogContains(Functions.isWindows() ? "Directory of " + r.jenkins.getRootDir() : "+ touch " + (Platform.isDarwin() ? Util.singleQuote(file.toString()) : file), b);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import hudson.Launcher;
import hudson.LauncherDecorator;
import hudson.MarkupText;
import hudson.Platform;
import hudson.console.AnnotatedLargeText;
import hudson.console.ConsoleAnnotator;
import hudson.console.ConsoleLogFilter;
Expand Down Expand Up @@ -248,6 +249,8 @@ public void abort() throws Exception {

@Test public void launcherDecorator() throws Exception {
Assume.assumeTrue("TODO Windows equivalent TBD", new File("/usr/bin/nice").canExecute());

Check warning on line 251 in src/test/java/org/jenkinsci/plugins/workflow/steps/durable_task/ShellStepTest.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

TODO

NORMAL: Windows equivalent TBD", new File("/usr/bin/nice").canExecute());
// https://stackoverflow.com/questions/44811425/nice-command-not-working-on-macos
Assume.assumeFalse("MacOS doesn't implement nice", Platform.isDarwin());
WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("node {sh 'echo niceness=`nice`'}", true));
Assume.assumeThat("test only works if mvn test is not itself niced", JenkinsRule.getLog(j.assertBuildStatusSuccess(p.scheduleBuild2(0))), containsString("niceness=0"));
Expand Down

0 comments on commit 6ae8123

Please sign in to comment.