Skip to content

Shell 0.6.0 #4

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

Draft
wants to merge 51 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
5568539
Initial commit for 0.6.0
aartiPl Apr 5, 2023
016ddb6
Merged changes from master
aartiPl May 4, 2023
9b4824b
Added shorthand functions for composing OsPaths
aartiPl May 6, 2023
5c37661
Added shorthand functions for composing OsPaths
aartiPl May 6, 2023
1a32e9c
Added tests for commands
aartiPl Jun 17, 2023
3de30a9
* Better tests
aartiPl Jun 17, 2023
661f4d5
* Ability to not use shell
aartiPl Jun 17, 2023
a584e1d
Test improvements
aartiPl Jun 19, 2023
f3b8e76
Passing Input Stream to ProcessRunner.
aartiPl Jun 22, 2023
8ce8ace
Removed files, which should be in kscript
aartiPl Jun 22, 2023
024a9ae
Removed experimental files
aartiPl Jun 24, 2023
226cbf8
* Publishing test artifact
aartiPl Jun 24, 2023
14fc674
Improvements
aartiPl Jun 24, 2023
f11b39d
Added github actions
aartiPl Jun 24, 2023
fdd3ec4
Make ./gradlew executable
aartiPl Jun 24, 2023
86e7c2b
integrationTest -> itest
aartiPl Jun 24, 2023
56fd140
adjustment for nl
aartiPl Jun 24, 2023
439ab1c
adjustment for nl
aartiPl Jun 24, 2023
7359239
update
aartiPl Jun 24, 2023
3f3dc2a
Removed UNDEFINED PathType
aartiPl Jun 26, 2023
f1faf5b
Refactored to contain 'root' value
aartiPl Jul 6, 2023
33a28ec
Refactored parsing
aartiPl Jul 6, 2023
b53aff9
Removed PathType
aartiPl Jul 6, 2023
0286c8e
Update
aartiPl Jul 6, 2023
86930ff
Fixed test
aartiPl Jul 6, 2023
6dd6ad4
Improvements
aartiPl Jul 6, 2023
d044c23
Improvements
aartiPl Jul 10, 2023
23b8a35
Reverted OsPath changes
aartiPl Aug 2, 2023
a71ad05
* Removed PathType enum
aartiPl Aug 2, 2023
600bc78
* Small improvements
aartiPl Aug 2, 2023
4011fcf
Design cd.
aartiPl Aug 5, 2023
c5c35b5
Design cd.
aartiPl Aug 19, 2023
4c495e2
Design cd.
aartiPl Aug 19, 2023
f7dae85
Ability to handle osType string
aartiPl Aug 19, 2023
e06e067
Reimplemented OsType, so that it can simplify implementation of OsType
aartiPl Aug 19, 2023
16f5d16
Improved implementation of hosted paths
aartiPl Aug 21, 2023
baec188
Improved implementation of hosted paths (shortening home and root paths)
aartiPl Aug 22, 2023
c363bbe
Cleanup.
aartiPl Sep 15, 2023
a76e7c8
Removed Either.
aartiPl Sep 15, 2023
9b6b1b3
Use Result<>
aartiPl Oct 31, 2023
61c6f96
Improvements
aartiPl Oct 31, 2023
55e3487
Removed Result<>
aartiPl Nov 1, 2023
34391e6
Update
aartiPl Nov 1, 2023
0512f05
Update
aartiPl Dec 21, 2023
c84e603
Update
aartiPl Dec 23, 2023
cd3774b
Update
aartiPl Dec 23, 2023
0760e07
Update
aartiPl Dec 23, 2023
b9c0866
Update
aartiPl Dec 26, 2023
0415f31
Update
aartiPl Dec 26, 2023
24aba61
Update
aartiPl Dec 26, 2023
6c9b701
* Updated build.gradle.kts to the latest Kotlin
aartiPl Jun 17, 2025
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
106 changes: 106 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: build

on:
workflow_dispatch:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- macos-12
- windows-2022
variant:
- posix
include:
- os: windows-2022
variant: cygwin
- os: windows-2022
variant: cmd
runs-on: ${{ matrix.os }}
timeout-minutes: 30

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'

- name: Setup Kotlin
uses: fwilhe2/setup-kotlin@main
with:
version: 1.7.21

- name: Install dependencies for ${{ runner.os }}
shell: bash
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
choco install zip
# Overwrite the WSL bash.exe
# cp /c/msys64/usr/bin/bash.exe /c/Windows/System32/bash.exe
mv /c/Windows/System32/bash.exe /c/Windows/System32/wsl-bash.exe
fi

- name: Run tests for Posix (and MSYS on Windows)
if: matrix.variant == 'posix'
shell: bash
run: |
# For Windows this action is running MSYS Os type

echo "OsType: $OSTYPE"

chmod +x ./gradlew

./gradlew clean assemble test || { echo 'Compilation or Unit tests failed' ; exit 1; }

