Skip to content

Commit

Permalink
RUMM-334 PR comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
buranmert committed Apr 17, 2020
1 parent 1bd4799 commit 76e74c2
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 101 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
/.build
/.swiftpm
xcuserdata/

*.local.xcconfig
53 changes: 13 additions & 40 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,51 +40,24 @@ $ make

### Repo structure

<details>
<summary>Datadog/</summary>
#### Datadog

- Datadog.xcodeproj
- Datadog
- DatadogTests
- DatadogObjC
1. Datadog.xcodeproj
2. DatadogPrivate _(can be moved to `Sources`)_
* ObjC -> Swift bridge module

</details>
#### Sources

<details>
<summary>Example/</summary>
`Datadog` and `DatadogObjC` source files

- Shopist.xcodeproj
- It also contains Datadog.xcodeproj as sub-project
- Shopist
- Example project using the SDK
- ShopistTests
- ShopistUITests
#### Tests

</details>
`DatadogTests` (unit tests) and `DatadogIntegrationTests` source files

<details>
<summary>SanityChecks/</summary>
#### Dependency manager tests

- Integration
- Cocoapods
- Carthage
- SPM
Isolated example apps using `cocoapods`, `carthage` and `spm` to ensure SDK is well integrated with all supported dependency managers.

#### Examples (to be removed)

</details>

<details>
<summary>Tools/</summary>

A set of command-line tools to automate development tasks, used by CI and `Makefile`

</details>

<details>
<summary>docs/</summary>

### IMPORTANT

The files in this folder are deployed to Datadog website.
Please do NOT add anything to this folder without approval!

