Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More updater tests #134

Merged
merged 5 commits into from
Jun 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 59 additions & 35 deletions corral/cmd/_test_cmd_update.pony
Original file line number Diff line number Diff line change
@@ -10,73 +10,97 @@ actor _TestCmdUpdate is TestList

fun tag tests(test: PonyTest) =>
test(_TestEmptyDeps)
test(_TestMutuallyRecursive)
test(_TestRegression120)

test(_TestSelfReferential)
SeanTAllen marked this conversation as resolved.
Show resolved Hide resolved

class iso _TestEmptyDeps is UnitTest
"""
Verify that when using an corral.json for with empty deps, that there
are never any sync, tag query, or checkout operations executed.
"""

fun name(): String =>
"cmd/update/" + __loc.type_name()

fun apply(h: TestHelper) ? =>
"""
Verify that when using an corral.json for with empty deps, that there
are never any sync, tag query, or checkout operations executed.
"""
let auth = h.env.root as AmbientAuth
let log = Log(LvlNone, h.env.err, SimpleLogFormatter)
let fp: FilePath = _TestData.file_path_from(h, "empty-deps")?
let repo_cache = _TestRepoCache(auth)?
let ctx = Context(h.env, log, log, false, repo_cache)
let project = Project(auth, log, fp)
let bundle = Bundle.load(fp, log)?
let recorder = _OpsRecorder(h, 0, 0, 0)
let vcs_builder: VCSBuilder = _TestCmdUpdateVCSBuilder(recorder)
_OpsRecorderTestRunner(
h,
"empty-deps",
_OpsRecorder(h, 0, 0, 0))?

let updater = _Updater(ctx, project, consume bundle, vcs_builder, recorder)
class iso _TestMutuallyRecursive is UnitTest
"""
Verify that when using mutually recursive corral.json files that we
execute the correct number of operations
"""

// when updater is finished, it will send a `cmd_completed` message to
// _OpsRecorder which will trigger pass/fail
h.long_test(2_000_000_000)
fun name(): String =>
"cmd/update/" + __loc.type_name()

fun apply(h: TestHelper) ? =>
_OpsRecorderTestRunner(
h,
"mutually-recursive/foo",
_OpsRecorder(h, 2, 2, 2))?

class iso _TestRegression120 is UnitTest
"""
Issue #120 identified a problem with transitive dependencies that resulted
in too many operations being performaned across the loading of all
dependencies.
The test as currently constituted, consists of a bundles with 2
dependencies. One of those has 2 more in a transitive fashion, that should
result in 4 syncs and corresponding actions happening. However, due to a
bug in _Updater, it currently does 11.
With a real VCS like Git, the number that results from it is variable
based on timing. This test exists to prove that issue #120 is fixed and
to prevent a similar bug from being introduced in the future.
"""
fun name(): String =>
"cmd/update/" + __loc.type_name()

fun apply(h: TestHelper) ? =>
_OpsRecorderTestRunner(
h,
"regression-120/bundle-entrypoint",
_OpsRecorder(h, 4, 4, 4))?

class iso _TestSelfReferential is UnitTest
"""
Verify that a self reference in a corral.json results in only 1 operation
"""
fun name(): String =>
"cmd/update/" + __loc.type_name()

fun apply(h: TestHelper) ? =>
_OpsRecorderTestRunner(
h,
"self-referential",
_OpsRecorder(h, 1, 1, 1))?

primitive _OpsRecorderTestRunner
fun apply(h: TestHelper, dep_path: String val, recorder: _OpsRecorder) ? =>
"""
Issue #120 identified a problem with transitive dependencies that resulted
in too many operations being performaned across the loading of all
dependencies.
The test as currently constituted, consists of a bundles with 2
dependencies. One of those has 2 more in a transitive fashion, that should
result in 4 syncs and corresponding actions happening. However, due to a
bug in _Updater, it currently does 11.
With a real VCS like Git, the number that results from it is variable
based on timing. This test exists to prove that issue #120 is fixed and
to prevent a similar bug from being introduced in the future.
Runs an _OpsRecorder test.
"""
// given
let auth = h.env.root as AmbientAuth
let log = Log(LvlNone, h.env.err, SimpleLogFormatter)
let fp: FilePath = _TestData.file_path_from(h, "regression-120/bundle-entrypoint")?
let fp: FilePath = _TestData.file_path_from(h, dep_path)?
let repo_cache = _TestRepoCache(auth)?
let ctx = Context(h.env, log, log, false, repo_cache)
let project = Project(auth, log, fp)
let bundle = Bundle.load(fp, log)?
let recorder = _OpsRecorder(h, 4, 4, 4)
let vcs_builder: VCSBuilder = _TestCmdUpdateVCSBuilder(recorder)

// when
let updater = _Updater(ctx, project, consume bundle, vcs_builder, recorder)

// when updater is finished, it will send a `cmd_completed` message to
// _OpsRecorder which will trigger pass/fail
h.long_test(2_000_000_000)


actor _OpsRecorder is CmdResultReceiver
let _h: TestHelper

1 change: 1 addition & 0 deletions corral/test/testdata/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lock.json