Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No testdata copy and circular symlink fix #4728

Merged
merged 12 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ set(CMAKE_PROJECT_DESCRIPTION "Mixxx is Free DJ software that gives you everythi

# Used for force control of color output
set(BUILD_COLORS "auto" CACHE STRING "Try to use colors auto/always/no")
# Option to disable symlinks
set(USE_SYMLINKS ON CACHE BOOL "Use symlinks in build directory when possible")

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
include(CMakeDependentOption)
Expand Down Expand Up @@ -1742,30 +1740,6 @@ add_custom_target(mixxx-benchmark
)
add_dependencies(mixxx-benchmark mixxx-test)

if(UNIX AND USE_SYMLINKS)
add_custom_target(mixxx-testdata
COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/src/test" "${CMAKE_CURRENT_BINARY_DIR}/src/test"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/res/controllers"
COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/res/controllers/common-controller-scripts.js" "${CMAKE_CURRENT_BINARY_DIR}/res/controllers/common-controller-scripts.js"
COMMENT "Symlinking test data to build directory..."
)
elseif(WIN32)
file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/test" CMAKE_CURRENT_SOURCE_TESTDATA_DIR_NATIVE)
file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/src/test/" CMAKE_CURRENT_BINARY_TESTDATA_DIR_NATIVE)
add_custom_target(mixxx-testdata
COMMAND xcopy ${CMAKE_CURRENT_SOURCE_TESTDATA_DIR_NATIVE} ${CMAKE_CURRENT_BINARY_TESTDATA_DIR_NATIVE} /s /d /q /y
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/res/controllers/common-controller-scripts.js" "${CMAKE_CURRENT_BINARY_DIR}/res/controllers/common-controller-scripts.js"
COMMENT "Copying missing or modified test data files to build directory..."
)
else()
add_custom_target(mixxx-testdata
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/src/test" "${CMAKE_CURRENT_BINARY_DIR}/src/test"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/res/controllers/common-controller-scripts.js" "${CMAKE_CURRENT_BINARY_DIR}/res/controllers/common-controller-scripts.js"
COMMENT "Copying all test data files to build directory..."
)
endif()
add_dependencies(mixxx-test mixxx-testdata)

#
# Resources
#
Expand Down
14 changes: 12 additions & 2 deletions src/preferences/configobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const QString kTempFilenameExtension = QStringLiteral(".tmp");
const QString kCMakeCacheFile = QStringLiteral("CMakeCache.txt");
const QLatin1String kSourceDirLine = QLatin1String("mixxx_SOURCE_DIR:STATIC=");

QString computeResourcePath() {
QString computeResourcePathImpl() {
// Try to read in the resource directory from the command line
QString qResourcePath = CmdlineArgs::Instance().getResourcePath();

Expand Down Expand Up @@ -107,7 +107,7 @@ ConfigValueKbd::ConfigValueKbd(const QKeySequence& keys)

template<class ValueType>
ConfigObject<ValueType>::ConfigObject(const QString& file)
: ConfigObject(file, computeResourcePath(), computeSettingsPath(file)) {
: ConfigObject(file, computeResourcePathImpl(), computeSettingsPath(file)) {
reopen(file);
}

Expand Down Expand Up @@ -480,3 +480,13 @@ QString ConfigObject<ConfigValueKbd>::getValue(
}
return value.value;
}

template<>
QString ConfigObject<ConfigValue>::computeResourcePath() {
return computeResourcePathImpl();
}

template<>
QString ConfigObject<ConfigValueKbd>::computeResourcePath() {
return computeResourcePathImpl();
}
2 changes: 2 additions & 0 deletions src/preferences/configobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ template <class ValueType> class ConfigObject {
void reopen(const QString& file);
bool save();

static QString computeResourcePath();
uklotzde marked this conversation as resolved.
Show resolved Hide resolved

// Returns the resource path -- the path where controller presets, skins,
// library schema, keyboard mappings, and more are stored.
QString getResourcePath() const {
Expand Down
7 changes: 3 additions & 4 deletions src/test/autodjprocessor_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ using ::testing::Return;

static int kDefaultTransitionTime = 10;
const mixxx::audio::ChannelCount kChannelCount = mixxx::kEngineChannelCount;
const QString kTrackLocationTest(QDir::currentPath() %
"/src/test/id3-test-data/cover-test-png.mp3");
const QString kTrackLocationTest = QStringLiteral("id3-test-data/cover-test-png.mp3");

class FakeMaster {
public:
Expand Down Expand Up @@ -176,7 +175,7 @@ class AutoDJProcessorTest : public LibraryTest {

TrackPointer newTestTrack(TrackId trackId) const {
TrackPointer pTrack(
Track::newDummy(kTrackLocationTest, trackId));
Track::newDummy(getTestDir().filePath(kTrackLocationTest), trackId));
EXPECT_EQ(
SoundSourceProxy::UpdateTrackFromSourceResult::MetadataImportedAndUpdated,
SoundSourceProxy(pTrack).updateTrackFromSource(
Expand Down Expand Up @@ -232,7 +231,7 @@ class AutoDJProcessorTest : public LibraryTest {

TrackId addTrackToCollection(const QString& trackLocation) {
TrackPointer pTrack =
getOrAddTrackByLocation(trackLocation);
getOrAddTrackByLocation(getTestDir().filePath(trackLocation));
return pTrack ? pTrack->getId() : TrackId();
}

Expand Down
3 changes: 2 additions & 1 deletion src/test/controllerscriptenginelegacy_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ class ControllerScriptEngineLegacyTest : public MixxxTest {
};

TEST_F(ControllerScriptEngineLegacyTest, commonScriptHasNoErrors) {
QFileInfo commonScript("./res/controllers/common-controller-scripts.js");
QFileInfo commonScript(config()->getResourcePath() +
QStringLiteral("/controllers/common-controller-scripts.js"));
EXPECT_TRUE(evaluateScriptFile(commonScript));
}

Expand Down
21 changes: 12 additions & 9 deletions src/test/coverartcache_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,9 @@ class CoverArtCacheTest : public LibraryTest, public CoverArtCache {
}
};

const QString kCoverFileTest("cover_test.jpg");
const QString kCoverLocationTest(QDir::currentPath() %
"/src/test/id3-test-data/" % kCoverFileTest);
const QString kTrackLocationTest(QDir::currentPath() %
"/src/test/id3-test-data/cover-test-png.mp3");

const QString kCoverFileTest = QStringLiteral("cover_test.jpg");
const QString kCoverLocationTest = QStringLiteral("id3-test-data/") + kCoverFileTest;
const QString kTrackLocationTest = QStringLiteral("id3-test-data/cover-test-png.mp3");

// We need 3 separate test cases:
// 1) loadCoverFromMetadata()
Expand All @@ -76,13 +73,19 @@ const QString kTrackLocationTest(QDir::currentPath() %
// - absolute coverLocation

TEST_F(CoverArtCacheTest, loadCoverFromMetadata) {
loadCoverFromMetadata(kTrackLocationTest);
loadCoverFromMetadata(getTestDir().filePath(kTrackLocationTest));
}

TEST_F(CoverArtCacheTest, loadCoverFromFileRelative) {
loadCoverFromFile(kTrackLocationTest, kCoverFileTest, kCoverLocationTest);
loadCoverFromFile(
getTestDir().filePath(kTrackLocationTest),
kCoverFileTest,
getTestDir().filePath(kCoverLocationTest));
}

TEST_F(CoverArtCacheTest, loadCoverFromFileAbsolute) {
loadCoverFromFile(QString(), kCoverLocationTest, kCoverLocationTest);
loadCoverFromFile(
QString(),
getTestDir().filePath(kCoverLocationTest),
getTestDir().filePath(kCoverLocationTest));
}
66 changes: 39 additions & 27 deletions src/test/coverartutils_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

namespace {

const QDir kTestDir(QDir::current().absoluteFilePath("src/test/id3-test-data"));
const QString kReferencePNGLocationTest(kTestDir.absoluteFilePath("reference_cover.png"));
const QString kReferenceJPGLocationTest(kTestDir.absoluteFilePath("cover_test.jpg"));
const QString kReferencePNGLocationTest = QStringLiteral("id3-test-data/reference_cover.png");
const QString kReferenceJPGLocationTest = QStringLiteral("id3-test-data/cover_test.jpg");

void extractEmbeddedCover(
const QString& trackLocation,
Expand All @@ -33,61 +32,73 @@ class CoverArtUtilTest : public LibraryTest, CoverArtCache {
};

TEST_F(CoverArtUtilTest, extractEmbeddedCover) {
QImage referencePNGImage = QImage(kReferencePNGLocationTest);
QImage referenceJPGImage = QImage(kReferenceJPGLocationTest);
QImage referencePNGImage = QImage(getTestDir().filePath(kReferencePNGLocationTest));
QImage referenceJPGImage = QImage(getTestDir().filePath(kReferenceJPGLocationTest));

if (SoundSourceProxy::isFileSuffixSupported(QStringLiteral("aiff"))) {
extractEmbeddedCover(
kTestDir.absoluteFilePath("cover-test.aiff"), referencePNGImage);
extractEmbeddedCover(getTestDir().filePath(QStringLiteral("id3-test-data/cover-test.aiff")),
referencePNGImage);
}

if (SoundSourceProxy::isFileSuffixSupported(QStringLiteral("flac"))) {
extractEmbeddedCover(
kTestDir.absoluteFilePath("cover-test.flac"), referencePNGImage);
extractEmbeddedCover(getTestDir().filePath(QStringLiteral("id3-test-data/cover-test.flac")),
referencePNGImage);
}

if (SoundSourceProxy::isFileSuffixSupported(QStringLiteral("m4a"))) {
extractEmbeddedCover(
kTestDir.absoluteFilePath("cover-test-itunes-12.3.0-aac.m4a"), referencePNGImage);
getTestDir().filePath(QStringLiteral(
"id3-test-data/cover-test-itunes-12.3.0-aac.m4a")),
referencePNGImage);
extractEmbeddedCover(
kTestDir.absoluteFilePath("cover-test-itunes-12.7.0-aac.m4a"), referencePNGImage);
getTestDir().filePath(QStringLiteral(
"id3-test-data/cover-test-itunes-12.7.0-aac.m4a")),
referencePNGImage);
extractEmbeddedCover(
kTestDir.absoluteFilePath("cover-test-itunes-12.7.0-alac.m4a"), referencePNGImage);
getTestDir().filePath(QStringLiteral(
"id3-test-data/cover-test-itunes-12.7.0-alac.m4a")),
referencePNGImage);
}

if (SoundSourceProxy::isFileSuffixSupported(QStringLiteral("m4v"))) {
extractEmbeddedCover(
kTestDir.absoluteFilePath("cover-test.m4v"), referencePNGImage);
extractEmbeddedCover(getTestDir().filePath(QStringLiteral(
"id3-test-data/cover-test.m4v")),
referencePNGImage);
}

if (SoundSourceProxy::isFileSuffixSupported(QStringLiteral("mp3"))) {
// PNG
extractEmbeddedCover(
kTestDir.absoluteFilePath("cover-test-png.mp3"), referencePNGImage);
extractEmbeddedCover(getTestDir().filePath(QStringLiteral(
"id3-test-data/cover-test-png.mp3")),
referencePNGImage);
// JPEG
extractEmbeddedCover(
kTestDir.absoluteFilePath("cover-test-jpg.mp3"), referenceJPGImage);
extractEmbeddedCover(getTestDir().filePath(QStringLiteral(
"id3-test-data/cover-test-jpg.mp3")),
referenceJPGImage);
}

if (SoundSourceProxy::isFileSuffixSupported(QStringLiteral("ogg"))) {
extractEmbeddedCover(
kTestDir.absoluteFilePath("cover-test.ogg"), referencePNGImage);
extractEmbeddedCover(getTestDir().filePath(QStringLiteral(
"id3-test-data/cover-test.ogg")),
referencePNGImage);
}

if (SoundSourceProxy::isFileSuffixSupported(QStringLiteral("opus"))) {
// opus
extractEmbeddedCover(
kTestDir.absoluteFilePath("cover-test.opus"), referencePNGImage);
extractEmbeddedCover(getTestDir().filePath(QStringLiteral("id3-test-data/cover-test.opus")),
referencePNGImage);
}

if (SoundSourceProxy::isFileSuffixSupported(QStringLiteral("wav"))) {
extractEmbeddedCover(
kTestDir.absoluteFilePath("cover-test.wav"), referencePNGImage);
extractEmbeddedCover(getTestDir().filePath(QStringLiteral(
"id3-test-data/cover-test.wav")),
referencePNGImage);
}

if (SoundSourceProxy::isFileSuffixSupported(QStringLiteral("wv"))) {
extractEmbeddedCover(
kTestDir.absoluteFilePath("cover-test.wv"), referencePNGImage);
extractEmbeddedCover(getTestDir().filePath(QStringLiteral(
"id3-test-data/cover-test.wv")),
referencePNGImage);
}
}

Expand All @@ -97,7 +108,8 @@ TEST_F(CoverArtUtilTest, searchImage) {
ASSERT_TRUE(tempTrackDir.isValid());
QString trackdir = QString(tempTrackDir.path());

const QString kTrackLocationTest(kTestDir.absoluteFilePath("cover-test-png.mp3"));
const QString kTrackLocationTest(getTestDir().filePath(
QStringLiteral("id3-test-data/cover-test-png.mp3")));

TrackPointer pTrack(Track::newTemporary(kTrackLocationTest));
QList<QFileInfo> covers;
Expand Down
2 changes: 1 addition & 1 deletion src/test/cuecontrol_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CueControlTest : public BaseSignalPathTest {
}

TrackPointer createTestTrack() const {
const QString kTrackLocationTest = QDir::currentPath() + "/src/test/sine-30.wav";
const QString kTrackLocationTest = getTestDir().filePath(QStringLiteral("sine-30.wav"));
const auto pTrack = Track::newTemporary(
mixxx::FileAccess(mixxx::FileInfo(kTrackLocationTest)));
pTrack->setAudioProperties(
Expand Down
16 changes: 8 additions & 8 deletions src/test/globaltrackcache_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@

namespace {

const QDir kTestDir(QDir::current().absoluteFilePath("src/test/id3-test-data"));

const mixxx::FileInfo kTestFile(kTestDir.absoluteFilePath("cover-test.flac"));
const mixxx::FileInfo kTestFile2(kTestDir.absoluteFilePath("cover-test.ogg"));
const QString kTestFile = QStringLiteral("id3-test-data/cover-test.flac");
const QString kTestFile2 = QStringLiteral("id3-test-data/cover-test.ogg");

class TrackTitleThread: public QThread {
public:
Expand Down Expand Up @@ -97,7 +95,7 @@ TEST_F(GlobalTrackCacheTest, resolveByFileInfo) {

TrackPointer track;
{
auto testFileAccess = mixxx::FileAccess(mixxx::FileInfo(kTestFile));
auto testFileAccess = mixxx::FileAccess(mixxx::FileInfo(getTestDir().filePath(kTestFile)));
GlobalTrackCacheResolver resolver(testFileAccess);
track = resolver.getTrack();
EXPECT_TRUE(static_cast<bool>(track));
Expand Down Expand Up @@ -147,6 +145,8 @@ TEST_F(GlobalTrackCacheTest, concurrentDelete) {
TrackTitleThread workerThread;
workerThread.start();

const auto testFile = mixxx::FileInfo(getTestDir().filePath(kTestFile));

// lp1744550: A decent number of iterations is needed to reliably
// reveal potential race conditions while evicting tracks from
// the cache!
Expand All @@ -160,7 +160,7 @@ TEST_F(GlobalTrackCacheTest, concurrentDelete) {

TrackPointer track;
{
auto testFileAccess = mixxx::FileAccess(mixxx::FileInfo(kTestFile));
auto testFileAccess = mixxx::FileAccess(testFile);
GlobalTrackCacheResolver resolver(testFileAccess);
track = resolver.getTrack();
EXPECT_TRUE(static_cast<bool>(track));
Expand Down Expand Up @@ -203,12 +203,12 @@ TEST_F(GlobalTrackCacheTest, evictWhileMoving) {
ASSERT_TRUE(GlobalTrackCacheLocker().isEmpty());

TrackPointer track1 = GlobalTrackCacheResolver(
mixxx::FileAccess(mixxx::FileInfo(kTestFile)))
mixxx::FileAccess(mixxx::FileInfo(getTestDir().filePath(kTestFile))))
.getTrack();
EXPECT_TRUE(static_cast<bool>(track1));

TrackPointer track2 = GlobalTrackCacheResolver(
mixxx::FileAccess(mixxx::FileInfo(kTestFile2)))
mixxx::FileAccess(mixxx::FileInfo(getTestDir().filePath(kTestFile2))))
.getTrack();
EXPECT_TRUE(static_cast<bool>(track2));

Expand Down
2 changes: 1 addition & 1 deletion src/test/hotcuecontrol_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class HotcueControlTest : public BaseSignalPathTest {
}

TrackPointer createTestTrack() const {
const QString kTrackLocationTest = QDir::currentPath() + "/src/test/sine-30.wav";
const QString kTrackLocationTest = getTestDir().filePath(QStringLiteral("sine-30.wav"));
const auto pTrack = Track::newTemporary(
mixxx::FileAccess(mixxx::FileInfo(kTrackLocationTest)));
pTrack->setAudioProperties(
Expand Down
1 change: 1 addition & 0 deletions src/test/mixxxtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ QString makeTestConfigFile(const QString& path) {

// Static initialization
QScopedPointer<MixxxApplication> MixxxTest::s_pApplication;
QDir MixxxTest::s_TestDir;

MixxxTest::ApplicationScope::ApplicationScope(int& argc, char** argv) {
CmdlineArgs args;
Expand Down
Loading