</details>
Example apps for different package managers
4 changes: 2 additions & 2 deletions Datadog.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions Datadog/Datadog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
9E2FB2722447660E001C9B7B /* Datadog.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61133B82242393DE00786299 /* Datadog.framework */; };
9E36D92224373EA700BFBDB7 /* SwiftExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E36D92124373EA700BFBDB7 /* SwiftExtensionsTests.swift */; };
9EA6A539244897A900621535 /* LoggingIOBenchmarkTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EA6A538244897A900621535 /* LoggingIOBenchmarkTests.swift */; };
9EA6A53E24489DC800621535 /* TestsDirectory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 61133C462423990D00786299 /* TestsDirectory.swift */; };
9EF49F0F24476D0C004F2CA0 /* HTTPServerMock in Frameworks */ = {isa = PBXBuildFile; productRef = 9EF49F0E24476D0C004F2CA0 /* HTTPServerMock */; };
9EF49F1024476D96004F2CA0 /* BenchmarkTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E2FB27C24476707001C9B7B /* BenchmarkTests.swift */; };
9EF49F1124476D96004F2CA0 /* IntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9E2FB27D24476707001C9B7B /* IntegrationTests.swift */; };
Expand Down Expand Up @@ -250,6 +251,8 @@
9E2FB27C24476707001C9B7B /* BenchmarkTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BenchmarkTests.swift; sourceTree = "<group>"; };
9E2FB27D24476707001C9B7B /* IntegrationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IntegrationTests.swift; sourceTree = "<group>"; };
9E36D92124373EA700BFBDB7 /* SwiftExtensionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftExtensionsTests.swift; sourceTree = "<group>"; };
9E4195742449D739000AB0DB /* app-target.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "app-target.xcconfig"; sourceTree = "<group>"; };
9E4195752449D739000AB0DB /* unit-tests-target.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "unit-tests-target.xcconfig"; sourceTree = "<group>"; };
9EA6A538244897A900621535 /* LoggingIOBenchmarkTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoggingIOBenchmarkTests.swift; sourceTree = "<group>"; };
9EF49F1624476FBD004F2CA0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9EF49F17244770AD004F2CA0 /* DatadogIntegrationTests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = DatadogIntegrationTests.xcconfig; sourceTree = "<group>"; };
Expand Down Expand Up @@ -476,6 +479,7 @@
61133C07242397F200786299 /* TargetSupport */ = {
isa = PBXGroup;
children = (
9E4195732449D739000AB0DB /* xcconfigs */,
61133B84242393DE00786299 /* Datadog */,
61133BF1242397DA00786299 /* DatadogObjc */,
61133B8F242393DE00786299 /* DatadogTests */,
Expand Down Expand Up @@ -711,6 +715,16 @@
path = ../Tests/DatadogIntegrationTests;
sourceTree = "<group>";
};
9E4195732449D739000AB0DB /* xcconfigs */ = {
isa = PBXGroup;
children = (
9E4195742449D739000AB0DB /* app-target.xcconfig */,
9E4195752449D739000AB0DB /* unit-tests-target.xcconfig */,
);
name = xcconfigs;
path = "../../dependency-manager-tests/xcconfigs";
sourceTree = "<group>";
};
9EA6A53A2448982800621535 /* Benchmark */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -788,6 +802,7 @@
61133B87242393DE00786299 /* Sources */,
61133B88242393DE00786299 /* Frameworks */,
61133B89242393DE00786299 /* Resources */,
9EA6A53C24489AB100621535 /* ⚙️ Run linter */,
);
buildRules = (
);
Expand Down Expand Up @@ -827,6 +842,7 @@
9E2FB2462447660E001C9B7B /* Sources */,
9E2FB2712447660E001C9B7B /* Frameworks */,
9E2FB2732447660E001C9B7B /* Resources */,
9EA6A53D24489AE800621535 /* ⚙️ Run linter */,
);
buildRules = (
);
Expand Down Expand Up @@ -934,6 +950,44 @@
shellScript = "if which swiftlint >/dev/null; then\n cd ${SOURCE_ROOT}/..\n ./tools/lint/run-linter.sh\nfi\n";
showEnvVarsInLog = 0;
};
9EA6A53C24489AB100621535 /* ⚙️ Run linter */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "⚙️ Run linter";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n cd ${SOURCE_ROOT}/..\n ./tools/lint/run-linter.sh\nfi\n";
showEnvVarsInLog = 0;
};
9EA6A53D24489AE800621535 /* ⚙️ Run linter */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "⚙️ Run linter";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n cd ${SOURCE_ROOT}/..\n ./tools/lint/run-linter.sh\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -1050,6 +1104,7 @@
9EA6A539244897A900621535 /* LoggingIOBenchmarkTests.swift in Sources */,
9EF49F1324476D96004F2CA0 /* LoggingIntegrationTests.swift in Sources */,
9EF49F1424476DD6004F2CA0 /* LogMatcher.swift in Sources */,
9EA6A53E24489DC800621535 /* TestsDirectory.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
MOCK_SERVER_ADDRESS=
// Get codesign settings from app-target.xcconfig
#include "../dependency-manager-tests/xcconfigs/app-target.xcconfig"

// This file is auto generated by pre-build action
#include "MockServerAddress.local.xcconfig"
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ examples:
./tools/config/generate-examples-config-template.sh
@echo "OK 👌"

benchmark:
@xcodebuild -workspace "Datadog.xcworkspace" -scheme "DatadogIntegrationTests" test -destination "name=iPhone 11 Pro Max"

# Tests if current branch ships a valid SPM package.
test-spm:
@cd dependency-manager-tests/spm && $(MAKE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LoggingIOBenchmarkTests: XCTestCase {
}

override func tearDown() {
try! FileManager.default.removeItem(at: directory.url)
self.directory.delete()
queue = nil
directory = nil
strategy = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class IntegrationTests: XCTestCase {
override func setUp() {
super.setUp()
server = try! connectToServer()
logsDirectory.delete()
}

override func tearDown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,7 @@ import Datadog
import HTTPServerMock
import XCTest

fileprivate func clearPersistedLogs() throws {
let logFilesSubdirectory = "com.datadoghq.logs/v1"
let cachesDirectoryURL = FileManager.default.urls(
for: .cachesDirectory,
in: .userDomainMask
).first
let subdirectoryURL = cachesDirectoryURL?.appendingPathComponent(
logFilesSubdirectory,
isDirectory: true
)
if let dirToRemove = subdirectoryURL {
try FileManager.default.removeItem(at: dirToRemove)
}
}

class LoggingIntegrationTests: IntegrationTests {
override func setUp() {
super.setUp()
try? clearPersistedLogs()
}

private struct Constants {
/// Time needed for logs to be uploaded to mock server.
static let logsDeliveryTime: TimeInterval = 30
Expand Down
24 changes: 0 additions & 24 deletions Tests/DatadogIntegrationTests/TestHelpers.swift

This file was deleted.

9 changes: 4 additions & 5 deletions Tests/DatadogTests/Helpers/TestsDirectory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
import Foundation
@testable import Datadog

func clearPersistedLogs() throws {
let directory = try Directory(withSubdirectoryPath: LogsPersistenceStrategy.Constants.logFilesSubdirectory)
try FileManager.default.removeItem(at: directory.url)
}

/// Creates `Directory` pointing to unique subfolder in `/var/folders/`.
/// Does not create the subfolder - it must be later created with `.create()`.
func obtainUniqueTemporaryDirectory() -> Directory {
Expand All @@ -25,6 +20,10 @@ func obtainUniqueTemporaryDirectory() -> Directory {
/// The subfolder does not exist and can be created and deleted by calling `.create()` and `.delete()`.
let temporaryDirectory = obtainUniqueTemporaryDirectory()

/// Default URL where logs persist in
/// logsDirectory.delete() can be useful in tests when logs need to be cleared
let logsDirectory = try! Directory(withSubdirectoryPath: LogsPersistenceStrategy.Constants.logFilesSubdirectory)

/// Extends `Directory` with set of utilities for convenient work with files in tests.
/// Provides handy methods to create / delete files and directires.
extension Directory {
Expand Down
3 changes: 0 additions & 3 deletions dependency-manager-tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
.build
xcuserdata

# Ignore code signing setup
xcconfigs/datadog.xcconfig

# Carthage test
# - ignore `Cartfile.resolved` and `Cartfile` as they will be re-created for every test run
/carthage/Carthage
Expand Down
2 changes: 1 addition & 1 deletion dependency-manager-tests/xcconfigs/app-target.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ CODE_SIGN_IDENTITY[sdk=iphoneos*]=// use your own Sign Identity
PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]=// use your own Provisioning Profile

// If `datadog.xcconfig` is present, overwrite all settings
#include? "datadog.xcconfig"
#include? "datadog.local.xcconfig"
2 changes: 1 addition & 1 deletion tools/config/generate-http-server-mock-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ if [ ! -f "Package.swift" ]; then
fi

SERVER_ADDRESS=$(./instrumented-tests/http-server-mock/python/server_address.py)
XCCONFIG_FILE="./Datadog/TargetSupport/DatadogIntegrationTests/DatadogIntegrationTests.xcconfig"
XCCONFIG_FILE="./Datadog/TargetSupport/DatadogIntegrationTests/MockServerAddress.local.xcconfig"

echo "MOCK_SERVER_ADDRESS=${SERVER_ADDRESS}" > "${XCCONFIG_FILE}"

0 comments on commit 76e74c2

Please sign in to comment.