generates a launch.json file for debugging in VS Code. note: just copy the ones you need into your real launch.json file, as VS Code will crash if there are too many!
()
| 81 | // generates a launch.json file for debugging in VS Code. |
| 82 | // note: just copy the ones you need into your real launch.json file, as VS Code will crash if there are too many! |
| 83 | func (b *bisyncTest) generateDebuggers() { |
| 84 | config, err := parseConfig() |
| 85 | if err != nil { |
| 86 | fs.Errorf(config, "failed to parse config: %v", err) |
| 87 | } |
| 88 | |
| 89 | testList := []string{} |
| 90 | for _, testCase := range b.listDir(b.dataRoot) { |
| 91 | if strings.HasPrefix(testCase, "test_") { |
| 92 | // if dir is empty, skip it (can happen due to gitignored files/dirs when checking out branch) |
| 93 | if len(b.listDir(filepath.Join(b.dataRoot, testCase))) == 0 { |
| 94 | continue |
| 95 | } |
| 96 | testList = append(testList, testCase) |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | variations := []string{"LocalRemote", "RemoteLocal", "RemoteRemote"} |
| 101 | var debuggers strings.Builder |
| 102 | |
| 103 | for _, backend := range config.Backends { |
| 104 | if backend.Remote == "" { |
| 105 | backend.Remote = "local" |
| 106 | } |
| 107 | for _, testcase := range testList { |
| 108 | for _, variation := range variations { |
| 109 | if variation != "RemoteRemote" && backend.Remote == "local" { |
| 110 | continue |
| 111 | } |
| 112 | |
| 113 | name := fmt.Sprintf("Test %s %s %s", backend.Remote, testcase, variation) |
| 114 | switch variation { |
| 115 | case "LocalRemote": |
| 116 | debuggers.WriteString(fmt.Sprintf(debugFormat, name, "local", backend.Remote, testcase)) |
| 117 | case "RemoteLocal": |
| 118 | debuggers.WriteString(fmt.Sprintf(debugFormat, name, backend.Remote, "local", testcase)) |
| 119 | case "RemoteRemote": |
| 120 | debuggers.WriteString(fmt.Sprintf(debugFormat, name, backend.Remote, backend.Remote, testcase)) |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | out := fmt.Sprintf(docFormat, debuggers.String()) |
| 127 | outpath := "./testdata/bisync_vscode_debuggers_launch.json" |
| 128 | err = os.WriteFile(outpath, []byte(out), bilib.PermSecure) |
| 129 | assert.NoError(b.t, err, "writing golden file %s", outpath) |
| 130 | } |
no test coverage detected