craigburke / karma-gradle

Gradle Plugin for Running tests with Karma
Other
21 stars 11 forks source link

basePath computed from `build` dir #1

Open rahulsom opened 8 years ago

rahulsom commented 8 years ago

I was running into problems with the plugin reporting ERROR.

:karmaDependencies (Thread[Task worker Thread 3,5,main]) completed. Took 48.84 secs.
:karmaRun (Thread[Daemon worker Thread 5,5,main]) started.
:karmaRun
Executing task ':karmaRun' (up-to-date check took 0.0 secs) due to:
  Task has not declared any outputs.
Starting process 'command '/Users/rahul/.gradle/nodejs/node-v4.2.2-darwin-x64/bin/node''. Working directory: /Users/rahul/src/hottowel-ratpack Command: /Users/rahul/.gradle/nodejs/node-v4.2.2-darwin-x64/bin/node /Users/rahul/src/hottowel-ratpack/node_modules/karma/bin/karma start /Users/rahul/src/hottowel-ratpack/build/karma.conf.js --single-run
Successfully started process 'command '/Users/rahul/.gradle/nodejs/node-v4.2.2-darwin-x64/bin/node''
PhantomJS 1.9.8 (Mac OS X 0.0.0): Executed 0 of 0 ERROR (0.006 secs / 0 secs)

I modified the karma.conf.js to set logLevel to DEBUG. This is one of the things it would be nice if the plugin allowed.

Then I saw that it was computing basePath from the build dir onwards.

02 12 2015 10:31:00.887:DEBUG [plugin]: Loading plugin /Users/rahul/src/hottowel-ratpack/node_modules/karma-jasmine.
02 12 2015 10:31:00.889:DEBUG [plugin]: Loading plugin /Users/rahul/src/hottowel-ratpack/node_modules/karma-junit-reporter.
02 12 2015 10:31:00.953:DEBUG [plugin]: Loading plugin /Users/rahul/src/hottowel-ratpack/node_modules/karma-phantomjs-launcher.
02 12 2015 10:31:01.070:WARN [watcher]: Pattern "/Users/rahul/src/hottowel-ratpack/build/src/assets/bower/**/*.js" does not match any file.
02 12 2015 10:31:01.071:WARN [watcher]: Pattern "/Users/rahul/src/hottowel-ratpack/build/src/assets/js**/!(*.spec).js" does not match any file.
02 12 2015 10:31:01.072:WARN [watcher]: Pattern "/Users/rahul/src/hottowel-ratpack/build/src/assets/js**/*.spec.js" does not match any file.
02 12 2015 10:31:01.084:INFO [karma]: Karma v0.13.15 server started at http://localhost:9876/
02 12 2015 10:31:01.096:INFO [launcher]: Starting browser PhantomJS
02 12 2015 10:31:01.097:DEBUG [temp-dir]: Creating temp dir at /var/folders/3z/70s6csl91dj6m9r1360pvmdw0000gr/T/karma-66054161
02 12 2015 10:31:01.101:DEBUG [launcher]: /Users/rahul/src/hottowel-ratpack/node_modules/phantomjs/lib/phantom/bin/phantomjs /var/folders/3z/70s6csl91dj6m9r1360pvmdw0000gr/T/karma-66054161/capture.js

Workaround:

  basePath = '../src/assets'
craigburke commented 8 years ago

The plugin already allows you to set the log level:

karma {
    logLevel = 'DEBUG'
}

Good point about the path (I've just been using absolute paths there). It would make more sense for relative paths to be resolved relative to the project root. I'll look at changing that.

wbartensleben commented 8 years ago

Setting the logLevel as mentioned above produces a NullPointerException:

org.gradle.api.GradleScriptException: A problem occurred evaluating project ':applications:dev-console'.
    at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
    at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$1.run(DefaultScriptPluginFactory.java:148)
    at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:72)
    at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:153)
    at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:38)
    at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:25)
    at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
    at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:499)
    at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:86)
    at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:47)
    at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
    at org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:125)
    at org.gradle.internal.Factories$1.create(Factories.java:22)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:122)
    at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
    at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
    at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
    at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
    at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:77)
    at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:47)
    at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
    at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.Main.doAction(Main.java:33)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.lang.NullPointerException
    at org.gradle.api.internal.coerce.StringToEnumTransformer.transformValue(StringToEnumTransformer.java:64)
    at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.setProperty(BeanDynamicObject.java:193)
    at org.gradle.api.internal.BeanDynamicObject.setProperty(BeanDynamicObject.java:111)
    at org.gradle.api.internal.CompositeDynamicObject.setProperty(CompositeDynamicObject.java:112)
    at com.craigburke.gradle.KarmaModuleExtension_Decorated.setProperty(Unknown Source)
    at build_bsm0fi2dkdup6bkry9eeh9yo4$_run_closure19.doCall(/Users/pivotal/workspace/trailblazer/applications/dev-console/build.gradle:182)
    at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:67)
    at org.gradle.api.internal.plugins.ExtensionsStorage$ExtensionHolder.configure(ExtensionsStorage.java:145)
    at org.gradle.api.internal.plugins.ExtensionsStorage.configureExtension(ExtensionsStorage.java:69)
    at org.gradle.api.internal.plugins.DefaultConvention$ExtensionsDynamicObject.invokeMethod(DefaultConvention.java:207)
    at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:150)
    at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79)
    at build_bsm0fi2dkdup6bkry9eeh9yo4.run(/Users/pivotal/workspace/trailblazer/applications/dev-console/build.gradle:174)
    at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
    ... 47 more
eriwen commented 8 years ago

I also get an NPE trying to set logLevel.

Is it conflicting at all with https://github.com/craigburke/karma-gradle/blob/master/src/main/groovy/com/craigburke/gradle/KarmaModuleExtension.groovy#L77 ?

codebox commented 7 years ago

Same problem here - NullPointerException when setting logLevel