-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support build dependencies between modules in verbose makefile (#551)
- Loading branch information
Showing
24 changed files
with
654 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/SAP/cloud-mta-build-tool/internal/archive" | ||
) | ||
|
||
var _ = Describe("cp command", func() { | ||
BeforeEach(func() { | ||
copyCmdSrc = getTestPath("mtahtml5") | ||
copyCmdTrg = getTestPath("result") | ||
copyCmdPatterns = []string{} | ||
err := dir.CreateDirIfNotExist(copyCmdTrg) | ||
Ω(err).Should(Succeed()) | ||
}) | ||
|
||
AfterEach(func() { | ||
Ω(os.RemoveAll(getTestPath("result"))).Should(Succeed()) | ||
}) | ||
|
||
It("copy - Sanity", func() { | ||
copyCmdPatterns = []string{"mta.*", "ui5app2"} | ||
Ω(copyCmd.RunE(nil, []string{})).Should(Succeed()) | ||
validateFilesInDir(getTestPath("result"), []string{"mta.sh", "mta.yaml", "ui5app2/", "ui5app2/test.txt"}) | ||
}) | ||
It("copy should not fail when the pattern is valid but doesn't match any files", func() { | ||
copyCmdPatterns = []string{"xxx.xxx"} | ||
Ω(copyCmd.RunE(nil, []string{})).Should(Succeed()) | ||
validateFilesInDir(getTestPath("result"), []string{}) | ||
}) | ||
It("copy should not fail when there are no patterns", func() { | ||
copyCmdPatterns = []string{} | ||
Ω(copyCmd.RunE(nil, []string{})).Should(Succeed()) | ||
validateFilesInDir(getTestPath("result"), []string{}) | ||
}) | ||
It("copy should return error when the source folder doesn't exist", func() { | ||
copyCmdSrc = getTestPath("mtahtml6") | ||
copyCmdPatterns = []string{"*"} | ||
Ω(copyCmd.RunE(nil, []string{})).Should(HaveOccurred()) | ||
}) | ||
It("copy should return error when a pattern is invalid", func() { | ||
copyCmdPatterns = []string{"["} | ||
Ω(copyCmd.RunE(nil, []string{})).Should(HaveOccurred()) | ||
}) | ||
}) | ||
|
||
// Check the folder exists and includes exactly the expected files | ||
func validateFilesInDir(src string, expectedFilesInDir []string) { | ||
// List all files in the folder recursively | ||
filesInDir := make([]string, 0) | ||
err := filepath.Walk(src, func(path string, info os.FileInfo, err error) error { | ||
if err != nil { | ||
return err | ||
} | ||
// Don't include the folder itself | ||
if filepath.Clean(path) == filepath.Clean(src) { | ||
return nil | ||
} | ||
relPath, err := filepath.Rel(src, path) | ||
if err != nil { | ||
return err | ||
} | ||
relPath = filepath.ToSlash(relPath) | ||
if info.IsDir() { | ||
relPath += "/" | ||
} | ||
filesInDir = append(filesInDir, relPath) | ||
return nil | ||
}) | ||
Ω(err).Should(Succeed()) | ||
|
||
for _, expectedFile := range expectedFilesInDir { | ||
Ω(contains(expectedFile, filesInDir)).Should(BeTrue(), fmt.Sprintf("expected %s to be in the directory; directory contains %v", expectedFile, filesInDir)) | ||
} | ||
for _, existingFile := range filesInDir { | ||
Ω(contains(existingFile, expectedFilesInDir)).Should(BeTrue(), fmt.Sprintf("did not expect %s to be in the directory; directory contains %v", existingFile, filesInDir)) | ||
} | ||
} | ||
|
||
func contains(element string, elements []string) bool { | ||
for _, el := range elements { | ||
if el == element { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "f1.client", | ||
"title": "f1", | ||
"version": "0.0.1", | ||
"description": "", | ||
"scripts": { | ||
"postinstall": "node ./scripts/bundle.js && npm run lint", | ||
"lint": "node ./node_modules/eslint/bin/eslint . --ext=.js,.json" | ||
}, | ||
"devDependencies": { | ||
"eslint": "4.12.1", | ||
"@sap/eslint-plugin-webide-feature": "1.3.15", | ||
"@sap-webide/webide-client-tools": "latest" | ||
}, | ||
"bundledPlugins": { | ||
"p1": "file:src/p1" | ||
}, | ||
"files": [ | ||
"i18n", | ||
"src", | ||
"config-preload.js", | ||
"config-preload.json", | ||
"package.json" | ||
], | ||
"webidePreloads": { | ||
"js": [ | ||
"config-preload.js", | ||
"i18n/config-preload.js" | ||
], | ||
"config": [ | ||
"config-preload.json" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
_schema-version: "2.0.0" | ||
ID: f1 | ||
version: 0.0.1 | ||
|
||
modules: | ||
- name: module_with_dep | ||
type: html5 | ||
path: public | ||
build-parameters: | ||
builder: zip | ||
requires: | ||
- name: m2 | ||
artifacts: ["*"] | ||
target-path: "client" | ||
- name: m2 | ||
type: html5 | ||
path: client | ||
build-parameters: | ||
builder: zip | ||
supported-platforms: [] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "f1.approuter", | ||
"version": "0.0.1", | ||
"scripts": { | ||
"start": "node node_modules/@sap/approuter/approuter.js" | ||
}, | ||
"dependencies": { | ||
"@sap/approuter": "2.7.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.