Merge pull request #1663 from dubo-dubon-duponey/fix1

Fix flaky tests in outputs
This commit is contained in:
Andrea Luzzardi 2022-02-28 12:31:05 -08:00 committed by GitHub
commit 3e9fd390c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 65 additions and 23 deletions

View File

@ -8,6 +8,7 @@ on:
- '**.bash'
- '**.go'
- '**.cue'
- '**.bats'
- 'Makefile'
- 'go.mod'
- 'go.sum'
@ -19,6 +20,7 @@ on:
- '**.bash'
- '**.go'
- '**.cue'
- '**.bats'
- 'Makefile'
- 'go.mod'
- 'go.sum'

View File

@ -8,6 +8,7 @@ on:
- '**.bash'
- '**.go'
- '**.cue'
- '**.bats'
- 'Makefile'
- 'go.mod'
- 'go.sum'
@ -19,6 +20,7 @@ on:
- '**.bash'
- '**.go'
- '**.cue'
- '**.bats'
- 'Makefile'
- 'go.mod'
- 'go.sum'

View File

@ -94,19 +94,21 @@ setup() {
}
@test "plan/outputs/directories" {
cd "$TESTDIR"/plan/outputs/directories
cd "$TESTDIR"/plan/outputs/directories
rm -f "./out/test"
"$DAGGER" up ./outputs.cue
assert [ -f "./out/test" ]
"$DAGGER" up ./outputs.cue
assert [ -f "./out/test_outputs" ]
rm -f "./out/test_outputs"
}
@test "plan/outputs/directories relative paths" {
cd "$TESTDIR"/plan
cd "$TESTDIR"/plan
rm -f "./outputs/directories/out/test"
"$DAGGER" up ./outputs/directories/outputs.cue
assert [ -f "./outputs/directories/out/test" ]
"$DAGGER" up ./outputs/directories/relative.cue
assert [ -f "./outputs/directories/out/test_relative" ]
rm -f "./outputs/directories/out/test_relative"
}
@test "plan/outputs/files normal usage" {
@ -114,22 +116,22 @@ setup() {
"$DAGGER" up ./usage.cue
run ./test.sh
run ./test_usage
assert_output "Hello World!"
run ls -l "./test.sh"
run ls -l "./test_usage"
assert_output --partial "-rwxr-x---"
rm -f "./test.sh"
rm -f "./test_usage"
}
@test "plan/outputs/files relative path" {
cd "$TESTDIR"/plan
cd "$TESTDIR"/plan
"$DAGGER" up ./outputs/files/usage.cue
assert [ -f "./outputs/files/test.sh" ]
"$DAGGER" up ./outputs/files/relative.cue
assert [ -f "./outputs/files/test_relative" ]
rm -f "./outputs/files/test.sh"
rm -f "./outputs/files/test_relative"
}
@test "plan/outputs/files default permissions" {
@ -137,10 +139,10 @@ setup() {
"$DAGGER" up ./default_permissions.cue
run ls -l "./test"
run ls -l "./test_default_permissions"
assert_output --partial "-rw-r--r--"
rm -f "./test"
rm -f "./test_default_permissions"
}
@test "plan/outputs/files no contents" {
@ -150,7 +152,9 @@ setup() {
assert_failure
assert_output --partial "contents is not set"
assert [ ! -f "./test" ]
assert [ ! -f "./test_no_contents" ]
rm -f "./test_no_contents"
}
@test "plan/platform" {

View File

@ -7,12 +7,12 @@ import (
dagger.#Plan & {
actions: data: dagger.#WriteFile & {
input: dagger.#Scratch
path: "/test"
path: "/test_outputs"
permissions: 0o600
contents: "foobar"
}
outputs: directories: test: {
outputs: directories: test_outputs: {
contents: actions.data.output
dest: "./out"
}

View File

@ -0,0 +1,19 @@
package main
import (
"dagger.io/dagger"
)
dagger.#Plan & {
actions: data: dagger.#WriteFile & {
input: dagger.#Scratch
path: "/test_relative"
permissions: 0o600
contents: "foobar"
}
outputs: directories: test_relative: {
contents: actions.data.output
dest: "./out"
}
}

View File

@ -5,6 +5,6 @@ import "dagger.io/dagger"
dagger.#Plan & {
outputs: files: test: {
contents: "foobar"
dest: "./test"
dest: "./test_default_permissions"
}
}

View File

@ -3,5 +3,5 @@ package main
import "dagger.io/dagger"
dagger.#Plan & {
outputs: files: test: dest: "./test"
outputs: files: test: dest: "./test_no_contents"
}

View File

@ -0,0 +1,15 @@
package main
import "dagger.io/dagger"
dagger.#Plan & {
outputs: files: {
[path=string]: dest: path
test_relative: contents: """
#!/bin/bash
set -euo pipefail
echo "Hello World!"
"""
}
}

View File

@ -5,7 +5,7 @@ import "dagger.io/dagger"
dagger.#Plan & {
outputs: files: {
[path=string]: dest: path
"test.sh": {
test_usage: {
contents: """
#!/bin/bash
set -euo pipefail