if [[ "$OSTYPE" == "linux"* ]]; then
echo "Linux test..."
./gradlew -DosType=$OSTYPE -DincludeTags='posix | linux' itest
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "MacOs test..."
./gradlew -DosType=$OSTYPE -DincludeTags='posix | macos' itest
elif [[ "$OSTYPE" == "cygwin" ]]; then
echo "Cygwin test..."
./gradlew -DosType=$OSTYPE -DincludeTags='posix | cygwin' itest
elif [[ "$OSTYPE" == "msys" ]]; then
echo "MSys test..."
./gradlew -DosType=$OSTYPE -DincludeTags='posix | msys' itest
elif [[ "$OSTYPE" == "freebsd"* ]]; then
echo "FreeBsd test..."
./gradlew -DosType=$OSTYPE -DincludeTags='posix' itest
else
echo "Unknown OS"
exit 1
fi

- name: Run tests specific for Windows (cmd shell)
if: matrix.variant == 'cmd'
shell: cmd
run: |
echo "Windows test..."
.\gradlew.bat -DosType=windows -DincludeTags="windows" clean assemble test itest

- name: Install Cygwin (only Windows)
if: matrix.variant == 'cygwin'
uses: egor-tensin/setup-cygwin@v3

- name: Run tests specific for Cygwin
if: matrix.variant == 'cygwin'
shell: C:\tools\cygwin\bin\bash.exe --login --norc -eo pipefail -o igncr '{0}'
run: |
echo $OSTYPE
echo "Cygwin test..."
echo "Changing directory to $GITHUB_WORKSPACE ..."
cd $GITHUB_WORKSPACE
./gradlew clean assemble test || { echo 'Compilation or Unit tests failed' ; exit 1; }
./gradlew -DosType=$OSTYPE -DincludeTags='posix | cygwin' itest
19 changes: 17 additions & 2 deletions TODO.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
= shell 0.6 features:
= shell 0.6.0-SNAPSHOT features:

* Use https://github.com/JetBrains/pty4j[PTY4j] instead of ProcessBuilder to read color codes from input and append them to output
* Move shell test classes from kscript to the library
* dry-run, with test output provider
* printing of commands
* Command for encapsulating commands?
* Throw on exitCode != 0 and/or skipErrors
* verifier for different types like in assertk/assertj
* log masking (shallow - in printout and deep in stderr/stdout); masking list of the words; is the design with Streams valid for that?
* Encoding of special characters in output (\n, \, etc.)
* Interface for ShellExecutor (to allow mocking)
* Printing Output of commands
* Possibility of parametrization of commands (properties) + masking (for tests and interoperability)
* Silent mode ()
* Use https://github.com/JetBrains/pty4j[PTY4j] instead of ProcessBuilder to read color codes from input and append them to output (https://stackoverflow.com/questions/45789329/java-capture-process-output-with-color)
* Providing different types of shell (e.g. 'sh' or 'zsh') and executing without shell
* Library for testing
* Ideas: Generic verifier? ShellExecutorBuilder?
155 changes: 90 additions & 65 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
val kotlinVersion: String = "1.7.21"

val kotlinVersion: String = "2.1.21"

plugins {
kotlin("jvm") version "1.7.21"
id("com.adarshr.test-logger") version "3.2.0"
kotlin("jvm") version "2.1.21"
id("com.adarshr.test-logger") version "4.0.0"
`maven-publish`
signing
idea
}

repositories {
mavenLocal()
mavenCentral()
}

group = "io.github.kscripting"
version = "0.5.2"
version = "0.6.0-SNAPSHOT"

kotlin {
jvmToolchain(17)
}

configurations.all {
resolutionStrategy.cacheDynamicVersionsFor(0, "seconds")
resolutionStrategy.cacheChangingModulesFor(0, "seconds")
}

/*

sourceSets {
create("integration") {
// test { //With that idea can understand that 'integration' is test source set and do not complain about test
// names starting with upper case, but it doesn't compile correctly with it
java.srcDir("$projectDir/src/integration/kotlin")
resources.srcDir("$projectDir/src/integration/resources")
create("itest") {
kotlin.srcDir("$projectDir/src/itest/kotlin")
resources.srcDir("$projectDir/src/itest/resources")

compileClasspath += main.get().output + test.get().output
runtimeClasspath += main.get().output + test.get().output
}
// }
}

configurations {
get("integrationImplementation").apply { extendsFrom(get("testImplementation")) }
get("itestImplementation").apply { extendsFrom(get("testImplementation")) }
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}

withJavadocJar()
withSourcesJar()
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
kotlinOptions {
jvmTarget = "1.8"
}
}

tasks.create<Test>("integration") {
tasks.create<Test>("itest") {
val itags = System.getProperty("includeTags") ?: ""
val etags = System.getProperty("excludeTags") ?: ""

Expand All @@ -65,11 +64,10 @@ tasks.create<Test>("integration") {

description = "Runs the integration tests."
group = "verification"
testClassesDirs = sourceSets["integration"].output.classesDirs
classpath = sourceSets["integration"].runtimeClasspath
testClassesDirs = sourceSets["itest"].output.classesDirs
classpath = sourceSets["itest"].runtimeClasspath
outputs.upToDateWhen { false }
mustRunAfter(tasks["test"])
//dependsOn(tasks["assemble"], tasks["test"])
dependsOn(tasks["assemble"])

doLast {
println("Include tags: $itags")
Expand All @@ -79,10 +77,31 @@ tasks.create<Test>("integration") {

tasks.create<Task>("printIntegrationClasspath") {
doLast {
println(sourceSets["integration"].runtimeClasspath.asPath)
println(sourceSets["itest"].runtimeClasspath.asPath)
}
}

idea {
module {
testSources.from(sourceSets["itest"].kotlin.srcDirs)
}
}

val testToolsJar by tasks.registering(Jar::class) {
//archiveFileName.set("eulenspiegel-testHelpers-$version.jar")
archiveClassifier.set("test")
include("io/github/kscripting/shell/integration/tools/*")
from(sourceSets["itest"].output)
}



*/
*/

