-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add testsuite and some mod tests, repro for v0.0.0 bug, caught / fixe…
…d to others
- Loading branch information
Showing
17 changed files
with
247 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,9 @@ | |
/vendor/ | ||
/**/vendor/ | ||
|
||
# Testscript workdirs | ||
/**/.workdir/ | ||
|
||
# Hof related | ||
/hof-cpu.prof | ||
/hof |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package mod_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/rogpeppe/go-internal/testscript" | ||
|
||
"github.com/hofstadter-io/hof/lib/yagu" | ||
) | ||
|
||
func TestMod(t *testing.T) { | ||
|
||
yagu.Mkdir(".workdir/tests") | ||
|
||
testscript.Run(t, testscript.Params{ | ||
Dir: "testdata", | ||
WorkdirRoot: ".workdir/tests", | ||
}) | ||
} | ||
|
||
func TestModBugs(t *testing.T) { | ||
|
||
yagu.Mkdir(".workdir/bugs") | ||
|
||
testscript.Run(t, testscript.Params{ | ||
Dir: "testdata/bugs", | ||
WorkdirRoot: ".workdir/bugs", | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ cue: { | |
InitTemplates: {...} | *{ | ||
"cue.mod/module.cue": """ | ||
module: "{{ .Module }}" | ||
""" | ||
... | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# hof mod init cue blah // this should fail because the module format is incorrect | ||
! exec hof mod init cue blah | ||
stdout '.+' | ||
stderr '.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# hof mod vendor - BUG require v0.0.0 | ||
exec hof mod vendor | ||
|
||
-- cue.mods -- | ||
module github.com/test/mod | ||
|
||
cue v0.2.0 | ||
|
||
require ( | ||
github.com/hofstadter-io/hof v0.0.0 | ||
) | ||
-- cue.mod/module.cue -- | ||
module: "github.com/test/mod" | ||
-- dummy_end -- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# hof mod init - no args | ||
! exec hof mod init | ||
stdout 'missing required argument: ''lang''' | ||
stderr 'hof mod init <lang> <module> \[flags\]' | ||
|
||
|
||
# hof mod init - missing module | ||
! exec hof mod init cue | ||
stdout 'missing required argument: ''module''' | ||
stderr 'hof mod init <lang> <module> \[flags\]' | ||
|
||
|
||
# hof mod init - unknown lang, missing module | ||
! exec hof mod init blah | ||
stdout 'missing required argument: ''module''' | ||
stderr 'hof mod init <lang> <module> \[flags\]' | ||
|
||
|
||
# hof mod init - unknown lang, badfmt module | ||
! exec hof mod init blah blah | ||
stdout 'Unknown language "blah".' | ||
! stderr '.' | ||
|
||
|
||
# hof mod init - unknown lang, goodfmt module | ||
! exec hof mod init blah github.com/test/unknownlang | ||
stdout 'Unknown language "blah".' | ||
! stderr '.' | ||
|
||
|
||
# hof mod init - backwards args | ||
! exec hof mod init github.com/test/backwards cue | ||
stdout 'Unknown language "github.com/test/backwards".' | ||
! stderr . | ||
|
||
|
||
|
||
|
||
# hof mod init - ensure none of these created any files | ||
|
||
! exists cue.mods | ||
! exists cue.sums | ||
! exists cue.mod/ | ||
! exists cue.mod/module.cue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# hof mod init - already exists | ||
! exec hof mod init cue github.com/test/overmod | ||
stdout '^cue.mods already exists\n$' | ||
! stderr . | ||
|
||
-- cue.mods -- | ||
module github.com/test/existsmod | ||
|
||
cue v0.2.0 | ||
-- dummy-end -- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# hof mod init cue github.com/test/mod | ||
exec hof mod init cue github.com/test/mod | ||
! stdout . | ||
|
||
exists cue.mods | ||
exists cue.mod/module.cue | ||
|
||
cmp cue.mods match/cue.mods | ||
cmp cue.mod/module.cue match/cue.mod/module.cue | ||
|
||
-- match/cue.mods -- | ||
module github.com/test/mod | ||
|
||
cue v0.2.0 | ||
-- match/cue.mod/module.cue -- | ||
module: "github.com/test/mod" | ||
-- dummy_end -- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# cli test powered by testscript | ||
|
||
This directory contains a number of `txtar` files | ||
which are loaded by the `testscript` library. | ||
These are internal Go libraries from the compiler | ||
extracted into a reusable module. | ||
|
||
- https://github.com/rogpeppe/go-internal | ||
- https://pkg.go.dev/github.com/rogpeppe/go-internal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# hof mod vendor - local replace no require | ||
exec hof mod vendor | ||
|
||
|
||
|
||
-- cue.mods -- | ||
module github.com/test/mod | ||
|
||
cue v0.2.0 | ||
|
||
replace github.com/hofstadter-io/hof => ./simhof | ||
|
||
-- cue.mod/module.cue -- | ||
module: "github.com/test/mod" | ||
-- dummy_end -- | ||
|
||
|
||
-- simhof/cue.mods -- | ||
module github.com/hofstadter-io/hof | ||
|
||
cue v0.2.0 | ||
|
||
-- simhof/cue.mod/module.cue -- | ||
module: "github.com/hofstadter-io/hof" | ||
|
||
|
||
-- dummy_end -- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# hof mod vendor - local replace | ||
exec hof mod vendor | ||
|
||
|
||
|
||
-- cue.mods -- | ||
module github.com/test/mod | ||
|
||
cue v0.2.0 | ||
|
||
require ( | ||
github.com/hofstadter-io/hof v0.0.0 | ||
) | ||
|
||
replace github.com/hofstadter-io/hof => ./simhof | ||
|
||
-- cue.mod/module.cue -- | ||
module: "github.com/test/mod" | ||
-- dummy_end -- | ||
|
||
|
||
-- simhof/cue.mods -- | ||
module github.com/hofstadter-io/hof | ||
|
||
cue v0.2.0 | ||
|
||
-- simhof/cue.mod/module.cue -- | ||
module: "github.com/hofstadter-io/hof" | ||
|
||
|
||
-- dummy_end -- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# hof mod vendor - double require | ||
! exec hof mod vendor cue | ||
stdout 'Dependency "github.com/hofstadter-io/hof" required twice in ""' | ||
! stderr . | ||
|
||
-- cue.mods -- | ||
module github.com/test/2x-req | ||
|
||
require ( | ||
github.com/hofstadter-io/hof v0.0.0 | ||
github.com/hofstadter-io/hof v0.5.4 | ||
) | ||
|
||
cue v0.2.0 | ||
-- dummy-end -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# hof mod vendor - new module | ||
exec hof mod init cue github.com/test/mod | ||
! stdout . | ||
|
||
exec hof mod vendor | ||
exec hof mod vendor cue | ||
|
||
exists cue.mods | ||
cmp cue.mods match/cue.mods | ||
|
||
exists cue.sums | ||
cmp cue.sums match/cue.sums | ||
|
||
exists cue.mod/module.cue | ||
cmp cue.mod/module.cue match/cue.mod/module.cue | ||
|
||
-- match/cue.mods -- | ||
module github.com/test/mod | ||
|
||
cue v0.2.0 | ||
-- match/cue.sums -- | ||
-- match/cue.mod/module.cue -- | ||
module: "github.com/test/mod" | ||
-- dummy_end -- | ||
|
||
|