|
3 | 3 | sampleproj_path = File.join(File.dirname(File.dirname(__FILE__)), "SampleProjects")
|
4 | 4 |
|
5 | 5 | RSpec.describe ArduinoCI::CppLibrary do
|
6 |
| - cpp_lib_path = File.join(sampleproj_path, "DoSomething") |
| 6 | + cpp_lib_path = File.join(sampleproj_path, "TestSomething") |
7 | 7 | cpp_library = ArduinoCI::CppLibrary.new(cpp_lib_path)
|
8 | 8 | context "cpp_files" do
|
9 | 9 | it "finds cpp files in directory" do
|
10 |
| - dosomething_cpp_files = ["DoSomething/do-something.cpp"] |
| 10 | + testsomething_cpp_files = ["TestSomething/test-something.cpp"] |
11 | 11 | relative_paths = cpp_library.cpp_files.map { |f| f.split("SampleProjects/", 2)[1] }
|
12 |
| - expect(relative_paths).to match_array(dosomething_cpp_files) |
| 12 | + expect(relative_paths).to match_array(testsomething_cpp_files) |
13 | 13 | end
|
14 | 14 | end
|
15 | 15 |
|
16 | 16 | context "header_dirs" do
|
17 | 17 | it "finds directories containing h files" do
|
18 |
| - dosomething_header_dirs = ["DoSomething"] |
| 18 | + testsomething_header_dirs = ["TestSomething"] |
19 | 19 | relative_paths = cpp_library.header_dirs.map { |f| f.split("SampleProjects/", 2)[1] }
|
20 |
| - expect(relative_paths).to match_array(dosomething_header_dirs) |
| 20 | + expect(relative_paths).to match_array(testsomething_header_dirs) |
21 | 21 | end
|
22 | 22 | end
|
23 | 23 |
|
24 | 24 | context "tests_dir" do
|
25 | 25 | it "locate the tests directory" do
|
26 |
| - dosomething_header_dirs = ["DoSomething"] |
| 26 | + testsomething_header_dirs = ["TestSomething"] |
27 | 27 | relative_path = cpp_library.tests_dir.split("SampleProjects/", 2)[1]
|
28 |
| - expect(relative_path).to eq("DoSomething/test") |
| 28 | + expect(relative_path).to eq("TestSomething/test") |
29 | 29 | end
|
30 | 30 | end
|
31 | 31 |
|
32 | 32 | context "test_files" do
|
33 | 33 | it "finds cpp files in directory" do
|
34 |
| - dosomething_test_files = [ |
35 |
| - "DoSomething/test/good-null.cpp", |
36 |
| - "DoSomething/test/good-library.cpp", |
37 |
| - "DoSomething/test/bad-null.cpp" |
| 34 | + testsomething_test_files = [ |
| 35 | + "TestSomething/test/good-null.cpp", |
| 36 | + "TestSomething/test/good-library.cpp", |
| 37 | + "TestSomething/test/bad-null.cpp" |
38 | 38 | ]
|
39 | 39 | relative_paths = cpp_library.test_files.map { |f| f.split("SampleProjects/", 2)[1] }
|
40 |
| - expect(relative_paths).to match_array(dosomething_test_files) |
| 40 | + expect(relative_paths).to match_array(testsomething_test_files) |
41 | 41 | end
|
42 | 42 | end
|
43 | 43 |
|
44 | 44 | context "test" do
|
45 |
| - arduino_cmd = ArduinoCI::ArduinoInstallation.autolocate! |
46 |
| - it "tests libraries" do |
| 45 | + after(:each) do |example| |
| 46 | + if example.exception |
| 47 | + puts "Last command: #{cpp_library.last_cmd}" |
| 48 | + puts "========== Stdout:" |
| 49 | + puts cpp_library.last_out |
| 50 | + puts "========== Stderr:" |
| 51 | + puts cpp_library.last_err |
| 52 | + end |
| 53 | + end |
| 54 | + |
| 55 | + it "is going to test more than one library" do |
47 | 56 | test_files = cpp_library.test_files
|
48 | 57 | expect(test_files.empty?).to be false
|
49 |
| - test_files.each do |path| |
50 |
| - expect(cpp_library.test(path)).to eq(path.include?("good")) |
| 58 | + end |
| 59 | + |
| 60 | + test_files = cpp_library.test_files |
| 61 | + test_files.each do |path| |
| 62 | + expected = path.include?("good") |
| 63 | + it "tests #{File.basename(path)} expecting #{expected}" do |
| 64 | + exe = cpp_library.build_for_test_with_configuration(path, [], nil) |
| 65 | + expect(exe).not_to be nil |
| 66 | + expect(cpp_library.run_test_file(exe)).to eq(expected) |
51 | 67 | end
|
52 | 68 | end
|
53 | 69 | end
|
|
0 commit comments