Wiki

Ticket #215 (closed defect: fixed)

Opened 14 years ago

Last modified 12 years ago

-test option doesn't handle @args -target:lib

Reported by: Chuck Owned by: Chuck
Priority: major Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: test, target Cc:

Description

"""
Given the "@args -target:lib" below, the command
"cobra foo.cobra" works as expected.

However, "cobra -test foo.cobra" gives an error:

error: Cannot specify -main if building a module or library

So there is a deficiency in the implementation of -test.
"""

@args -target:lib

class A

	test
		a = A()
		assert a.two == 2
	
	get two as int
		return 2

Attachments

lib-tests.patch Download (3.6 KB) - added by hopscc 12 years ago.

Change History

Changed 12 years ago by hopscc

This and the change a while back (changeset:2847) to suppress running by default
any tests in libraries
make it now impossible to run tests in libraries (explicitly).

Trap this combination ( -test and target:lib) in SharpGenerator? and emit a diagnostic describing the problem and how to test libraries.
Modify the default test runner and test-runner invocation to allow tests to run both in app and app+libraries.

Changed 12 years ago by hopscc

Changed 12 years ago by hopscc

  • status changed from new to assigned
  • owner set to Chuck

Internal test-runner invocation to run app tests changed to

-test-runner:Cobra.Core.CobraCore.runAppTests

The options setup to run all tests (app assembly and libs) is now very baroque

# compile lib
> cobra  -target:lib testLib.cobra

# run tests in app using lib - tests in app only (implicit default)
> cobra  -test -ref:testLib testLibRun.cobra

# same as above explicitly specified run tests in app assembly only
> cobra  -test -test-runner:Cobra.Core.CobraCore.runAppTests -ref:testLib testLibRun.cobra

# run all tests - app and libs
> cobra  -test -test-runner:Cobra.Core.CobraCore.runAllTests -ref:testLib testLibRun.cobra

May be advisable to add another highlevel test option
"-testAll - run all tests, app assembly and libraries"
alongside existing
-test - run tests in app assembly

Changed 12 years ago by Charles

Your last two commands in your previous comment are the same. Did you mean the last to be -testAll?

Also, we've been using a style of "-foo-bar" in the options, not "-fooBar".

Changed 12 years ago by Charles

Woops. I see now the diff is .runAppTests vs. runAllTests

Changed 12 years ago by hopscc

yeah, sure - possible alternate -test option '-test-all' (run all tests in app and all libraries used)

Changed 12 years ago by Charles

Patch applied in changeset:2970 sans new error message that -test and -target:lib don't work together. Will try to fix first.

Changed 12 years ago by Charles

  • status changed from assigned to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.