Giter Club home page Giter Club logo

gradle-test-kotlin-extensions's People

Contributors

mkobit avatar

Stargazers

 avatar  avatar

gradle-test-kotlin-extensions's Issues

Introduce better mechanism for adding/removing arguments for repeated executions

Some tests would like to do the following

  • build(arg1) - assert on build result
  • build(arg2) - assert on build result

Where the arguments between the first and second build are different.
In most cases I find myself wanting to keep most of the options like --stacktrace and --info while only changing the tasks that are executed. This will be sort of problematic with how the GradleRunner APIs work.

This currently requires some thought as mixing both arguments and options does not work incredibly well together and the APIs are still pretty meh to use.

I think this will result in API changing to provider a more "base runner" context and then copy/run builds from that. The BuildResult is what will be queried anyways afterwards.

Figuring out the right API here is the most important part.

TODO: Propose a better API that accomplishes the following:

  • Produce new build executions for same project directory with default (preconfigured) arguments
  • Append additional context to new build execution
  • (Possibly) mutate default (preconfigured) arguments

Assumption here is that the project directory is reused

Add in CharSequence setter overload for `RegularFileContext.content` to enable `file.content = "some content"`

Right now, the RegularFileContext.content getters/setters are for ByteArray to not make assumptions about encoding for users and also better translate to what the Files APIs do. This still isn't friendly so might be revisited.

Being able to also just set the content as a String or CharSequence would most likely be easier for most users, so maybe it should be the default?

Right now:

FileContext.RegularFileContext(path).content = "stuff".toByteArray()

this would enable it to also be

FileContext.RegularFileContext(path).content = "stuff"

dependent on https://youtrack.jetbrains.com/issue/KT-4075

Published 0.2.0 POM does not include version in Kotlin dependency

The Kotlin plugin automatically resolves version based on plugin version used, so you can do api(kotlin("stdlib-jre8")). Unfortunately, the version is not also in the POM

Easiest fix is to just explicitly use the same version

Should also follow up with a YouTrack issue for patching the Kotlin Gradle plugin for publishing

    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-stdlib-jre8</artifactId>
      <scope>compile</scope>
    </dependency>

Introduce additional DSL methods for creating files and directories

see https://kotlinlang.org/docs/reference/operator-overloading.html

possible functions:

  • FileContext.DirectoryContext
    • operator fun String.invoke(action: FileAction, setup: FileContext.DirectoryContext.() -> Unit) - apply action to file path (file or directory?), and do setup on it
    • operator fun div(action: FileAction, directoryName: CharSequence) - create or get directory at path
  • FileContext.RegularFileContext
    • operator fun plus(bytes: ByteArray) - append bytes to file
    • operator fun plus(content: CharSequence) - append toString() to file with default encoding

DSL thoughts:

runner.setupProjectDir {
  "src" {
    "main" {
        "java" {
          "MyFile.java"("public class MyFile {}")
        }
    }
  }
}

Finalize FileContext DSL

  • - should we keep the current div syntax for constructing DirectoryContext and nested DirectoryContext?
  • - should we keep the current string invocation methods for creating a RegularFileContext inside of a DirectoryContext?
  • - should RegularFileContext methods accept a character encoding, or should it only be done at construction time?

Retrieve Path to GradleRunner

As a developer I want to retrieve the Path from the GradleRunner so that I can use NIO APIs to set up test projects more easily.

Change DSL `invoke` signature to return a `RegularFileContext` instead of a `DirectoryContext`

    public operator fun CharSequence.invoke(
        fileAction: FileAction = FileAction.MaybeCreate,
        action: DirectoryContext.() -> Unit
    ): DirectoryContext = directory(this, fileAction, action)

Right now the UX is like this:

gradleRunner.setupProjectDir {
  "build.gradle" { // DirectoryContext
  }
  
  "build.gradle"(content = Original) { // RegularFileContext
  }
}

It is more consistent and expected for these both to return a RegularFileContext

Consider adding operator div function for DirectoryContext

Idea is to overload the div operator for possibly more fluent directory expanding

radleRunner.setupProjectDir {
  this / "dir1" / "dir3" / "dir4"
  this / "dir1/dir2/dir3"
  "dir1" / "dir2" {
    // DirectoryContext for "dir2"
  }
  "dir1" / "dir2" {
    "dir3" / {
      // DirectoryContext for "dir3"
    }
    "file1" {
      // RegularFileContext for file1
    }
  }
}

Combined with #27 it might be easier to create nested file is directories that may be mostly empty. For example, files in deeper Java package structures.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.