From f5b5ac47b0a7364c4238dbaad03b6c1972cd8da4 Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Mon, 29 Mar 2021 19:03:53 +0200 Subject: [PATCH] refactor: merge libminiooni into cmd/miniooni (#268) We used to have an external package called libminiooni so that third parties could use it. We wrote this such that we could support github.com/bassosimone/aladdin. That was actually a not-so-good idea because it added to the APIs we needed to maintain. Since the merge of engine into cli, such an API is not public anymore and aladdin has been deprecated and archived. Therefore, we can now cleanup the situation and merge libminiooni into miniooni again, thus making the codebase more local. This cleanup has been identified while working on https://github.com/ooni/probe/issues/1299. --- .../{libminiooni => cmd/miniooni}/.gitignore | 0 internal/cmd/miniooni/README.md | 7 ++++--- .../miniooni}/libminiooni.go | 19 +------------------ internal/cmd/miniooni/libminiooni_test.go | 12 ++++++++++++ internal/cmd/miniooni/main.go | 6 +----- internal/libminiooni/README.md | 13 ------------- .../libminiooni_integration_test.go | 16 ---------------- 7 files changed, 18 insertions(+), 55 deletions(-) rename internal/{libminiooni => cmd/miniooni}/.gitignore (100%) rename internal/{libminiooni => cmd/miniooni}/libminiooni.go (93%) create mode 100644 internal/cmd/miniooni/libminiooni_test.go delete mode 100644 internal/libminiooni/README.md delete mode 100644 internal/libminiooni/libminiooni_integration_test.go diff --git a/internal/libminiooni/.gitignore b/internal/cmd/miniooni/.gitignore similarity index 100% rename from internal/libminiooni/.gitignore rename to internal/cmd/miniooni/.gitignore diff --git a/internal/cmd/miniooni/README.md b/internal/cmd/miniooni/README.md index ae2b3fd..c4ab7b6 100644 --- a/internal/cmd/miniooni/README.md +++ b/internal/cmd/miniooni/README.md @@ -3,6 +3,7 @@ This directory contains the source code of a simple CLI client that we use for research as well as for running QA scripts. We designed this tool to have a CLI similar to MK and OONI Probe v2.x to ease running Jafar -scripts that check whether these tools behave similarly. - -See also libminiooni. +scripts that check whether these tools behave similarly. Perfect backwards +compatibility was not a design goal for miniooni. Rather, we aimed to +have as little conflict as possible, such that we can run side-by-side +QA checks. diff --git a/internal/libminiooni/libminiooni.go b/internal/cmd/miniooni/libminiooni.go similarity index 93% rename from internal/libminiooni/libminiooni.go rename to internal/cmd/miniooni/libminiooni.go index d0daa6e..51fc51c 100644 --- a/internal/libminiooni/libminiooni.go +++ b/internal/cmd/miniooni/libminiooni.go @@ -1,21 +1,4 @@ -// Package libminiooni implements the cmd/miniooni CLI. Miniooni is our -// experimental client used for research and QA testing. -// -// This CLI has CLI options that do not conflict with Measurement Kit -// v0.10.x CLI options. There are some options conflict with the legacy -// OONI Probe CLI options. Perfect backwards compatibility is not a -// design goal for miniooni. Rather, we aim to have as little conflict -// as possible such that we can run side by side QA checks. -// -// We extracted this package from cmd/miniooni to allow us to further -// integrate the miniooni CLI into other binaries (see for example the -// code at github.com/bassosimone/aladdin). -package libminiooni - -// TODO(bassosimone): now that this code cannot be imported from -// external sources anymore, we should move it back into the -// internal/cmd/miniooni folder and reduce the number of packages -// that are unnecessarily exposed inside ./internal/engine. +package main // TODO(bassosimone): we need to deprecate or remove --limit. diff --git a/internal/cmd/miniooni/libminiooni_test.go b/internal/cmd/miniooni/libminiooni_test.go new file mode 100644 index 0000000..01ec1a5 --- /dev/null +++ b/internal/cmd/miniooni/libminiooni_test.go @@ -0,0 +1,12 @@ +package main + +import "testing" + +func TestSimple(t *testing.T) { + if testing.Short() { + t.Skip("skip test in short mode") + } + MainWithConfiguration("example", Options{ + Yes: true, + }) +} diff --git a/internal/cmd/miniooni/main.go b/internal/cmd/miniooni/main.go index 79546db..e46620f 100644 --- a/internal/cmd/miniooni/main.go +++ b/internal/cmd/miniooni/main.go @@ -1,14 +1,10 @@ // Command miniooni is a simple binary for research and QA purposes // with a CLI interface similar to MK and OONI Probe v2.x. -// -// See also libminiooni, which is where we implement this CLI. package main import ( "fmt" "os" - - "github.com/ooni/probe-cli/v3/internal/libminiooni" ) func main() { @@ -17,5 +13,5 @@ func main() { fmt.Fprintf(os.Stderr, "%s", s) } }() - libminiooni.Main() + Main() } diff --git a/internal/libminiooni/README.md b/internal/libminiooni/README.md deleted file mode 100644 index 693b629..0000000 --- a/internal/libminiooni/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Package github.com/ooni/probe-cli/internal/libminiooni - -Package libminiooni implements the cmd/miniooni CLI. Miniooni is our -experimental client used for research and QA testing. - -This CLI has CLI options that do not conflict with Measurement Kit -v0.10.x CLI options. There are some options conflict with the legacy -OONI Probe CLI options. Perfect backwards compatibility is not a -design goal for miniooni. Rather, we aim to have as little conflict -as possible such that we can run side by side QA checks. - -This package was split off from cmd/miniooni in ooni/probe-engine. For -now we are keeping this split, but we will merge them in the future. diff --git a/internal/libminiooni/libminiooni_integration_test.go b/internal/libminiooni/libminiooni_integration_test.go deleted file mode 100644 index 66870ca..0000000 --- a/internal/libminiooni/libminiooni_integration_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package libminiooni_test - -import ( - "testing" - - "github.com/ooni/probe-cli/v3/internal/libminiooni" -) - -func TestSimple(t *testing.T) { - if testing.Short() { - t.Skip("skip test in short mode") - } - libminiooni.MainWithConfiguration("example", libminiooni.Options{ - Yes: true, - }) -}