aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/work_edit.txt
diff options
context:
space:
mode:
authorMichael Matloob <matloob@golang.org>2021-06-16 18:46:23 -0400
committerMichael Matloob <matloob@golang.org>2021-07-31 00:25:16 +0000
commit3799012990a324db968b8f377a5faf541cf20ac7 (patch)
treeeb59eaeb694e34e604783b257dcaa98c8e35e1ae /src/cmd/go/testdata/script/work_edit.txt
parentb3b53e1dad8681e3c21522513e4539813a5a3de7 (diff)
downloadgo-3799012990a324db968b8f377a5faf541cf20ac7.tar.gz
go-3799012990a324db968b8f377a5faf541cf20ac7.zip
[dev.cmdgo] cmd/go: add go mod editwork command
go mod editwork behaves similarly to go mod edit: it has flags to change the go version, and add and remove directory and replace directives. For #45713 Change-Id: I1c795c122bfe461d6e87dd731692e0bf1bbe2bf7 Reviewed-on: https://go-review.googlesource.com/c/go/+/334938 Trust: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/testdata/script/work_edit.txt')
-rw-r--r--src/cmd/go/testdata/script/work_edit.txt157
1 files changed, 157 insertions, 0 deletions
diff --git a/src/cmd/go/testdata/script/work_edit.txt b/src/cmd/go/testdata/script/work_edit.txt
new file mode 100644
index 0000000000..0717086ee7
--- /dev/null
+++ b/src/cmd/go/testdata/script/work_edit.txt
@@ -0,0 +1,157 @@
+# Test editing go.work files.
+
+go mod initwork m
+cmp go.work go.work.want_initial
+
+go mod editwork -directory n
+cmp go.work go.work.want_directory_n
+
+go mod editwork -go 1.18
+cmp go.work go.work.want_go_118
+
+go mod editwork -dropdirectory m
+cmp go.work go.work.want_dropdirectory_m
+
+go mod editwork -replace=x.1@v1.3.0=y.1@v1.4.0 -replace='x.1@v1.4.0 = ../z'
+cmp go.work go.work.want_add_replaces
+
+go mod editwork -directory n -directory ../a -directory /b -directory c -directory c
+cmp go.work go.work.want_multidirectory
+
+go mod editwork -dropdirectory /b -dropdirectory n
+cmp go.work go.work.want_multidropdirectory
+
+go mod editwork -dropreplace='x.1@v1.4.0'
+cmp go.work go.work.want_dropreplace
+
+go mod editwork -print -go 1.19 -directory b -dropdirectory c -replace 'x.1@v1.4.0 = ../z' -dropreplace x.1 -dropreplace x.1@v1.3.0
+cmp stdout go.work.want_print
+
+go mod editwork -json -go 1.19 -directory b -dropdirectory c -replace 'x.1@v1.4.0 = ../z' -dropreplace x.1 -dropreplace x.1@v1.3.0
+cmp stdout go.work.want_json
+
+go mod editwork -print -fmt -workfile unformatted
+cmp stdout formatted
+
+-- go.work.want_initial --
+go 1.17
+
+directory m
+-- go.work.want_directory_n --
+go 1.17
+
+directory (
+ m
+ n
+)
+-- go.work.want_go_118 --
+go 1.18
+
+directory (
+ m
+ n
+)
+-- go.work.want_dropdirectory_m --
+go 1.18
+
+directory n
+-- go.work.want_add_replaces --
+go 1.18
+
+directory n
+
+replace (
+ x.1 v1.3.0 => y.1 v1.4.0
+ x.1 v1.4.0 => ../z
+)
+-- go.work.want_multidirectory --
+go 1.18
+
+directory (
+ ../a
+ /b
+ c
+ n
+)
+
+replace (
+ x.1 v1.3.0 => y.1 v1.4.0
+ x.1 v1.4.0 => ../z
+)
+-- go.work.want_multidropdirectory --
+go 1.18
+
+directory (
+ ../a
+ c
+)
+
+replace (
+ x.1 v1.3.0 => y.1 v1.4.0
+ x.1 v1.4.0 => ../z
+)
+-- go.work.want_dropreplace --
+go 1.18
+
+directory (
+ ../a
+ c
+)
+
+replace x.1 v1.3.0 => y.1 v1.4.0
+-- go.work.want_print --
+go 1.19
+
+directory (
+ ../a
+ b
+)
+
+replace x.1 v1.4.0 => ../z
+-- go.work.want_json --
+{
+ "Go": "1.19",
+ "Directory": [
+ {
+ "DiskPath": "../a"
+ },
+ {
+ "DiskPath": "b"
+ }
+ ],
+ "Replace": [
+ {
+ "Old": {
+ "Path": "x.1",
+ "Version": "v1.4.0"
+ },
+ "New": {
+ "Path": "../z"
+ }
+ }
+ ]
+}
+-- unformatted --
+go 1.17
+ directory (
+ a
+ b
+ c
+ )
+ replace (
+ x.1 v1.3.0 => y.1 v1.4.0
+ x.1 v1.4.0 => ../z
+ )
+-- formatted --
+go 1.17
+
+directory (
+ a
+ b
+ c
+)
+
+replace (
+ x.1 v1.3.0 => y.1 v1.4.0
+ x.1 v1.4.0 => ../z
+) \ No newline at end of file