jeftadlvw / git-nest

Nest external repositories into your project without git being bothered.
https://github.com/jeftadlvw/git-nest
Apache License 2.0
1 stars 1 forks source link

🐛 tests in temporary environment fail, but not on host machine #27

Closed jeftadlvw closed 1 month ago

jeftadlvw commented 1 month ago

When running tests in the temporary environment, some of them fail, wheras they are completely fine on the host machine. There seems to be some inconsitency between the tests. Sometimes they also fail on the host machine. But when rerun everything is fine. Maybe this has to do with that most tests are run in parallel and they modify resources, or that the programs don't wait enough for os-side changes to be persisted.

Commit hash: db39cda908ebed18e45f0ede9c307d613bc010a4

# host
$ go clean -testcache
$ go test ./.../tests
ok      github.com/jeftadlvw/git-nest/actions/tests     4.202s
ok      github.com/jeftadlvw/git-nest/internal/tests    0.949s
ok      github.com/jeftadlvw/git-nest/migrations/context/tests  0.159s
ok      github.com/jeftadlvw/git-nest/migrations/fs/tests       0.225s
ok      github.com/jeftadlvw/git-nest/migrations/git/tests      0.088s
ok      github.com/jeftadlvw/git-nest/migrations/submodules/tests       0.355s
ok      github.com/jeftadlvw/git-nest/models/tests      0.423s
ok      github.com/jeftadlvw/git-nest/models/urls/tests 0.290s
ok      github.com/jeftadlvw/git-nest/utils/tests       3.027s
# test environment
$ watch_and_build /app/src /app/bin
Build command: PWD=/app/test-env && cd /app/src && go test ./.../tests && go build -o /app/bin/git-nest -buildvcs=false && cd /app/test-env
Initial build...
go: downloading github.com/deckarep/golang-set/v2 v2.6.0
go: downloading golang.org/x/term v0.20.0
go: downloading github.com/BurntSushi/toml v1.3.2
go: downloading golang.org/x/sys v0.20.0
git-nest root and git repository root directories do not match:  != /tmp/2681657371
git-nest root and git repository root directories do not match:  != /tmp/2212923822
git-nest root and git repository root directories do not match:  != /tmp/3111472254
git-nest root and git repository root directories do not match:  != /tmp/3370521334
git-nest root and git repository root directories do not match:  != /tmp/2560634869
git-nest root and git repository root directories do not match:  != /tmp/4268956939
git-nest root and git repository root directories do not match:  != /tmp/567044065
git-nest root and git repository root directories do not match:  != /tmp/3369110544
git-nest root and git repository root directories do not match:  != /tmp/1848112080
git-nest root and git repository root directories do not match:  != /tmp/1070361638
git-nest root and git repository root directories do not match:  != /tmp/107041280
git-nest root and git repository root directories do not match:  != /tmp/140319859
git-nest root and git repository root directories do not match:  != /tmp/3508208617
git-nest root and git repository root directories do not match:  != /tmp/3659411492
git-nest root and git repository root directories do not match:  != /tmp/3614487022
git-nest root and git repository root directories do not match:  != /tmp/3839513750
--- FAIL: TestRemoveSubmoduleFromContext (0.00s)
    --- FAIL: TestRemoveSubmoduleFromContext/TestAddSubmoduleInContext-9 (0.60s)
        remove_test.go:158: no error, but expected one
--- FAIL: TestSynchronizeSubmodule (0.00s)
    --- FAIL: TestSynchronizeSubmodule/TestSynchronizeSubmodule-10 (0.49s)
        sync_test.go:143: unexpected error: internal error: could not parse url : scheme is not http-based
    --- FAIL: TestSynchronizeSubmodule/TestSynchronizeSubmodule-11 (0.50s)
        sync_test.go:152: unequal amounts of migrations: expected 1, got 0 ( )
    --- FAIL: TestSynchronizeSubmodule/TestSynchronizeSubmodule-5 (0.50s)
        sync_test.go:143: unexpected error: internal error: could not parse url : scheme is not http-based
    --- FAIL: TestSynchronizeSubmodule/TestSynchronizeSubmodule-9 (0.51s)
        sync_test.go:152: unequal amounts of migrations: expected 1, got 2 ( submodules.UpdateUrl {Submodule github.com:443
jeftadlvw/example-repository@main>nested_module-1 {example.com 80 /foo false}} submodules.UpdateRef {Submodule
github.com:443/jeftadlvw/example-repository@main>nested_module-1 0ab2d7ab4e49272a3f8955fbc79d34895d49bb31} )
FAIL
FAIL    github.com/jeftadlvw/git-nest/actions/tests     3.241s
ok      github.com/jeftadlvw/git-nest/internal/tests    0.669s
ok      github.com/jeftadlvw/git-nest/migrations/context/tests  0.003s
ok      github.com/jeftadlvw/git-nest/migrations/fs/tests       0.004s
ok      github.com/jeftadlvw/git-nest/migrations/git/tests      0.004s
ok      github.com/jeftadlvw/git-nest/migrations/submodules/tests       0.002s
ok      github.com/jeftadlvw/git-nest/models/tests      0.004s
ok      github.com/jeftadlvw/git-nest/models/urls/tests 0.004s
--- FAIL: TestGetGitFetchHead (0.00s)
    --- FAIL: TestGetGitFetchHead/GetGitFetchHead-4 (0.50s)
        git_test.go:288: unexpected ref: ><, expected >0ab2d7ab4e49272a3f8955fbc79d34895d49bb31<,
    --- FAIL: TestGetGitFetchHead/GetGitFetchHead-5 (0.51s)
        git_test.go:291: unexpected abbreviation: ><, expected >foo<,
--- FAIL: TestGetGitHasUnpublishedChanges (0.00s)
    --- FAIL: TestGetGitHasUnpublishedChanges/GetGitHasUnpublishedChanges-6 (0.51s)
        git_test.go:429: returned false, but should be true
--- FAIL: TestGetGitRemoteUrl (0.00s)
    --- FAIL: TestGetGitRemoteUrl/TestGetGitRemoteUrl-5 (0.54s)
        git_test.go:234: unexpected remote: ><, expected >https://github.com/jeftadlvw/example-repository<,
FAIL
FAIL    github.com/jeftadlvw/git-nest/utils/tests       2.064s
FAIL
Setting up watches.  Beware: since -r was given, this may take a while!
Watches established.
jeftadlvw commented 1 month ago

A workaround would be to don't run the tests. Run the test environment container with one additional environment variable: -e DISABLE_TESTS=true

jeftadlvw commented 1 month ago

It seems that this issue only appears on MacOS arm docker containers. They run on my pc (amd64), in a docker container on my pc (golang:1.22.4-bookworm) and pi (armv6).

jeftadlvw commented 1 month ago

After further investigation, i have reasons to think the custom exec.Command wrapper causes these issues. Information gets lost somewhere around scanning and passing the data to parallel handler functions.

jeftadlvw commented 1 month ago

This problem should be solved. All tests succeed on various platforms. Still weird that the issue occured within a docker container on ARM, but maybe other things like system resources played a role