| 94 | } |
| 95 | |
| 96 | void TestBazaar::addFiles() |
| 97 | { |
| 98 | qDebug() << "Adding files to the repo"; |
| 99 | |
| 100 | //we start it after repoInit, so we still have empty bazaar repo |
| 101 | QFile f(bazaarTest_BaseDir + bazaarTest_FileName); |
| 102 | |
| 103 | if (f.open(QIODevice::WriteOnly)) { |
| 104 | QTextStream input(&f); |
| 105 | input << "HELLO WORLD"; |
| 106 | } |
| 107 | |
| 108 | f.close(); |
| 109 | f.setFileName(bazaarTest_BaseDir + bazaarTest_FileName2); |
| 110 | |
| 111 | if (f.open(QIODevice::WriteOnly)) { |
| 112 | QTextStream input(&f); |
| 113 | input << "No, bar()!"; |
| 114 | } |
| 115 | |
| 116 | f.close(); |
| 117 | |
| 118 | //test bzr-status exitCode (see DVcsJob::setExitCode). |
| 119 | VcsJob* j = m_plugin->status(QList<QUrl>() << QUrl::fromLocalFile(bazaarTest_BaseDir)); |
| 120 | VERIFYJOB(j); |
| 121 | |
| 122 | // /tmp/kdevBazaar_testdir/ and testfile |
| 123 | j = m_plugin->add(QList<QUrl>() << QUrl::fromLocalFile(bazaarTest_BaseDir + bazaarTest_FileName)); |
| 124 | VERIFYJOB(j); |
| 125 | |
| 126 | f.setFileName(bazaarSrcDir + bazaarTest_FileName3); |
| 127 | |
| 128 | if (f.open(QIODevice::WriteOnly)) { |
| 129 | QTextStream input(&f); |
| 130 | input << "No, foo()! It's bar()!"; |
| 131 | } |
| 132 | |
| 133 | f.close(); |
| 134 | |
| 135 | //test bzr-status exitCode again |
| 136 | j = m_plugin->status(QList<QUrl>() << QUrl::fromLocalFile(bazaarTest_BaseDir)); |
| 137 | VERIFYJOB(j); |
| 138 | |
| 139 | //repository path without trailing slash and a file in a parent directory |
| 140 | // /tmp/repo and /tmp/repo/src/bar |
| 141 | j = m_plugin->add(QList<QUrl>() << QUrl::fromLocalFile(bazaarSrcDir + bazaarTest_FileName3)); |
| 142 | VERIFYJOB(j); |
| 143 | |
| 144 | //let's use absolute path, because it's used in ContextMenus |
| 145 | j = m_plugin->add(QList<QUrl>() << QUrl::fromLocalFile(bazaarTest_BaseDir + bazaarTest_FileName2)); |
| 146 | VERIFYJOB(j); |
| 147 | |
| 148 | //Now let's create several files and try "bzr add file1 file2 file3" |
| 149 | const QStringList files{QStringLiteral("file1"), QStringLiteral("file2"), QStringLiteral("la la")}; |
| 150 | QList<QUrl> multipleFiles; |
| 151 | for (const QString& file : files) { |
| 152 | QFile f(bazaarTest_BaseDir + file); |
| 153 | QVERIFY(f.open(QIODevice::WriteOnly)); |