Skip to content

Clojure native #138

Closed
wants to merge 13 commits into from

4 participants

@hiredman

rewrite of the clojure backend in clojure

  • includes a lein plugin

  • snippet support is not included

    • dealing with abstract classes with private and protected methods and fields in clojure is a pain, it would be nice if there was an interface to use for this
  • no changes to tests (not sure how/if the stuff in src/test runs)

  • the loading of clojure source needs some work, mostly due to the change to FileResourceLoader, but clojure always loads relative to the classpath, so at least in the lein plugin I may switch back to the ClassPathResourceLoader

@aslakhellesoy aslakhellesoy commented on the diff Jan 14, 2012
...c/main/java/cucumber/runtime/StepDefinitionMatch.java
@@ -78,7 +78,9 @@ public void runStep(Locale locale) throws Throwable {
@aslakhellesoy
Cucumber member

This class is no longer used - am I correct? Delete it?

@aslakhellesoy
Cucumber member

Never mind my last comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@aslakhellesoy aslakhellesoy commented on the diff Jan 14, 2012
clojure/src/main/clj/cucumber/runtime/clj.clj
+ (filter #(= "invoke" (.getName %)))
+ (map #(count (.getParameterTypes %)))
+ (apply max))]
+ (.addBeforeHook
+ @world
+ (reify
+ HookDefinition
+ (execute [hd scenario-result]
+ (if (zero? max-parameter-count)
+ (hook-fun)
+ (hook-fun scenario-result)))
+ (matches [hd tags]
+ (.eval te tags))
+ (getOrder [hd] 0)))))
+
+;; TODO: before and after hooks
@aslakhellesoy
Cucumber member

TODO is done?

@hiredman
hiredman added a note Jan 14, 2012

it is, I forgot to delete it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@aslakhellesoy aslakhellesoy commented on the diff Jan 14, 2012
...c/main/java/cucumber/runtime/StepDefinitionMatch.java
@@ -78,7 +78,9 @@ public void runStep(Locale locale) throws Throwable {
int n = 0;
for (Argument a : getArguments()) {
+ if (parameterTypes != null) {
@aslakhellesoy
Cucumber member

What's the reason behind this change? Can you add a test/feature to demonstrate why it's needed? Also, indentation is off.

@hiredman
hiredman added a note Jan 14, 2012

https://github.com/cucumber/cucumber-jvm/blob/master/core/src/main/java/cucumber/runtime/StepDefinition.java#L30

the comments in the interface say that paramterTypes can be null, so the above code needs a null check.

it looks like you have a different fix on master c3c328c so I can pull this out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@aslakhellesoy
Cucumber member

RE: snippets: I'll refactor it to make it easier to use. (Replace inheritance with delegation)

RE: tests: You haven't tried to run the tests? How do you know if this works then?

RE: Changes to FileResourceLoader. What changes are you referring to? Feel free to change back to the ClasspathResourceLoader if that makes more sense.

@hiredman

I am interested in using cucumber for integration tests for a clojure application. in the process of writing this I also wrote my first feature and scenarios for doing the integration testing. That's how I know the code "works".

I would like to get the existing tests working, there are some files in clojure/src/test but when I run 'mvn test' nothing happens, this may be the result of me adding clojure-maven-plugin to the pom. I'm not a big maven guy, we use leiningen at work.

As I was working on this at someone point when I merged in master things broke and I had to fiddle with the paths passed in to cli.Main (this was before I stopped using cli.Main in the lein plugin) and I thought that somehow the Backend switched from getting passed a ClasspathResourceLoader to a FileResourceLoader, perhaps this is incorrect.

@aslakhellesoy
Cucumber member

Did you have a chance to look at the Snippet API after I refactored it? Now you just have an interface to implement - much better separation IMO.

I haven't tried your code yet (it no longer applies cleanly with master). Can you try to run the regular ant build and make sure it works?

Currently a Backend is instantiated with a ClasspathResourceLoader when kicked off from JUnit, and a FileResourceLoader when kicked off from the CLI. This seems like a sensible default, especially since Java people will prefer the JUnit runner, while e.g. jruby/jython/rhino etc people will prefer the CLI.

Clojure seems like an exception to the rule (jruby/jython/rhino don't use the CLASSPATH), so maybe you should ignore the resourceLoader passed to the ctor and always use a ClasspathResourceLoader.

@rplevy-draker

I ran "mvn clean install" on the clojure-native branch and it fails when running the test cucumber.resources.ResourcesTest. That file doesn't seems to contain any actual tests however.

This doesn't occur on the master branch of cucumber-jvm, main repo (but as a side note, a Groovy test fails).

@aslakhellesoy
Cucumber member

Is anyone interested in bringing this uptodate with the current master HEAD? If not I'll close this issue. /cc @hiredman @rplevy-draker @nilswloka

@nilswloka
Cucumber member

I'm not sure whether I have sufficient Clojure skills, but I can give it a try. I'm still very much interested in a native version.

@nilswloka
Cucumber member

Sent a pull request: #265

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.