//val publishArtifact = artifacts.add("archives", testToolsJar)
val publishArtifact = artifacts.add("archives", tasks.jar) //TODO: above line is correct - current should be removed

testlogger {
showStandardStreams = true
showFullStackTraces = false
Expand All @@ -92,35 +111,42 @@ tasks.test {
useJUnitPlatform()
}

val licencesSpec = Action<MavenPomLicenseSpec> {
license {
name.set("MIT License")
url.set("https://opensource.org/licenses/MIT")
}
}

val developersSpec = Action<MavenPomDeveloperSpec> {
developer {
id.set("aartiPl")
name.set("Marcin Kuszczak")
email.set("aarti@interia.pl")
}
}

val scmSpec = Action<MavenPomScm> {
connection.set("scm:git:git://https://github.com/kscripting/shell.git")
developerConnection.set("scm:git:ssh:https://github.com/kscripting/shell.git")
url.set("https://github.com/kscripting/shell")
}

publishing {
publications {
create<MavenPublication>("mavenJava") {
create<MavenPublication>("shell") {
artifactId = "shell"
from(components["java"])
artifact(publishArtifact)

pom {
name.set("kscript")
name.set("shell")
description.set("Shell - library for interoperability with different system shells")
url.set("https://github.com/kscripting/shell")

licenses {
license {
name.set("MIT License")
url.set("https://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set("aartiPl")
name.set("Marcin Kuszczak")
email.set("aarti@interia.pl")
}
}
scm {
connection.set("scm:git:git://https://github.com/kscripting/shell.git")
developerConnection.set("scm:git:ssh:https://github.com/kscripting/shell.git")
url.set("https://github.com/kscripting/shell")
}
licenses(licencesSpec)
developers(developersSpec)
scm(scmSpec)
}
}
}
Expand All @@ -140,28 +166,27 @@ publishing {
}

signing {
sign(publishing.publications["mavenJava"])
sign(publishing.publications["shell"])
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")

implementation("org.jetbrains.kotlin:kotlin-scripting-common:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-scripting-jvm:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-scripting-dependencies-maven-all:$kotlinVersion")
implementation("io.arrow-kt:arrow-core:1.1.2")
implementation("org.apache.commons:commons-lang3:3.12.0")

implementation("org.slf4j:slf4j-nop:2.0.4")
api("net.igsoft:typeutils:0.7.0-SNAPSHOT")

testImplementation("org.junit.platform:junit-platform-suite-engine:1.9.0")
testImplementation("org.junit.platform:junit-platform-suite-api:1.9.0")
testImplementation("org.junit.platform:junit-platform-suite-commons:1.9.0")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.9.0")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.0")
testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.25")
implementation("org.apache.commons:commons-lang3:3.12.0")
implementation("org.slf4j:slf4j-nop:2.0.5")

val junitPlatformVersion = "1.13.1"
val junitEngineVersion = "5.13.1"
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("org.junit.platform:junit-platform-suite-engine:${junitPlatformVersion}")
testImplementation("org.junit.platform:junit-platform-suite-api:${junitPlatformVersion}")
testImplementation("org.junit.platform:junit-platform-suite-commons:${junitPlatformVersion}")
testImplementation("org.junit.jupiter:junit-jupiter:$junitEngineVersion")
testImplementation("org.junit.jupiter:junit-jupiter-params:$junitEngineVersion")
testImplementation("com.willowtreeapps.assertk:assertk:0.28.1")
testImplementation("io.mockk:mockk:1.13.2")

testImplementation(kotlin("script-runtime"))
Expand Down
8 changes: 8 additions & 0 deletions src/doEcho
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

if [[ "-f" = "$1" ]]; then
cat $2
exit
fi

echo "$1"
8 changes: 8 additions & 0 deletions src/doEcho.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@echo off

IF "-f"=="%1" (
type %2
exit
)

echo %1
Loading
Loading