|
1 | 1 | /*
|
2 |
| -Copyright (c) 2023 Murex |
| 2 | +Copyright (c) 2024 Murex |
3 | 3 |
|
4 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy
|
5 | 5 | of this software and associated documentation files (the "Software"), to deal
|
@@ -31,19 +31,57 @@ const (
|
31 | 31 | toolchainName = "gradle-wrapper"
|
32 | 32 | )
|
33 | 33 |
|
34 |
| -func Test_toolchain_returns_error_when_build_fails(t *testing.T) { |
| 34 | +func Test_toolchain_returns_error_when_build_command_is_not_found(t *testing.T) { |
| 35 | + // Command does not exist in testDataRootDir |
35 | 36 | assertErrorWhenBuildFails(t, toolchainName, testDataRootDir)
|
36 | 37 | }
|
37 | 38 |
|
| 39 | +func Test_toolchain_returns_error_when_build_command_fails(t *testing.T) { |
| 40 | + tchn, _ := Get(toolchainName) |
| 41 | + // Add a built-in toolchain from a valid one, but with invalid build command arguments. |
| 42 | + // This allows to actually run the build command and get an execution error out of it |
| 43 | + failingName := tchn.GetName() + "-failing-build" |
| 44 | + var failingCommands []Command |
| 45 | + for _, cmd := range tchn.GetBuildCommands() { |
| 46 | + failingCommands = append(failingCommands, Command{ |
| 47 | + Os: cmd.Os, |
| 48 | + Arch: cmd.Arch, |
| 49 | + Path: cmd.Path, |
| 50 | + Arguments: []string{"-invalid-argument"}, |
| 51 | + }) |
| 52 | + } |
| 53 | + _ = addBuiltIn(New(failingName, failingCommands, tchn.GetTestCommands(), tchn.GetTestResultDir())) |
| 54 | + assertErrorWhenBuildFails(t, failingName, testDataDirJava) |
| 55 | +} |
| 56 | + |
38 | 57 | func Test_toolchain_returns_ok_when_build_passes(t *testing.T) {
|
39 | 58 | utils.SlowTestTag(t)
|
40 | 59 | assertNoErrorWhenBuildPasses(t, toolchainName, testDataDirJava)
|
41 | 60 | }
|
42 | 61 |
|
43 |
| -func Test_toolchain_returns_error_when_tests_fail(t *testing.T) { |
| 62 | +func Test_toolchain_returns_error_when_test_command_is_not_found(t *testing.T) { |
| 63 | + // Command does not exist in testDataRootDir |
44 | 64 | assertErrorWhenTestFails(t, toolchainName, testDataRootDir)
|
45 | 65 | }
|
46 | 66 |
|
| 67 | +func Test_toolchain_returns_error_when_test_command_fails(t *testing.T) { |
| 68 | + // Add a built-in toolchain from a valid one, but with invalid test command arguments. |
| 69 | + // This allows to actually run the test command and get an execution error out of it |
| 70 | + tchn, _ := Get(toolchainName) |
| 71 | + failingName := tchn.GetName() + "-failing-test" |
| 72 | + var failingCommands []Command |
| 73 | + for _, cmd := range tchn.GetTestCommands() { |
| 74 | + failingCommands = append(failingCommands, Command{ |
| 75 | + Os: cmd.Os, |
| 76 | + Arch: cmd.Arch, |
| 77 | + Path: cmd.Path, |
| 78 | + Arguments: []string{"-invalid-argument"}, |
| 79 | + }) |
| 80 | + } |
| 81 | + _ = addBuiltIn(New(failingName, tchn.GetBuildCommands(), failingCommands, tchn.GetTestResultDir())) |
| 82 | + assertErrorWhenTestFails(t, failingName, testDataDirJava) |
| 83 | +} |
| 84 | + |
47 | 85 | func Test_toolchain_returns_ok_when_tests_pass(t *testing.T) {
|
48 | 86 | utils.SlowTestTag(t)
|
49 | 87 | assertNoErrorWhenTestPasses(t, toolchainName, testDataDirJava)
|
|
0 commit comments