Skip to content

Commit fb1fd61

Browse files
committed
Add support for using an ARCONFIG environment variable to specify the location of the config.yml file for running the tests
1 parent df63c99 commit fb1fd61

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

activerecord/RUNNING_UNIT_TESTS

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,31 @@ You can build postgres and mysql databases using the build_postgresql and build_
99

1010
You can run a particular test file from the command line, e.g.
1111

12-
$ ruby test/cases/base_test.rb
12+
$ ruby -Itest test/cases/base_test.rb
1313

1414
To run a specific test:
1515

16-
$ ruby test/cases/base_test.rb -n test_something_works
16+
$ ruby -Itest test/cases/base_test.rb -n test_something_works
1717

1818
You can run with a database other than the default you set in test/config.yml, using the ARCONN
1919
environment variable:
2020

21-
$ ARCONN=postgresql ruby test/cases/base_test.rb
21+
$ ARCONN=postgresql ruby -Itest test/cases/base_test.rb
2222

2323
You can run all the tests for a given database via rake:
2424

25-
$ rake test_postgresql
25+
$ rake test_mysql
26+
27+
The 'rake test' task will run all the tests for mysql, mysql2, sqlite3 and postgresql.
28+
29+
== Identity Map
30+
31+
By default the tests run with the Identity Map turned off. But all tests should pass whether or
32+
not the identity map is on or off. You can turn it on using the IM env variable:
33+
34+
$ IM=true ruby -Itest test/case/base_test.rb
35+
36+
== Config file
37+
38+
By default, the config file is expected to be at the path test/config.yml. You can specify a
39+
custom location with the ARCONFIG environment variable.

activerecord/test/support/config.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ def config
1010

1111
private
1212

13+
def config_file
14+
Pathname.new(ENV['ARCONFIG'] || TEST_ROOT + '/config.yml')
15+
end
16+
1317
def read_config
14-
unless File.exist?(TEST_ROOT + '/config.yml')
15-
FileUtils.cp TEST_ROOT + '/config.example.yml', TEST_ROOT + '/config.yml'
18+
unless config_file.exist?
19+
FileUtils.cp TEST_ROOT + '/config.example.yml', config_file
1620
end
1721

18-
raw = File.read(TEST_ROOT + '/config.yml')
19-
erb = Erubis::Eruby.new(raw)
22+
erb = Erubis::Eruby.new(config_file.read)
2023
expand_config(YAML.parse(erb.result(binding)).transform)
2124
end
2225

0 commit comments

Comments
 (0)