/4dbisect

command line tool to test a code with different versions of 4d available in folder by version

Primary LanguageSwift

4dbisect

language check release

Test versions of 4d app to find when a bug occurs.

It use dichotomie, so avoid flaky test.

How to build yourself

Its a swift command line, so if not installed, install Xcode or swift runtime.

Then in project path run

swift build -c release

Result of build will be in .build/release/4dbisect

Put in PATH

You could install it to /usr/local/bin for instance to use it everywhere

sudo cp .build/release/4dbisect /usr/local/bin

or add YOUR_CURRENT_PATH/.build/release/ in your $PATH

How to install the released version

For security reason its better to build yourself but you could download the latest release release

or launch this command

sudo curl -sL https://mesopelagique.github.io/4dbisect/install.sh | bash

This will install 4dbisect to /usr/local/bin

How to use

USAGE: 4dbisect [--min <min>] [--max <max>] [--path <path>] <script>

ARGUMENTS:
  <script>                Path of script to test. 

OPTIONS:
  -m, --min <min>         The minimum version. 
  -M, --max <max>         The maximum version. 
  --path <path>           Path that contains versionned folder 
  -h, --help              Show help information.
4dbisect --min 225555 --max 289999 --path "/Your/Path/To/Build/Main" ./test.sh
parameters: 225555 ➡ 289999
available: 238629 ➡ 261398
test: 238629 ✅
test: 261398 ❌
available no skip: 238629 ➡ 261398
test: 251291 ❌
test: 245065 ❌
test: 241271 ✅
test: 243242 ❌
test: 242181 🌀
test: 242129 ❌
test: 241673 ✅
test: 241902 ✅
test: 241983 ❌
test: 241919 🌀
result: 241902 ➡ 241983
  • ✅ good
  • ❌ bad
  • 🌀 skip

The path must contains no trailing / and inside a folder numeroted by version

The script

The script will receive as arguments the version number and the file path, the one you provide with --path option.

In script you must return 0 if all is ok, and any other code if failed.

Use 125 (like git bisect) to set that the version could not be tested, for instance the 4D zip is not available.

examples

headless test

An example of script could be found in test.sh

If you use it, consider changing the path of your database inside the script (by default it use $HOME/Bisect path).

A demo database could be found in Bisect.zip.

You must launch your test and quit 4d after that, in database method onStart you could could put that code to quit on error

ON ERR CALL("onError") // handle any error ie. ASSERT
test
If (Not(Shift down)) // so you could open your db without the auto quit
  QUIT 4D()
End if

with test your method that could use ASSERT in case of failure.

Then your base must create an error file in Resources folder on error when your test failed.

In onError (see onStart to choose the name)

Folder(fk resources folder).file("error").setText("")

If 4D and QUIT 4D allow to set the process exit code this file creation will not be necessary

UI test

In your form add two buttons

  • OK: in method just QUIT 4D
  • KO: in method Folder(fk resources folder).file("error").setText("") and QUIT 4D

An example of script could be found in examples/testUIWith4DCache.sh, script that could be downloaded into your database path

Tips

If you want to go further with sources and find the exact commit, you must use git bisect but you need to compile 4D at each checkout

More information about bisection


mesopelagique