Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix running tests on MacOS #407

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -247,7 +248,9 @@
}

@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